From: Shuah Khan <skhan@linuxfoundation.org>
To: pbonzini@redhat.com, shuah@kernel.org
Cc: Shuah Khan <skhan@linuxfoundation.org>,
kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] selftests:kvm: fix get_trans_hugepagesz() ignoring fscanf() return warn
Date: Wed, 15 Sep 2021 15:28:07 -0600 [thread overview]
Message-ID: <ecac8f61fd0ec5c4e608fb0ed2c00016c05c1905.1631737524.git.skhan@linuxfoundation.org> (raw)
In-Reply-To: <cover.1631737524.git.skhan@linuxfoundation.org>
Fix get_trans_hugepagesz() to check fscanf() return value to get rid
of the following warning:
lib/test_util.c: In function ‘get_trans_hugepagesz’:
lib/test_util.c:138:2: warning: ignoring return value of ‘fscanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
138 | fscanf(f, "%ld", &size);
| ^~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
---
tools/testing/selftests/kvm/lib/test_util.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/lib/test_util.c b/tools/testing/selftests/kvm/lib/test_util.c
index af1031fed97f..938cd423643e 100644
--- a/tools/testing/selftests/kvm/lib/test_util.c
+++ b/tools/testing/selftests/kvm/lib/test_util.c
@@ -129,13 +129,16 @@ size_t get_trans_hugepagesz(void)
{
size_t size;
FILE *f;
+ int ret;
TEST_ASSERT(thp_configured(), "THP is not configured in host kernel");
f = fopen("/sys/kernel/mm/transparent_hugepage/hpage_pmd_size", "r");
TEST_ASSERT(f != NULL, "Error in opening transparent_hugepage/hpage_pmd_size");
- fscanf(f, "%ld", &size);
+ ret = fscanf(f, "%ld", &size);
+ ret = fscanf(f, "%ld", &size);
+ TEST_ASSERT(ret < 1, "Error reading transparent_hugepage/hpage_pmd_size");
fclose(f);
return size;
--
2.30.2
next prev parent reply other threads:[~2021-09-15 21:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-15 21:28 [PATCH 0/4] selftests: kvm: fscanf warn fixes and cleanups Shuah Khan
2021-09-15 21:28 ` [PATCH 1/4] selftests:kvm: fix get_warnings_count() ignoring fscanf() return warn Shuah Khan
2021-09-15 21:28 ` Shuah Khan [this message]
2021-09-15 21:28 ` [PATCH 3/4] selftests: kvm: move get_run_delay() into lib/test_util Shuah Khan
2021-09-15 21:28 ` [PATCH 4/4] selftests: kvm: fix get_run_delay() ignoring fscanf() return warn Shuah Khan
2021-09-15 22:34 ` [PATCH 0/4] selftests: kvm: fscanf warn fixes and cleanups Paolo Bonzini
2021-09-16 0:02 ` Shuah Khan
2021-09-16 5:06 ` Paolo Bonzini
2021-09-16 18:31 ` Shuah Khan
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=ecac8f61fd0ec5c4e608fb0ed2c00016c05c1905.1631737524.git.skhan@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=shuah@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).