[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240412160947.GA2252629@dev-arch.thelio-3990X>
Date: Fri, 12 Apr 2024 09:09:47 -0700
From: Nathan Chancellor <nathan@...nel.org>
To: Thomas Gleixner <tglx@...utronix.de>, shuah@...nel.org
Cc: oleg@...hat.com, anna-maria@...utronix.de, frederic@...nel.org,
ndesaulniers@...gle.com, morbo@...gle.com, justinstitt@...gle.com,
linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
llvm@...ts.linux.dev, patches@...ts.linux.dev,
John Stultz <jstultz@...gle.com>
Subject: Re: [PATCH] kselftest: Mark functions that unconditionally call
exit() as __noreturn
On Fri, Apr 12, 2024 at 02:05:47PM +0200, Thomas Gleixner wrote:
> On Thu, Apr 11 2024 at 11:45, Nathan Chancellor wrote:
> > I have based this change on timers/urgent, as the commit that introduces
> > this particular warning is there and it is marked for stable, even
> > though this appears to be a generic kselftest issue. I think it makes
> > the most sense for this change to go via timers/urgent with Shuah's ack.
> > While __noreturn with a return type other than 'void' does not make much
> > sense semantically, there are many places that these functions are used
> > as the return value for other functions such as main(), so I did not
> > change the return type of these functions from 'int' to 'void' to
> > minimize the necessary changes for a backport (it is an existing issue
> > anyways).
>
> Hrmm. This really want's to be fixed once the change hits Linus tree as this:
>
> static inline __noreturn int ksft_exit_pass(void)
>
> looks seriously broken :)
Yeah, I only realized this morning that prior to this change, making
these functions return void instead of int would have broken
int main(void)
{
<code>
ksft_exit_pass();
}
because without __noreturn, the compiler will complain that main() is
missing a return value. So 'int' -> '__noreturn void' would have been
the proper atomic change but the use of 'return ksft_exit_...();' made
that seem rather difficult when I was writing/testing that change on top
of this one.
However, now that I am actually sitting down and looking at it with a
fresh perspective, I am able to produce a pretty mechanical looking
change with just two sed commands:
sed -i 's;__noreturn\(.*\)int;__noreturn\1void;g' tools/testing/selftests/kselftest.h &&
sed -i 's/\(\s\+\)return\s\+\(.*ksft_exit_x\?\(fail\|pass\|skip\)\)/\1\2/g' $(git grep -lP 'return.*ksft_exit_x?(fail|pass|skip)' | sed s/:/-/g)
Perhaps Shuah could just run that in the kselftest tree and commit the
result once the change from Linus's tree is merged there? Otherwise, I
am happy to send a formal patch once I have something proper to base on.
Thanks for taking just the minimal change :)
Cheers,
Nathan
Powered by blists - more mailing lists