Re: [PATCH *-next 01/18] mm/mmu_gather: Remove needless return in void API tlb_remove_page()

From: Zijun Hu
Date: Wed Feb 26 2025 - 06:30:56 EST


On 2025/2/26 01:27, Przemek Kitszel wrote:
>>>>> It might not be your preferred coding style, but it is not completely
>>>>> pointless.
>>>>
>>>> based on below C spec such as C17 description. i guess language C does
>>>> not like this usage "return void function in void function";
>>>
>>> This is GNU extension IIRC. Note kernel uses GNU11, not C11
>>
>> any link to share about GNU11's description for this aspect ? (^^)
> this is new for C17 or was there for long time?
>

Standard C spec has that description for long time.
Standard C11 spec also has that description.

> even if this is an extension, it is very nice for generating locked
> wrappers, so you don't have to handle void case specially
>
> void foo_bar(...)
> {
>     lockdep_assert_held(&a_lock);
>     /// ...
> }
>
> // generated
> void foo_bar_lock(...)
> {
>     scoped_guard(mutex, &a_lock)
>         return foo_bar(...);

above is able to be written as below:
scoped_guard(mutex, &a_lock) {
foo_bar(...);
return;
}
> }
i will list my reasons why this usage "return void function in void
function" is not good in cover letter [00/18] of this series.