From patchwork Wed Apr 24 17:24:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 13642246 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 045B0C4345F for ; Wed, 24 Apr 2024 17:24:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7219F8D0024; Wed, 24 Apr 2024 13:24:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D1E78D001F; Wed, 24 Apr 2024 13:24:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 599558D0024; Wed, 24 Apr 2024 13:24:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3B48C8D001F for ; Wed, 24 Apr 2024 13:24:56 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D91B71C1761 for ; Wed, 24 Apr 2024 17:24:50 +0000 (UTC) X-FDA: 82045100340.19.3F493CF Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 1416A80017 for ; Wed, 24 Apr 2024 17:24:48 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Z2WIpPo3; spf=pass (imf02.hostedemail.com: domain of nathan@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=nathan@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713979489; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=0yWWZRRG6Uqys0X6e3Vot40XCX4VTZaqP22WOdg3lac=; b=C0gRtxfV/u2UgimynrEluUDxkYzV/56EhL2RtJlmUs45FVXPVOdZ+f7AIGtwNU7ab+rAJl TYz8NPA0Wv1zfAxbkSSN0FPVygrNnaQ3N1j75d1hNwyCGh+Lttj0fXoPJBPp6qqq5FPyBx tTBzhXnToBQifZ1hQ/B5kIZwoPTMrNo= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Z2WIpPo3; spf=pass (imf02.hostedemail.com: domain of nathan@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=nathan@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713979489; a=rsa-sha256; cv=none; b=zcCxexBVbB3K3xv+hlBZthLdkCdgh0Mlns21UqqFLWX+dgQT9WgYpvQdMYvuukUXFTDnlE oP6/FBjnjyUYtMjZ3ix6XuxwlaNnn3tt4XwYI6ob6UO4nVolzoNcN7Bnx4ng9AGNI4hap7 tdkzOctsPi9VnaDGBrTs0etyk6BbQcA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id CD69F61C3A; Wed, 24 Apr 2024 17:24:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9595C113CD; Wed, 24 Apr 2024 17:24:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713979487; bh=7a/aAi2AQMEaXyJBYPENiWldcWe8zLQuMjiOVus5MY4=; h=From:Subject:Date:To:Cc:From; b=Z2WIpPo3CfWypicVRNJgNKpBkKw2IDDbvmOWn/pVpXbT3ddGt53iU2hSr3QT2XvPj wxzIO4K6WCuwaLySXxCbnVEl3zbO6CHF+i2H3cIn83SpoSi/QbIQ+3xG/GXMC/+ynt 6XfMM6R4nAZXnsIcNclHdJGJZsSriTj2zah+o18dWvKm8RDEN2R1bqzV0dCUQetPLt 7GXh2qfhnGrZKbGIN+ZYsfvyic5ysOF7jq1yI+vmsA/VLZlExE3uhY55rXuV38hYlm s8G2GZ79FFhaa16xxP42lR7/fRXs4jys6AsSCM1pi0lHlzrpR4LA0AcmDbO7h+YtRe N9NgUNJN2i+ig== From: Nathan Chancellor Subject: [PATCH v2 00/10] selftests: Make ksft_exit functions return void instead of int Date: Wed, 24 Apr 2024 10:24:03 -0700 Message-Id: <20240424-ksft-exit-int-to-void-v2-0-c35f3b8c9ca0@kernel.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIADNAKWYC/3WNQQ6CMBBFr0Jm7RgKKODKexgWrZ3CBNOStmkwh LtbSVy6fC/5728QyDMFuBUbeEoc2NkM1amA5yTtSMg6M1Rl1ZSNuOIcTERaOSLbiNFhcqzxImW vVd2Juu0hbxdPhtej+xgyTxyi8+/jJomv/RXbP8UkUCAZ03RGK6nq/j6Tt/Q6Oz/CsO/7BxdNF 5W7AAAA To: shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Muhammad Usama Anjum , Thomas Gleixner , Nathan Chancellor , 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 X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5976; i=nathan@kernel.org; h=from:subject:message-id; bh=7a/aAi2AQMEaXyJBYPENiWldcWe8zLQuMjiOVus5MY4=; b=owGbwMvMwCUmm602sfCA1DTG02pJDGmaDrHX9pxyqA0s1zFa5KucKbPIvNvLxSXIj5eP6bY38 w+GULuOUhYGMS4GWTFFlurHqscNDeecZbxxahLMHFYmkCEMXJwCMJGJ9gz/dBh2a/QtuCOVdXra xRLeO0EBkZfNHHwmZ4SqRfb1Pj6WyvCT0eKB95fvR5afu9AXkLl11RvpwEuhSusOa31c1XGm+Y0 TIwA= X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 X-Rspamd-Queue-Id: 1416A80017 X-Stat-Signature: zbggs7fgyzgxz55whpjmys53qjsouk6a X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1713979488-521668 X-HE-Meta: U2FsdGVkX1/rlGpZmqDv/0TJ2rudMxl9F4giux/h+JxqSZtsuZx8QeMnohOakvwGxeMR3FMqBWWOIRQwquGk6pPHtFWK6whh+hHdUz8O4B7DedoPSp/j01r2+xDT66qpopoUeQZ1V+Ea0U+PkjchTd5aqkaAJodpHfTeq6STphO6S3qmcs3Bpli58zzQ7V3judXGmzpVyvyTbqkPein3F0Qs+iHt+083Pj06bpsxDdB4MwMyWduEzokS6MbdSZAlp7gmzFO0PadYpPGEWhABYuBdTHXNNKkUzodSyxcXOFVWXOfcQFRjI+hTSmwVUkjXWDRNg7fByaL/BpNerxk1tn4rsV2b61pFRta2zH90RubEO0KMehX30JJMFf4E/UekRURwW+BCRWT7zUIO5BD95O+dTmXYdlvc3cjccljma5wKrEXQ46Ofgc2ATN7yUrYsDmxTmindcMbOdfX2dyckpYH8nYItcf3Zd5qw2T61uxBAhRdHks6K4CJBWbtMpQ7cf+tqKrikQmcIFWMuLbFHxQ0Ii5ssAl1SxwBkouNhX3dLP4TI9TIpxrWjeSwcEa7+rdefKju40ZBcHasgQhZ7OdyCIytVq31fFiFnGMqkxb4/lTRCrBWrBP59qpS0Jz/03hIxLn0Xo6umiAGpLeqkN88/cIGOsrM1Mo2DY9KtjUYITSVhknd5DG5lZCVFpEz9hDwzbyTxrwrKteHvLhOFg6zm7qYFTXx+TmjqY6ivjbvkMxpBKu0yvNkeaaprncHLK2h5ibNq+xIiusSG8ssaDzRcuQ+cfMS9nvbTMdiDLeHQShBvS9sO9ewplleUK4MIu54igeLiBEZRmZUHmydRbUfLaLB+TL9PzqPG2fo/ty5An7HEyymUALEYB04sgcAIFCUoGfYgl0yWa5ILMA5c+/oI4JsxWgo13CbZ9CzG6Q68/TxIjyNOmQ1BvykBlsgDatL+87GV47xiTHKAytf 5xjHoJRZ nV9QKDUSKbBIlGjXRYYDKyCN1GkdQSG28HbEjV/fZzEDOYe1ULaI2TqtXLeQUp1TOuKhGDdcNiwO942jsD9ZEfS3U1EbWQ9Y7jgbTVGMRZdCv10lUM+QZlclKpkH9bVBHItJFJDow8R5/iVFMm3KulVvwd5VUUUxLLZche6t6Yy5CwP2ah9UWEO0RrYqbwBW+ElLVa2D4d5eJNf75eC8P48nCVAdBi6NroIgOAli492E9jPaELt0K/vkrPPCJipGZQ9zd3OHJXqkf+t+1P54tIFkxkhz0RDM+F+ijY506XU7Mx0c= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000254, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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. - 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 tools/testing/selftests/clone3/clone3_clear_sighand.c | 2 +- tools/testing/selftests/clone3/clone3_set_tid.c | 4 +++- tools/testing/selftests/ipc/msgque.c | 11 +++++------ tools/testing/selftests/kselftest.h | 12 ++++++------ .../selftests/membarrier/membarrier_test_multi_thread.c | 2 +- .../selftests/membarrier/membarrier_test_single_thread.c | 2 +- tools/testing/selftests/mm/compaction_test.c | 6 +++--- tools/testing/selftests/mm/cow.c | 2 +- tools/testing/selftests/mm/gup_longterm.c | 2 +- tools/testing/selftests/mm/gup_test.c | 4 ++-- tools/testing/selftests/mm/ksm_functional_tests.c | 2 +- tools/testing/selftests/mm/madv_populate.c | 2 +- tools/testing/selftests/mm/mkdirty.c | 2 +- tools/testing/selftests/mm/pagemap_ioctl.c | 4 ++-- tools/testing/selftests/mm/soft-dirty.c | 2 +- tools/testing/selftests/pidfd/pidfd_fdinfo_test.c | 2 +- tools/testing/selftests/pidfd/pidfd_open_test.c | 4 +++- tools/testing/selftests/pidfd/pidfd_poll_test.c | 2 +- tools/testing/selftests/pidfd/pidfd_test.c | 2 +- tools/testing/selftests/resctrl/resctrl_tests.c | 6 +++--- tools/testing/selftests/sync/sync_test.c | 3 +-- tools/testing/selftests/timers/adjtick.c | 4 ++-- tools/testing/selftests/timers/alarmtimer-suspend.c | 4 ++-- tools/testing/selftests/timers/change_skew.c | 4 ++-- tools/testing/selftests/timers/freq-step.c | 4 ++-- tools/testing/selftests/timers/leap-a-day.c | 10 +++++----- tools/testing/selftests/timers/leapcrash.c | 4 ++-- tools/testing/selftests/timers/mqueue-lat.c | 4 ++-- tools/testing/selftests/timers/posix_timers.c | 12 ++++++------ tools/testing/selftests/timers/raw_skew.c | 6 +++--- tools/testing/selftests/timers/set-2038.c | 4 ++-- tools/testing/selftests/timers/set-tai.c | 4 ++-- tools/testing/selftests/timers/set-timer-lat.c | 4 ++-- tools/testing/selftests/timers/set-tz.c | 4 ++-- tools/testing/selftests/timers/skew_consistency.c | 4 ++-- tools/testing/selftests/timers/threadtest.c | 2 +- tools/testing/selftests/timers/valid-adjtimex.c | 6 +++--- tools/testing/selftests/x86/lam.c | 2 +- 38 files changed, 81 insertions(+), 79 deletions(-) --- base-commit: 0e275f65f3ef9c662b678655c70aca555fbde304 change-id: 20240416-ksft-exit-int-to-void-5aa9db381379 Best regards,