All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] symbols.c: Avoid warn_unused_result build failure on fgets().
@ 2015-11-04 11:39 Riku Voipio
  2015-11-04 14:04 ` Jan Beulich
  2015-11-04 14:23 ` Ian Campbell
  0 siblings, 2 replies; 6+ messages in thread
From: Riku Voipio @ 2015-11-04 11:39 UTC (permalink / raw)
  To: xen-devel; +Cc: Riku Voipio, ian.campbell, Jan Beulich

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@suse.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 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)
 
  skip_tail:
 	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;
 }
 
-- 
2.6.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-11-09  8:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-04 11:39 [PATCH] symbols.c: Avoid warn_unused_result build failure on fgets() Riku Voipio
2015-11-04 14:04 ` Jan Beulich
2015-11-09  5:03   ` Haozhong Zhang
2015-11-09  8:10     ` Jan Beulich
2015-11-09  8:29       ` Riku Voipio
2015-11-04 14:23 ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.