From: Paolo Bonzini <pbonzini@redhat.com>
To: Shuah Khan <skhan@linuxfoundation.org>, shuah@kernel.org
Cc: kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] selftests: kvm: fix mismatched fclose() after popen()
Date: Thu, 21 Oct 2021 21:54:26 +0200 [thread overview]
Message-ID: <7edcd370-41a5-f7e8-1ea9-a6073c97638d@redhat.com> (raw)
In-Reply-To: <20211021175603.22391-1-skhan@linuxfoundation.org>
On 21/10/21 19:56, Shuah Khan wrote:
> 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>
> ---
> tools/testing/selftests/kvm/x86_64/mmio_warning_test.c | 2 +-
> 1 file changed, 1 insertion(+), 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 8039e1eff938..9f55ccd169a1 100644
> --- a/tools/testing/selftests/kvm/x86_64/mmio_warning_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/mmio_warning_test.c
> @@ -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;
> }
>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Thanks,
Paolo
prev parent reply other threads:[~2021-10-21 19:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-21 17:56 Shuah Khan
2021-10-21 19:54 ` Paolo Bonzini [this message]
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=7edcd370-41a5-f7e8-1ea9-a6073c97638d@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.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®