Re: [PATCH net] ice: Fix freeing uninitialized pointers

Julia Lawall
2024-03-21T20:20:22Z

Does one prefer an initialization of null at the top of the function or an initialization to a meaningful value in the middle of the function ?

(Sorry for top posting)

Sent from my iPhone

> On 21 Mar 2024, at 14:14, Markus Elfring <Markus.Elfring@web.de> wrote:
>
> ﻿
>>
>>> How do you think about to reduce the scope for the affected local variable instead
>>> with the help of a small script (like the following) for the semantic patch language?
>>>
>>> @movement@
>>> attribute name __free;
>>> @@
>>> -u8 *tx_frame __free(kfree);
>>> int i;
>>> ... when any
>>> if (ice_fltr_add_mac(test_vsi, ...))
>>> { ... }
>>> +
>>> +{
>>> +u8 *tx_frame __free(kfree) = NULL;
>>> if (ice_lbtest_create_frame(pf, &tx_frame, ...))
>>> { ... }
>>> ... when any
>>> +}
>>> +
>>> valid_frames = ice_lbtest_receive_frames(...);
>>
>> I believe you don't understand what the scope of the above can be.
>
> Will the understanding improve for the proposed source code transformation?
>
> Regards,
> Markus