Re: [PATCH] ufs: qcom: Fix confusing cleanup.h syntax

From: Krzysztof Kozlowski

Date: Mon Dec 08 2025 - 02:11:28 EST


On 08/12/2025 06:16, Manivannan Sadhasivam wrote:
> On Mon, Dec 08, 2025 at 03:08:08AM +0100, Krzysztof Kozlowski wrote:
>> Initializing automatic __free variables to NULL without need (e.g.
>> branches with different allocations), followed by actual allocation is
>> in contrary to explicit coding rules guiding cleanup.h:
>>
>> "Given that the "__free(...) = NULL" pattern for variables defined at
>> the top of the function poses this potential interdependency problem the
>> recommendation is to always define and assign variables in one statement
>> and not group variable definitions at the top of the function when
>> __free() is used."
>>
>> Code does not have a bug, but is less readable and uses discouraged
>> coding practice, so fix that by moving declaration to the place of
>> assignment.
>>
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxxxxx>
>
> Thanks. On the side note, I would recommend adding this check to checkpatch to
> warn people in the first place.
>
> Reviewed-by: Manivannan Sadhasivam <mani@xxxxxxxxxx>


That could be too many false positives. =NULL initialization is correct
and valid in certain cases. Just should not be the default/standard.

Best regards,
Krzysztof