Skip to content

Commit d6dca06

Browse files
shuahkhgregkh
authored andcommitted
selftests: kvm: fix mismatched fclose() after popen()
[ Upstream commit c3867ab ] 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 <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>
1 parent 9f4bd00 commit d6dca06

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/testing/selftests/kvm/x86_64/mmio_warning_test.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int get_warnings_count(void)
8484
f = popen("dmesg | grep \"WARNING:\" | wc -l", "r");
8585
if (fscanf(f, "%d", &warnings) < 1)
8686
warnings = 0;
87-
fclose(f);
87+
pclose(f);
8888

8989
return warnings;
9090
}

0 commit comments

Comments
 (0)