[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH-for-5.2? 1/2] tests/qtest: variable defined by g_autofree nee
From: |
Thomas Huth |
Subject: |
Re: [PATCH-for-5.2? 1/2] tests/qtest: variable defined by g_autofree need to be initialized |
Date: |
Thu, 19 Nov 2020 08:55:05 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 |
On 18/11/2020 13.13, Philippe Mathieu-Daudé wrote:
> On 11/18/20 12:56 PM, Chen Qun wrote:
>> According to the glib function requirements, we need initialise
>> the variable. Otherwise there will be compilation warnings:
>>
>> glib-autocleanups.h:28:3: warning: ‘full_name’ may be
>> used uninitialized in this function [-Wmaybe-uninitialized]
>> 28 | g_free (*pp);
>> | ^~~~~~~~~~~~
>>
>> Reported-by: Euler Robot <euler.robot@huawei.com>
>> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
>> ---
>> tests/qtest/npcm7xx_timer-test.c | 8 +++-----
>> 1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/tests/qtest/npcm7xx_timer-test.c
>> b/tests/qtest/npcm7xx_timer-test.c
>> index f08b0cd62a..83774a5b90 100644
>> --- a/tests/qtest/npcm7xx_timer-test.c
>> +++ b/tests/qtest/npcm7xx_timer-test.c
>> @@ -512,11 +512,9 @@ static void test_disable_on_expiration(gconstpointer
>> test_data)
>> */
>> static void tim_add_test(const char *name, const TestData *td,
>> GTestDataFunc fn)
>> {
>
> Or:
>
>> - g_autofree char *full_name;
> + g_autofree char *full_name = NULL;
I think we better go with the current version of the patch - otherwise a
supersmart new compiler version might warn again that the NULL that we
assign here is never used...
Reviewed-by: Thomas Huth <thuth@redhat.com>
[PATCH-for-5.2? 2/2] tests/qtest: fix memleak in npcm7xx_watchdog_timer-test, Chen Qun, 2020/11/18