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

Przemek Kitszel przemyslaw.kitszel at intel.com
Tue Feb 25 09:27:55 PST 2025


On 2/24/25 15:45, Zijun Hu wrote:
> On 2025/2/24 21:23, Peter Zijlstra wrote:
>> On Sat, Feb 22, 2025 at 07:00:28PM +0800, Zijun Hu wrote:
>>> On 2025/2/22 04:01, Peter Zijlstra wrote:
>>>>>    */
>>>>>   static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)
>>>>>   {
>>>>> -	return tlb_remove_page_size(tlb, page, PAGE_SIZE);
>>>>> +	tlb_remove_page_size(tlb, page, PAGE_SIZE);
>>>>>   }
>>>> So I don't mind removing it, but note that that return enforces
>>>> tlb_remove_page_size() has void return type.
>>>>
>>>
>>> tlb_remove_page_size() is void function already. (^^)
>>
>> Yes, but if you were to change that, the above return would complain.
>>
>>>> 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?

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(...);
}

etc



More information about the linux-mtd mailing list