lkml.org 
[lkml]   [2021]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.14 303/849] selftests: kvm: fix mismatched fclose() after popen()
    Date
    From: Shuah Khan <skhan@linuxfoundation.org>

    [ Upstream commit c3867ab5924b7a9a0b4a117902a08669d8be7c21 ]

    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>
    ---
    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 8039e1eff9388..9f55ccd169a13 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;
    }
    --
    2.33.0


    \
     
     \ /
      Last update: 2021-11-16 02:40    [W:2.940 / U:0.064 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site