]> granicus.if.org Git - cgit/commitdiff
html: check return value of write
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 20 Mar 2013 19:44:20 +0000 (20:44 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 20 Mar 2013 20:08:32 +0000 (21:08 +0100)
This squelches a gcc warning. It's also correct that we check to see if
there are any partial or failed writes. For now, we just print a warning
to stderr. In the future, perhaps it will prove wise to exit(1) on
partial writes.

html.c

diff --git a/html.c b/html.c
index b5c69034f5dfa8a07d9ccbf8a9c61194e9bd07d6..d60a41ffd45859e748588f488f2ac8f38f9119ad 100644 (file)
--- a/html.c
+++ b/html.c
@@ -63,12 +63,13 @@ char *fmt(const char *format, ...)
 
 void html_raw(const char *data, size_t size)
 {
-       write(htmlfd, data, size);
+       if (write(htmlfd, data, size) != size)
+               fprintf(stderr, "[html.c] html output truncated.\n");
 }
 
 void html(const char *txt)
 {
-       write(htmlfd, txt, strlen(txt));
+       html_raw(txt, strlen(txt));
 }
 
 void htmlf(const char *format, ...)