]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commitdiff
symbols.c: avoid warn_unused_result build failure on fgets()
authorRiku Voipio <riku.voipio@linaro.org>
Tue, 10 Nov 2015 11:07:55 +0000 (12:07 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 10 Nov 2015 11:07:55 +0000 (12:07 +0100)
In commit:

d37d63d symbols: prefix static symbols with their source file names

An unchecked fgets was added. This causes a compile error at least
on ubuntu utopic:

symbols.c: In function 'read_symbol':
symbols.c:181:3: error: ignoring return value of 'fgets', declared with
attribute warn_unused_result [-Werror=unused-result]
   fgets(str, 500, in); /* discard rest of line */
   ^

Paper over the warning by checking the return value in the if statement.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/tools/symbols.c

index dbf6a1a7ed43eb50f6e66fc43dbf33d7f0392200..1abdf089adde18cfaf1a864f18bb973fab7c8904 100644 (file)
@@ -177,8 +177,8 @@ static int read_symbol(FILE *in, struct sym_entry *s)
        rc = 0;
 
  skip_tail:
-       if (input_format == fmt_sysv)
-               fgets(str, 500, in); /* discard rest of line */
+       if ((input_format == fmt_sysv) && fgets(str, 500, in) == NULL)
+               /* ignore errors while discarding rest of line */;
 
        return rc;
 }