Re: [PATCH *-next 00/18] Remove weird and needless 'return' for void APIs

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

 



On 2025/2/21 23:40, Arnd Bergmann wrote:
>> This patch series is to remove weird and needless 'return' for
>> void APIs under include/ with the following pattern:
>>
>> api_header.h:
>>
>> void api_func_a(...);
>>
>> static inline void api_func_b(...)
>> {
>> 	return api_func_a(...);
>> }
>>
>> Remove the needless 'return' in api_func_b().
>>
>> Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
> I have no objection to the changes, but I think you should
> describe the motivation for them beyond them being 'weird'.
> 

yes. C spec such as C17 have this description about return
statement:

6.8.6.4:
A return statement with an expression shall not appear in a function
whose return type is void. A return statement without an expression
shall only appear in a function whose return type is void.

do we need to treat below return statement as bad code style ?

void api_func_a(...);
void api_func_b(...) {
...
	return api_func_a(...); // return void function in void func
...
}

> Do these 'return' statements get in the way of some other
> work you are doing? Is there a compiler warning you want
> to enable to ensure they don't come back? Is this all of
> the instances in the kernel or just the ones you found by
> inspection?

actually, i find this weird return usage by reading code by accident
in driver core firstly:
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=driver-core-testing&id=a44073c28bc6d4118891d61e31c9fa9dc4333dc0

then i check folder include/ and work out this patch series.

not sure if there are still such instances in current kernel tree.





[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux