Skip to content

Commit

Permalink
selftests:kvm: fix get_warnings_count() ignoring fscanf() return warn
Browse files Browse the repository at this point in the history
[ Upstream commit 39a71f7 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
shuahkh authored and gregkh committed Oct 9, 2021
1 parent bcc4b4d commit c450640
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/testing/selftests/kvm/x86_64/mmio_warning_test.c
Expand Up @@ -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;
Expand Down

0 comments on commit c450640

Please sign in to comment.