From 28efe765578c7bf75fea29c6d827b1925a0b3525 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Thu, 29 Apr 2010 20:46:27 +0200 Subject: Check fwrite return values, to silence linker warnings. --- unmime.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'unmime.c') diff --git a/unmime.c b/unmime.c index 1409bd67..67028e77 100644 --- a/unmime.c +++ b/unmime.c @@ -657,7 +657,7 @@ int outlevel = 0; #define BUFSIZE_INCREMENT 4096 #ifdef DEBUG -#define DBG_FWRITE(B,L,BS,FD) ((void)fwrite((B), (L), (BS), (FD))) +#define DBG_FWRITE(B,L,BS,FD) do { if (fwrite((B), (L), (BS), (FD))) { } } while(0) #else #define DBG_FWRITE(B,L,BS,FD) #endif @@ -720,8 +720,11 @@ int main(int argc, char *argv[]) bodytype = MimeBodyType(buffer, 1); i = strlen(buffer); - fwrite(buffer, i, 1, stdout); DBG_FWRITE(buffer, i, 1, fd_conv); + if (fwrite(buffer, i, 1, stdout) < 1) { + perror("fwrite"); + goto barf; + } do { buf_p = (buffer - 1); @@ -738,13 +741,17 @@ int main(int argc, char *argv[]) buf_p = buffer; UnMimeBodyline(&buf_p, 0, 0); } - fwrite(buffer, (buf_p - buffer), 1, stdout); DBG_FWRITE(buffer, (buf_p - buffer), 1, fd_conv); + if (fwrite(buffer, (buf_p - buffer), 1, stdout) < 1) { + perror("fwrite"); + goto barf; + } } } while (buf_p > buffer); +barf: free(buffer); - fflush(stdout); + if (EOF == fflush(stdout)) perror("fflush"); #ifdef DEBUG fclose(fd_orig); @@ -754,4 +761,3 @@ int main(int argc, char *argv[]) return 0; } #endif - -- cgit v1.2.3