[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] symbols.c: Avoid warn_unused_result build failure on fgets().

In commit:

d37d63d symbols: prefix static symbols with their source file names

An unchecked fgets was added. This causes a compile error:

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 like in the other similar fgets-on-error-path
earlier in the same file.

Cc: Jan Beulich <jbeulich@xxxxxxxx>
Signed-off-by: Riku Voipio <riku.voipio@xxxxxxxxxx>
 xen/tools/symbols.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/tools/symbols.c b/xen/tools/symbols.c
index dbf6a1a..7e75be2 100644
--- a/xen/tools/symbols.c
+++ b/xen/tools/symbols.c
@@ -178,8 +178,8 @@ static int read_symbol(FILE *in, struct sym_entry *s)
        if (input_format == fmt_sysv)
-               fgets(str, 500, in); /* discard rest of line */
+               if (fgets(str, 500, in) == NULL) /* discard rest of line */
+                       return -1; /* must check fgets result */
        return rc;

Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.