summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorShuah Khan <skhan@linuxfoundation.org>2021-09-15 15:28:06 -0600
committerShuah Khan <skhan@linuxfoundation.org>2021-09-16 12:57:02 -0600
commit39a71f712d8a13728febd8f3cb3f6db7e1fa7221 (patch)
treeebeda92f8beb947d04e75ba5c5fa84c43e3ab3df /tools
parent8914a7a247e065438a0ec86a58c1c359223d2c9e (diff)
downloadlinux-stable-39a71f712d8a13728febd8f3cb3f6db7e1fa7221.tar.gz
linux-stable-39a71f712d8a13728febd8f3cb3f6db7e1fa7221.tar.bz2
linux-stable-39a71f712d8a13728febd8f3cb3f6db7e1fa7221.zip
selftests:kvm: fix get_warnings_count() ignoring fscanf() return warn
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> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/kvm/x86_64/mmio_warning_test.c3
1 files changed, 2 insertions, 1 deletions
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;