Skip to content

Commit

Permalink
selftests: kvm: fix mismatched fclose() after popen()
Browse files Browse the repository at this point in the history
get_warnings_count() does fclose() using File * returned from popen().
Fix it to call pclose() as it should.

tools/testing/selftests/kvm/x86_64/mmio_warning_test
x86_64/mmio_warning_test.c: In function ‘get_warnings_count’:
x86_64/mmio_warning_test.c:87:9: warning: ‘fclose’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
   87 |         fclose(f);
      |         ^~~~~~~~~
x86_64/mmio_warning_test.c:84:13: note: returned from ‘popen’
   84 |         f = popen("dmesg | grep \"WARNING:\" | wc -l", "r");
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Shuah Khan <[email protected]>
Acked-by: Paolo Bonzini <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
  • Loading branch information
shuahkh committed Oct 21, 2021
1 parent 519d819 commit c3867ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/testing/selftests/kvm/x86_64/mmio_warning_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int get_warnings_count(void)
f = popen("dmesg | grep \"WARNING:\" | wc -l", "r");
if (fscanf(f, "%d", &warnings) < 1)
warnings = 0;
fclose(f);
pclose(f);

return warnings;
}
Expand Down

0 comments on commit c3867ab

Please sign in to comment.