Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp575810lqd; Wed, 24 Apr 2024 10:26:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWLsQRLw/W9t4Z2YGcKg/FWAfMtIp2UorXi/vXzKDPqjkD82TQPUPwk2Wl6DOYwXrnPkeiHj99WoUxAA3Laseo8JFKr1P1mOb2LKRr4nQ== X-Google-Smtp-Source: AGHT+IGqnELYts4rPT4FLqGLZeBJ8Q2zwI88okVYPGoGK19yqk71WhUMX+9Qhrc62XKhaSdAEheL X-Received: by 2002:a05:6a20:d80c:b0:1ad:7e66:659a with SMTP id iv12-20020a056a20d80c00b001ad7e66659amr3915236pzb.15.1713979560978; Wed, 24 Apr 2024 10:26:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713979560; cv=pass; d=google.com; s=arc-20160816; b=K2p+nMWO69zqoOgcK+kWHWe5GUQXa8TiSIDIP7+qjrELdgVVVrQuWUNQ5nl8GRtJ/I cgQDRQYR5VOhhZYd5AO689Av/kMvd4Thd2IjZ3ZMiJRVpdKQs8FiWhQxi+g0vng5YSs7 oa8I/6BWX12Ls1+ZssIMe6e25baNv9QLscemdqyk8Svkua65kleieVH6XECoKDYe/AtW jkllRdzMEiJhMNxJvXnPEbPxUBLjS61G3thYJ1gBDFGNi2x5dxMXbddWAlrK6062ecH+ fs/G5fMz2V6DmfvnQnrpjVe2CALsB82qLxTmviMXXI5eoz4CRc4YDVmQqRtHEUaZ8zTF c02A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:from :dkim-signature; bh=0yWWZRRG6Uqys0X6e3Vot40XCX4VTZaqP22WOdg3lac=; fh=LowOlb7w+YkqaSSKqke/BNNS7zA4G4pC3WsSsLQfgHU=; b=Lt7PSOGP56iJgbdpy29FDw9aB2pV9+zd5mzlCd8VkH95p7wZHi/i1YAZe7n5VT8bDg ilcvW1fHs0mV1EHAYy13r/W6g33hYB0ZhMHMDW5zPN+DDPYXs/rmy11FNfwbC41yhNtA TzwMYd0KO1+t9P+kcvy757ZCHD1Xyh5oMCeExKxtF7hzGJ9hGqYkDdsG1dv7AfLlGYHN JO4oD1SUmleOr4fXpQO0WazaC+5SQKMm06jd2e6jrdFayS7gzJyLPu4Se3qNufubX2na HkS8uYtjVmQoOX6dKUmrF7/2EUEfgAfe+QZRsE06P1rRLX4QFlmXJqsn17X3v5ccITV+ LOuQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z2WIpPo3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-157385-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157385-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i5-20020a654845000000b005e2b1c99876si12193626pgs.336.2024.04.24.10.26.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 10:26:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157385-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z2WIpPo3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-157385-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157385-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2759128B24C for ; Wed, 24 Apr 2024 17:24:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E957516D4DE; Wed, 24 Apr 2024 17:24:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z2WIpPo3" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2E30160794; Wed, 24 Apr 2024 17:24:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713979488; cv=none; b=ZwlBdf5JU590Y6j3n9s3ukED31hypOETGV+tDgGCtVz8MIhJek278kSdMEhetRj/zGueybg9cUUCV4bP9WGMBW/b8KunB6FIhYzOffbXDxSxtU53s5Wuozo2RedTHQV4wbsttEr+eIqWvwJMzm2KYNZ27Rv3q2fhtAw5thyu97w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713979488; c=relaxed/simple; bh=7a/aAi2AQMEaXyJBYPENiWldcWe8zLQuMjiOVus5MY4=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=VhDzMUCNJ4gP7x+cVmojQQbxgOTTv5v1vb0vw4krG/jBWP6eNoRfV1viXq9bkwusy3QGqPvu1r56YiZIU6s6V1WRt3s/oxt/dB2OQ9FXKe8HFwZXVdoxWFJ1/UyTW+LCf9aZzDry+wl3mb92f7hnh9qzh1sVklExIIDok2OHGFs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z2WIpPo3; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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, -- Nathan Chancellor