[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a3825ab2-8987-4b85-9db0-642035789c49@web.de>
Date: Sat, 30 Dec 2023 14:36:37 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: James Bottomley <jejb@...ux.ibm.com>, linux-scsi@...r.kernel.org,
kernel-janitors@...r.kernel.org,
"Martin K. Petersen" <martin.petersen@...cle.com>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: Re: scsi: ses: Move a label in ses_enclosure_data_process()
>> You probably know some advices from another information source.
>>
>> https://wiki.sei.cmu.edu/confluence/display/c/MEM12-C.+Consider+using+a+goto+chain+when+leaving+a+function+on+error+when+using+and+releasing+resources
>>
>
> Yes, but it's about using staged deallocation at the end of the
> function instead of in the if loops. That's to *simplify* the exit
> chain and make the error legs less error prone because the teardown
> isn't repeated in if bodies. It has no bearing on what you just tried
> to do.
I got the impression that there is a general conflict involved
according to different programming styles.
>>> If coccinelle
>>> suddenly thinks this is a problem, it's coccinelle that needs
>>> fixing.
>>
>> This software tool can help to point source code places out for
>> further considerations. The search patterns are evolving accordingly.
>
> The pattern is wrong because kfree(NULL) exists as a teardown simplification.
It might be convenient to view in this way.
If you would dare to follow advice from goto chains in a strict way,
I imagine that you can tend to stress the attention for more useful
data processing a bit more than such a redundant function call.
Regards,
Markus
Powered by blists - more mailing lists