RE: [PATCH][next] tipc: remove redundant assignment to ret, simplify code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>Subject: Re: [PATCH][next] tipc: remove redundant assignment to ret, simplify code
>
>On 11/04/2024 11:31, Dan Carpenter wrote:
>> On Thu, Apr 11, 2024 at 10:04:10AM +0000, Tung Quang Nguyen wrote:
>>>>
>>> I suggest that err variable should be completely removed. Could you
>>> please also do the same thing for this code ?
>>> "
>>> ...
>>> err = skb_handler(skb, cb, tsk);
>>> if (err) {
>>
>> If we write the code as:
>>
>> 	if (some_function(parameters)) {
>>
>> then at first that looks like a boolean.  People probably think the
>> function returns true/false.  But if we leave it as-is:
>>
>> 	err = some_function(parameters);
>> 	if (err) {
>>
>> Then that looks like error handling.
>>
>> So it's better and more readable to leave it as-is.
>>
>> regards,
>> dan carpenter
>
>I concur with Dan's comments.
>
>Colin
I have a different view.
It does not make sense to me to use stack variable 'err' just for checking return code of the functions (__tipc_nl_add_sk/ __tipc_add_sock_diag) that we know always return true on error.





[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux