From: Shuah Khan <skhan@linuxfoundation.org>
To: Nathan Chancellor <nathan@kernel.org>, shuah@kernel.org
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Muhammad Usama Anjum <usama.anjum@collabora.com>,
Thomas Gleixner <tglx@linutronix.de>,
brauner@kernel.org, akpm@linux-foundation.org,
linux-mm@kvack.org, fenghua.yu@intel.com,
reinette.chatre@intel.com, anna-maria@linutronix.de,
frederic@kernel.org, jstultz@google.com, sboyd@kernel.org,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH v2 00/10] selftests: Make ksft_exit functions return void instead of int
Date: Thu, 25 Apr 2024 08:39:52 -0600 [thread overview]
Message-ID: <46c3ea6c-713f-48b1-b4e3-95f5e6813f3c@linuxfoundation.org> (raw)
In-Reply-To: <20240424-ksft-exit-int-to-void-v2-0-c35f3b8c9ca0@kernel.org>
On 4/24/24 11:24, Nathan Chancellor wrote:
> Hi all,
>
> Commit f7d5bcd35d42 ("selftests: kselftest: Mark functions that
> unconditionally call exit() as __noreturn") marked functions that call
> exit() as __noreturn but it did not change the return type of these
> functions from 'void' to 'int' like it should have (since a noreturn
> function by definition cannot return an integer because it does not
> return...) because there are many tests that return the result of the
> ksft_exit function, even though it has never been used due to calling
> exit().
>
> Prior to adding __noreturn, the compiler would not know that the functions
> that call exit() will not return, so code like
>
> void ksft_exit_fail(void)
> {
> exit(1);
> }
>
> void ksft_exit_pass(void)
> {
> exit(0);
> }
>
> int main(void)
> {
> int ret;
>
> ret = foo();
> if (ret)
> ksft_exit_fail();
> ksft_exit_pass();
> }
>
> would cause the compiler to complain that main() does not return an
> integer, even though when ksft_exit_pass() is called, exit() will cause
> the program to terminate. So ksft_exit_...() returns int to make the
> compiler happy.
>
> int ksft_exit_fail(void)
> {
> exit(1);
> }
>
> int ksft_exit_pass(void)
> {
> exit(0);
> }
>
> int main(void)
> {
> int ret;
>
> ret = foo();
> if (ret)
> return ksft_exit_fail();
> return ksft_exit_pass();
> }
>
> While this results in no warnings, it is weird semantically and it has
> issues as noted in the aforementioned __noreturn change. Now that
> __noreturn has been added to these functions, it is much cleaner to
> change the functions to 'void' and eliminate the return statements, as
> it has been made clear to the compiler that these functions terminate
> the program. Drop the return before all instances of ksft_exit_...() in
> a mostly mechanical way.
>
> ---
> Changes in v2:
> - Split series into individual patches per subsystem at Shuah's
> request and CC maintainers for subsystems that have one.
> - Rewrite commit messages for new patches and move previous commit
> message into cover letter to high level explain all changes.
> - Carry forward Thomas and Muhammad's review on patch split, as there
> were no functional changes, please holler if this was inappropriate.
Thank you for carrying the reviewed by tags.
> - Link to v1: https://lore.kernel.org/r/20240417-ksft-exit-int-to-void-v1-1-eff48fdbab39@kernel.org
>
> ---
> Nathan Chancellor (10):
> selftests/clone3: ksft_exit functions do not return
> selftests/ipc: ksft_exit functions do not return
> selftests: membarrier: ksft_exit_pass() does not return
> selftests/mm: ksft_exit functions do not return
> selftests: pidfd: ksft_exit functions do not return
> selftests/resctrl: ksft_exit_skip() does not return
> selftests: sync: ksft_exit_pass() does not return
> selftests: timers: ksft_exit functions do not return
> selftests: x86: ksft_exit_pass() does not return
> selftests: kselftest: Make ksft_exit functions return void instead of int
>
Applied to linux-kselftest next for Linux 6.10-rc1.
thanks,
-- Shuah
prev parent reply other threads:[~2024-04-25 14:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-24 17:24 Nathan Chancellor
2024-04-24 17:24 ` [PATCH v2 01/10] selftests/clone3: ksft_exit functions do not return Nathan Chancellor
2024-04-24 17:24 ` [PATCH v2 02/10] selftests/ipc: " Nathan Chancellor
2024-04-24 17:24 ` [PATCH v2 03/10] selftests: membarrier: ksft_exit_pass() does " Nathan Chancellor
2024-04-24 17:24 ` [PATCH v2 04/10] selftests/mm: ksft_exit functions do " Nathan Chancellor
2024-04-24 17:24 ` [PATCH v2 05/10] selftests: pidfd: " Nathan Chancellor
2024-04-24 17:24 ` [PATCH v2 06/10] selftests/resctrl: ksft_exit_skip() does " Nathan Chancellor
2024-04-24 17:24 ` [PATCH v2 07/10] selftests: sync: ksft_exit_pass() " Nathan Chancellor
2024-04-24 17:24 ` [PATCH v2 08/10] selftests: timers: ksft_exit functions do " Nathan Chancellor
2024-04-24 17:24 ` [PATCH v2 09/10] selftests: x86: ksft_exit_pass() does " Nathan Chancellor
2024-04-24 17:24 ` [PATCH v2 10/10] selftests: kselftest: Make ksft_exit functions return void instead of int Nathan Chancellor
2024-04-25 14:39 ` Shuah Khan [this message]
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=46c3ea6c-713f-48b1-b4e3-95f5e6813f3c@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=anna-maria@linutronix.de \
--cc=brauner@kernel.org \
--cc=fenghua.yu@intel.com \
--cc=frederic@kernel.org \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nathan@kernel.org \
--cc=reinette.chatre@intel.com \
--cc=sboyd@kernel.org \
--cc=shuah@kernel.org \
--cc=tglx@linutronix.de \
--cc=usama.anjum@collabora.com \
/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
all inboxes | Powered by JetHome®