From: Nathan Chancellor <nathan@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>, shuah@kernel.org
Cc: oleg@redhat.com, anna-maria@linutronix.de, frederic@kernel.org,
ndesaulniers@google.com, morbo@google.com,
justinstitt@google.com, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
patches@lists.linux.dev, John Stultz <jstultz@google.com>
Subject: Re: [PATCH] kselftest: Mark functions that unconditionally call exit() as __noreturn
Date: Fri, 12 Apr 2024 09:09:47 -0700 [thread overview]
Message-ID: <20240412160947.GA2252629@dev-arch.thelio-3990X> (raw)
In-Reply-To: <87sezqzsys.ffs@tglx>
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
next prev parent reply other threads:[~2024-04-12 16:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-11 18:45 [PATCH] kselftest: Mark functions that unconditionally call exit() as __noreturn Nathan Chancellor
2024-04-11 21:11 ` Shuah Khan
2024-04-12 12:05 ` Thomas Gleixner
2024-04-12 16:09 ` Nathan Chancellor [this message]
2024-04-12 16:08 ` Bill Wendling
2024-04-12 16:11 ` Bill Wendling
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240412160947.GA2252629@dev-arch.thelio-3990X \
--to=nathan@kernel.org \
--cc=anna-maria@linutronix.de \
--cc=frederic@kernel.org \
--cc=jstultz@google.com \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=ndesaulniers@google.com \
--cc=oleg@redhat.com \
--cc=patches@lists.linux.dev \
--cc=shuah@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox