From mboxrd@z Thu Jan 1 00:00:00 1970 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 32584C4345F for ; Thu, 25 Apr 2024 14:40:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9004B6B0083; Thu, 25 Apr 2024 10:40:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8AF1F6B0088; Thu, 25 Apr 2024 10:40:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 776B86B0089; Thu, 25 Apr 2024 10:40:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 58E9C6B0083 for ; Thu, 25 Apr 2024 10:40:05 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D5E5BA049C for ; Thu, 25 Apr 2024 14:40:04 +0000 (UTC) X-FDA: 82048313928.01.E178E79 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf21.hostedemail.com (Postfix) with ESMTP id 033511C0005 for ; Thu, 25 Apr 2024 14:40:02 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=google header.b=LmRayagr; spf=pass (imf21.hostedemail.com: domain of skhan@linuxfoundation.org designates 209.85.214.174 as permitted sender) smtp.mailfrom=skhan@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714056003; 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:in-reply-to:references:references:dkim-signature; bh=zbFwAjhGWh5upncK28mICUHBRGJEanf6iq+mFqabC1E=; b=8GxgcrjErwFFomh7n7vMBamc34U9zD//nfzHN5cpsIutWZHJp5tYvr4MqhRn+PGQnoJk56 Tx2xaSnMMzCYN3k05S2oUT897/YbvIMK2ZMBFsWJ57IeQgoRAThxn/adBsM4UZHQ4oYhMO 1tCnwrV+Gw6VB31fTVvDEFqywhq87qI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714056003; a=rsa-sha256; cv=none; b=oMuAMg2AT0UVcCPav5D7sAXtVZsDzRn9odCzTtKVNdNIshjYEpzTfcNPgK64FpLAzUeznP A59BhupAJL1rsfZo+sEWrX53AAgLateSlWKRycLw72EcVaSaCkgX1kHqgG9S3BqXkx/PUU B1TKKUYTjVRUId1u1jX6W+4XnE/9xvk= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=google header.b=LmRayagr; spf=pass (imf21.hostedemail.com: domain of skhan@linuxfoundation.org designates 209.85.214.174 as permitted sender) smtp.mailfrom=skhan@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1e85055aebfso562005ad.3 for ; Thu, 25 Apr 2024 07:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1714056002; x=1714660802; darn=kvack.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=zbFwAjhGWh5upncK28mICUHBRGJEanf6iq+mFqabC1E=; b=LmRayagrPY25U7S7qpQtIAMWfoY+tRr2UNKqwfOg85o3YssG3nLpxu7ur4bbfzN3bt SpL2H/DRrgJR8Kgre4qaMQ4nR8ioHblo1w1s+BCxVtTWuYJBRJ8nTwMUk9gm1ZTJjXFb O6LzpNNRwB6Qp/zoNc8U4+yfSyvFR5lFSCXow= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714056002; x=1714660802; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zbFwAjhGWh5upncK28mICUHBRGJEanf6iq+mFqabC1E=; b=EEoozL3ffJQVFBW4pzas/qNGK5lzosulFHmGNrNykmvkHBjWccKd5gTs//srAicZWS j7dtvS1Tjs2itPIuHDlCEnZ8OFhXWbYDoO0nQa2x2m4m1wGmLWXwWsv+KYfS/39VHfH2 roGAB69gOuwNOzSvQ20tAtSllDQf4Iuo1+hjZNAFR2Z8HOzrbuaOYGDtREH4aUwJNQGL DBt+Xts8rDvsMJoCxhxqjCJbGST7Qe86QkzuDy2p81WA2yZVN8VTLV7t87jmYNpwihYe dFO+9a9oGkD7ZItuWdNtmTZ94N7lWmHhqiivUJ8hc0nzKgufbL+tQ4GnVXXwyj2SP9Gb Zdww== X-Forwarded-Encrypted: i=1; AJvYcCVTfyvE3YISN5UofRHzjZody3dwk+lgUr2PLqCisA1aJyPRwihn4irdmOskxGwqmEctjxEBknDsFJbWBlcVhRtccLA= X-Gm-Message-State: AOJu0YwtYviKzz0bLz29fEXNYHbqvMIO2D5kacL6L4NRArvM/Pt4Z/q5 SOxNnJeA3idzoj9tjgcEbMn9oEZY6KFuL90v4yAH5sK5rdQpoYsA+lroJf/ZWoE= X-Google-Smtp-Source: AGHT+IHTcniE7luu0Yhn8p35CQUR1IIBNxaulwYiXiLCmF67vC9Fwvg0LSCum8iFKMf1M25HxyNkWg== X-Received: by 2002:a17:903:4c1:b0:1de:ddc6:27a6 with SMTP id jm1-20020a17090304c100b001deddc627a6mr6271553plb.2.1714056001670; Thu, 25 Apr 2024 07:40:01 -0700 (PDT) Received: from [192.168.43.82] ([223.185.79.208]) by smtp.gmail.com with ESMTPSA id j9-20020a170903024900b001e8d180766dsm11787155plh.278.2024.04.25.07.39.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Apr 2024 07:40:00 -0700 (PDT) Message-ID: <46c3ea6c-713f-48b1-b4e3-95f5e6813f3c@linuxfoundation.org> Date: Thu, 25 Apr 2024 08:39:52 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 00/10] selftests: Make ksft_exit functions return void instead of int To: Nathan Chancellor , shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Muhammad Usama Anjum , Thomas Gleixner , 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 References: <20240424-ksft-exit-int-to-void-v2-0-c35f3b8c9ca0@kernel.org> Content-Language: en-US From: Shuah Khan In-Reply-To: <20240424-ksft-exit-int-to-void-v2-0-c35f3b8c9ca0@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 033511C0005 X-Stat-Signature: soyxgzzir65mmbk7m5n31n5jixrcdrto X-Rspam-User: X-HE-Tag: 1714056002-509030 X-HE-Meta: U2FsdGVkX1/wBqvr9mLDhQ1ANKEyCIjIXUX8o1+PZYfXxfl/1JHzQlCMoHaPQPxc9XR7SWYDEn0kIaffbL4CE1AB0FCeu4TJ4On6rNPpPnW0f8Um6de2kp5NPq8YuxFbnVsjYSNA2sdDu4hMyPRBaNTw06uPjy9SDpnst0iLUGqfBDIkxhJSn1nfZnVsRRcWZVdvJlGrwneIvMFSeAqB0scXGhAPLB/eKF6NvcYXaXCXPHpF5iHJSWpUV3dkK1IkOX8Zrb8Wqzla+FqC5wqaD+siBEHBCaxa5TYvYohikv8vnKPRI0wxebXLMqWz+v2he3JdtQY1TUFICoxbHI6rx8L8CzVyIfGcEEFmpkVmEKl6dTKQ+vJCc9uqAXKUvJS3YUxZdt1yO2EujZGFkGFwPM1YszoBukiV3bfLnLxhgCifKH9pf4qFXZlbjE76bS3HiT7Tu7F+0yDKSxdUsjpbJhw2IPvJl3h5kdk/DKVMWkJjAn91eGfGKliLQpnYj/DuE2knauAXotZJYDQyInbQLTGo3UW9gfIrBn3RqCqvkONEOsBSQNWZdl5OjhtzRr0K6nqmP7bxSxBDB9PWxOTBS+V/JdjZPMkO8f6HTfuVvi9ijCCRusur14rb8tq0PocCYnB27Z32gbCVZGlOkoBOSDWs/nqUeV57PpGaZapKC6DlXTPZdwdQ3ltGKXOSZEqkN6ijUp88dYw98RzjmgrYplAGk9pSEiLUIyDbnl2TzRCPqfdd1DxgiMGJB4/PT8gk10inOjPieW0bFESJrq5an1ezA+POoTl81DffW5tD6SJr5Zmp5jDTCAV3aXF1t7jt4nBxJpef7nCRJnn1NnlvaXGYWTqpZ6JKw2vLc38dTWXR+JhUZO99DuR2t9Gq0wy+iOa8XQhZ2x8wgajHsH6Dj3QESlS17xgjaMa+wIIZHY371N/Nfq/LQ9R6TMmGnaHB9QfZY9ns11sjCxf1nYv 4y9LgIoc TMAiSZHcwiy33+uUzH72XpB8LB2m7FZ8JTg4e79/xnsea52fG6EVqo/lJqOTNekAeh3YF++HjIBqdgoYKJf6a7JlKyqFafK85q3rIgi0rZp5//zm0UJWMTvHnoZRAr7gKozWGO4uKgnn8ai40USytWUs2OkyHg8+p+3e05EcT8NEaReF7hYZPrz0ITESjKBjKE/uGxfBOAK1cuzI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.001499, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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