All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH] libf2fs: avoid build warning
Date: Mon, 31 Oct 2016 21:25:39 -0700	[thread overview]
Message-ID: <20161101042539.32122-1-jaegeuk@kernel.org> (raw)

This avoids the below warnings.

libf2fs_zoned.c:39:8: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result]
fscanf(file, "%s", str);
      ^
libf2fs_zoned.c: In function 'f2fs_get_zone_blocks':
libf2fs_zoned.c:72:8: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result]
fscanf(file, "%s", str);
      ^

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 lib/libf2fs_zoned.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
index 4ef4f1d..93b48f1 100644
--- a/lib/libf2fs_zoned.c
+++ b/lib/libf2fs_zoned.c
@@ -26,6 +26,7 @@ void f2fs_get_zoned_model()
 {
 	char str[128];
 	FILE *file;
+	int res;
 
 	/* Check that this is a zoned block device */
 	snprintf(str, sizeof(str),
@@ -36,9 +37,12 @@ void f2fs_get_zoned_model()
 		goto not_zoned;
 
 	memset(str, 0, sizeof(str));
-	fscanf(file, "%s", str);
+	res = fscanf(file, "%s", str);
 	fclose(file);
 
+	if (res != 1)
+		goto not_zoned;
+
 	if (strcmp(str, "host-aware") == 0) {
 		c.zoned_model = F2FS_ZONED_HA;
 		return;
@@ -57,6 +61,7 @@ int f2fs_get_zone_blocks()
 	uint64_t sectors;
 	char str[128];
 	FILE *file;
+	int res;
 
 	/* Get zone size */
 	c.zone_blocks = 0;
@@ -69,9 +74,12 @@ int f2fs_get_zone_blocks()
 		return -1;
 
 	memset(str, 0, sizeof(str));
-	fscanf(file, "%s", str);
+	res = fscanf(file, "%s", str);
 	fclose(file);
 
+	if (res != 1)
+		return -1;
+
 	sectors = atol(str);
 	if (!sectors)
 		return -1;
-- 
2.8.3


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi

                 reply	other threads:[~2016-11-01  4:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161101042539.32122-1-jaegeuk@kernel.org \
    --to=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.