diff mbox

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

Message ID 1447059973-11330-1-git-send-email-riku.voipio@linaro.org
State New
Headers show

Commit Message

Riku Voipio Nov. 9, 2015, 9:06 a.m. UTC
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.

Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>

---
 xen/tools/symbols.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.6.2


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
diff mbox

Patch

diff --git a/xen/tools/symbols.c b/xen/tools/symbols.c
index dbf6a1a..3b8fa39 100644
--- a/xen/tools/symbols.c
+++ b/xen/tools/symbols.c
@@ -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)
+		return rc; /* discard rest of line and ignore errors */
 
 	return rc;
 }