html.c: die when write fails
authorJohn Keeping <john@keeping.me.uk>
Sat, 18 May 2013 14:57:03 +0000 (15:57 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 22 May 2013 10:53:06 +0000 (12:53 +0200)
If we fail to write HTML output once, there's no point carrying on so
just write a failure message once and die.  By using Git's die_errno
function we also let the user know in what way the write failed.

Signed-off-by: John Keeping <john@keeping.me.uk>
html.c

diff --git a/html.c b/html.c
index f7772dce1c3284c61e0c4a93dc06e533b85574aa..03277db9b73235c964f608df4e358f44323756c6 100644 (file)
--- a/html.c
+++ b/html.c
@@ -78,7 +78,7 @@ char *fmtalloc(const char *format, ...)
 void html_raw(const char *data, size_t size)
 {
        if (write(htmlfd, data, size) != size)
-               fprintf(stderr, "[html.c] html output truncated.\n");
+               die_errno("write error on html output");
 }
 
 void html(const char *txt)