[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250227130347.GA5880@noisy.programming.kicks-ass.net>
Date: Thu, 27 Feb 2025 14:03:47 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Zijun Hu <zijun_hu@...oud.com>
Cc: Zijun Hu <quic_zijuhu@...cinc.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Will Deacon <will@...nel.org>,
"Aneesh Kumar K.V" <aneesh.kumar@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Nick Piggin <npiggin@...il.com>, Arnd Bergmann <arnd@...db.de>,
Thomas Gleixner <tglx@...utronix.de>,
Herbert Xu <herbert@...dor.apana.org.au>,
"David S. Miller" <davem@...emloft.net>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Danilo Krummrich <dakr@...nel.org>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>,
Johannes Berg <johannes@...solutions.net>,
Jamal Hadi Salim <jhs@...atatu.com>,
Cong Wang <xiyou.wangcong@...il.com>, Jiri Pirko <jiri@...nulli.us>,
Jason Gunthorpe <jgg@...pe.ca>, Leon Romanovsky <leon@...nel.org>,
Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>, Lee Jones <lee@...nel.org>,
Thomas Graf <tgraf@...g.ch>, Christoph Hellwig <hch@....de>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Robin Murphy <robin.murphy@....com>,
Miquel Raynal <miquel.raynal@...tlin.com>,
Richard Weinberger <richard@....at>,
Vignesh Raghavendra <vigneshr@...com>, linux-arch@...r.kernel.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
linux-crypto@...r.kernel.org, netdev@...r.kernel.org,
linux-wireless@...r.kernel.org, linux-rdma@...r.kernel.org,
linux-gpio@...r.kernel.org, linux-pm@...r.kernel.org,
iommu@...ts.linux.dev, linux-mtd@...ts.infradead.org
Subject: Re: [PATCH *-next 00/18] Remove weird and needless 'return' for void
APIs
On Thu, Feb 27, 2025 at 08:48:19PM +0800, Zijun Hu wrote:
> On 2025/2/21 21:02, Zijun Hu wrote:
> > void api_func_a(...);
> >
> > static inline void api_func_b(...)
> > {
> > return api_func_a(...);
> > }
>
> The Usage : Return void function in void function
>
> IMO, perhaps, the usage is not good since:
>
> A) STD C does not like the usage, and i find GCC has no description
> about the usage.
> C11/C17: 6.8.6.4 The return statement
> "A return statement with an expression shall not appear in a
> function whose return type is void"
We really don't use STD C, the kernel is littered with extensions.
> B) According to discussion, the usage have function that return type
> of the callee api_func_a() is monitored. but this function has below
> shortcoming as well:
>
> the monitor is not needed if the caller api_func_b() is in the same
> module with the callee api_func_a(), otherwise, provided the callee is
> a API and provided by author of other module. the author needs to clean
> up lot of usages of the API if he/she changes the API's return type from
> void to any other type, so it is not nice to API provider.
>
> C) perhaps, most ordinary developers don't known the function mentioned
> by B), and also feel strange for the usage
It is quite common to do kernel wide updates using scripts / cocinelle.
If you have a specialization that wraps a function to fill out a default
value, then you want the return types to keep matching.
Ex.
return_type foo(type1 a1, type2 a2);
return_type my_foo(type1 a1)
{
return foo(a1, value);
}
is a normal thing to do. The whole STD C cannot return void bollocks
breaks that when return_type := void, so in that regards I would call
this a STD C defect.
Powered by blists - more mailing lists