From 0716c46281ea524ae84f602e146370fa791302d4 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Thu, 18 Dec 2014 12:30:50 -0600 Subject: [PATCH] wmcdplay: Fix -Wunused-result compiler warnings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In particular, fix warnings of the form "warning: ignoring return value of ‘char* fgets(char*, int, FILE*)’, declared with attribute warn_unused_result" by checking return value of fgets. --- wmcdplay/wmcdplay.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wmcdplay/wmcdplay.cc b/wmcdplay/wmcdplay.cc index 0108b89..ab18f4a 100644 --- a/wmcdplay/wmcdplay.cc +++ b/wmcdplay/wmcdplay.cc @@ -644,7 +644,10 @@ bool readArtwork(char *artfilen){ char buf[256]; bool done=false; while(!done){ - fgets(buf, 250, artfile); + if (fgets(buf, 250, artfile) == NULL) { + fprintf(stderr,"%s : Error reading artwork file.\n", NAME); + return false; + } done=(feof(artfile)!=0); if(!done){ @@ -734,7 +737,10 @@ char *readBlock(FILE *dfile){ long bytes=0; char *block=NULL; do{ - fgets(buf, 250, dfile); + if (fgets(buf, 250, dfile) == NULL) { + fprintf(stderr,"%s : Error reading artwork file.\n", NAME); + return NULL; + } int buflen=strlen(buf); block=(char *)realloc(block, sizeof(char)*(bytes+buflen+1)); strcpy(block+bytes, buf);