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 1/4] selftests:kvm: fix get_warnings_count() ignoring fscanf() return warn
Date: Wed, 15 Sep 2021 15:28:06 -0600 [thread overview]
Message-ID: <9dfad43fb500a77f7a08e5e7b80dcb07172d6e44.1631737524.git.skhan@linuxfoundation.org> (raw)
In-Reply-To: <cover.1631737524.git.skhan@linuxfoundation.org>
Fix get_warnings_count() to check fscanf() return value to get rid
of the following warning:
x86_64/mmio_warning_test.c: In function ‘get_warnings_count’:
x86_64/mmio_warning_test.c:85:2: warning: ignoring return value of ‘fscanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
85 | fscanf(f, "%d", &warnings);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
---
tools/testing/selftests/kvm/x86_64/mmio_warning_test.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/x86_64/mmio_warning_test.c b/tools/testing/selftests/kvm/x86_64/mmio_warning_test.c
index e6480fd5c4bd..8039e1eff938 100644
--- a/tools/testing/selftests/kvm/x86_64/mmio_warning_test.c
+++ b/tools/testing/selftests/kvm/x86_64/mmio_warning_test.c
@@ -82,7 +82,8 @@ int get_warnings_count(void)
FILE *f;
f = popen("dmesg | grep \"WARNING:\" | wc -l", "r");
- fscanf(f, "%d", &warnings);
+ if (fscanf(f, "%d", &warnings) < 1)
+ warnings = 0;
fclose(f);
return warnings;
--
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 ` Shuah Khan [this message]
2021-09-15 21:28 ` [PATCH 2/4] selftests:kvm: fix get_trans_hugepagesz() ignoring fscanf() return warn Shuah Khan
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=9dfad43fb500a77f7a08e5e7b80dcb07172d6e44.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
all inboxes | Powered by JetHome®