Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp426817lqd; Wed, 24 Apr 2024 06:45:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV6gG+Gkrz2XvPgZf/igmF6auGdUYuyVVlpQ2joz+NwATx4PXdNcxgrChIxUOygE/xqltQsld23heMiwzWELFtFnSutbgRIQRz6IdB4dA== X-Google-Smtp-Source: AGHT+IEiGP+s+whOwE1mDoJ4R7W8RX9A3O5NnDDJA+JPBOkIW+lv9REoArW+EFrxDOn+D6iORpf3 X-Received: by 2002:a17:902:d2c2:b0:1e0:e85f:3882 with SMTP id n2-20020a170902d2c200b001e0e85f3882mr3177722plc.38.1713966318788; Wed, 24 Apr 2024 06:45:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713966318; cv=pass; d=google.com; s=arc-20160816; b=c1bDU2M/Yo9kjvMnEC/Sls3drhovW5ds4vnN/cdE+CqQ9hoDfOP+6VHbKlVtPIDu60 ttC9dr1XCf5bM6UuFx7y+6iq/HLroDZcowr4rxBzlP39dkP9Pnjo2NMLUbQidOuhqM2i X1+sVCKGYCYClJC4BekXCwzCLEgy+wXkJPKB9Azms7DspAS7HbtAooCN8AowIw5a7gFM S8l2Z0Bi2v+ToowoOlVoQbtDSeB3lJdWLTWLQrNu+yYGfOtVkGDlztN+ctt2CdmpQze/ Djw29owuoqIGfMTt0h5AfAjM8prRfuUQD74E2D3EcLClOWD/btEb9C2Mn/rVUiUNjNmU TGFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=q/KNDSFclfAattMPcaLu4xqVUcBUQTMHdrpQhgD6K8U=; fh=K87gWhHB6ioXXSQO6ADy68mDFn0HTRtDmXug3dDsJZs=; b=Vmq7VrmT3AoRBZ2dgZeQQV9g23HJpP2tsbWf9guQnUbUaBJWwHEwvVSyv7QwZEAnjk kSrI01p0ubGlmZoGztCzteM8DsdSUFtf84vVF7xUIBkXLoQWpnISsdPVcslBZFEfxgMR LZlKa+vq/cR9fwv4eqO9SVEmPFhlpdeAfzOfG7jCHS390rhyFZrCHlQ5kh1u57Dr0EJi 0CKNvlYmy1XaEutwj5KPQIYYTrPr/Sb4t75310LUCNYNQ2uFy9umzIRMgZuKvKAWb0HC mRjrG3aFReLDUd7Wnyom0eEAWgYCCYLms84IkC3iG8C9VaPn/o7nl97icNXuTSitV4xs /rlg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b="Lf0Y/i09"; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linuxfoundation.org dmarc=pass fromdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-157000-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157000-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b10-20020a170902d50a00b001e7a249fd08si11442189plg.603.2024.04.24.06.45.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 06:45:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157000-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b="Lf0Y/i09"; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linuxfoundation.org dmarc=pass fromdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-157000-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157000-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.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 F10F728706E for ; Wed, 24 Apr 2024 13:44:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4FAF715CD53; Wed, 24 Apr 2024 13:44:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Lf0Y/i09" Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A361A15CD4A for ; Wed, 24 Apr 2024 13:44:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713966280; cv=none; b=qWLA8GDpQmQVEdfeMFZj/d9cIZ22qC9RMgBejWPJ1AKNIyujjt2sxlI80P8ASfdR4UiuuAcW5Rx+hF0n32yZcoOZvWgsiwdNUmvbE2ratpOJ+pXfkSTWKfJAD90KAV5mplIsFwuHm/jcwFiM7+b8GYxsM2mTMwc6R0MOQYZcDZ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713966280; c=relaxed/simple; bh=ihIvZQ1lhIayeVVoC4jmqBSdep063fytTukLDdx9yZY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tRkIUvXz4sF1kqopl+C8I8crLBY6Z3O7Mqzy1eqheEpgTI8epOi6qNewyNMNMOur3/MLu1HiMB7FyimoQVZt/9kplCoD3f06chW4giKPNtiYIPDGJH7PD0lGhy5ab+noRnL8fvZFFPwMLaCfcqVceXJerea8LkNdZcfHhHgpU0g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org; spf=pass smtp.mailfrom=linuxfoundation.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Lf0Y/i09; arc=none smtp.client-ip=209.85.216.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxfoundation.org Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2af71daeec1so46706a91.0 for ; Wed, 24 Apr 2024 06:44:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1713966277; x=1714571077; darn=vger.kernel.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=q/KNDSFclfAattMPcaLu4xqVUcBUQTMHdrpQhgD6K8U=; b=Lf0Y/i09ZT65h/ZO3rpunkp13TtlWGB+JTpr4WWdMiTz6EOhFh+Xs73erB8OGifTfc POTwGkYXL0EoalEL1tdd1hvQqQPnlPQ3qOJa0JgTdrFcxlwkJW0Dtdxe0xDSfsBZItjY jv2MPbj6KRyDgDp01sLi5IHjlSHtddxbCN13c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713966277; x=1714571077; 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=q/KNDSFclfAattMPcaLu4xqVUcBUQTMHdrpQhgD6K8U=; b=kJf/Sq2d9n1OdG7mc7rqoB8F0SPzwBLMYCIb/RdeRPJ0mnL9bsI9zUryukqll9kApR lXM44r5zk/vjj+t4HXCuJS+PbKAfu2SezjKvBEwfLK0agqnNG4xd8KLOMYte728Hail1 hJXtYSz4scSjvIwKafYteOsqr/LxPYbjKmRpZL7VqswrVh/0Tekf2FRoLwAsSsrJhj8u cRB+4FTDpIl2h74vSOZ39nlv+C8u8EyYMD7W7abj7dynfeCB7GFpMxypE0NMe/SGEqWM JJ5rJyWRienbtvvehqVEgtBIgXbyKWGO+NJ4lSUSGvoUh6FDmffIua04lANrUUhudVS0 03Lg== X-Forwarded-Encrypted: i=1; AJvYcCUiGzDytgVcqwKnLGUnXdnEYAZOzZbhhh6PrcslcGSBN5gk5bmLgzCX2jnCPYz/KfRJv+RSbVrQ4XFrRqMBpqZ00KLNLCy+8GL48my/ X-Gm-Message-State: AOJu0YybZRluvj3fw8WCzbsgr7i37q+vRjGKxWQ9Djs4y4VZ1MOB2V+a S1JlCAfXjgyRwPHzvqWo3c5Hh3eXbvmtYqt4KZG04NvrcgjRmyeu6vi2HMrBMck= X-Received: by 2002:a17:902:ed45:b0:1e2:2ac1:aef0 with SMTP id y5-20020a170902ed4500b001e22ac1aef0mr2782540plb.2.1713966277003; Wed, 24 Apr 2024 06:44:37 -0700 (PDT) Received: from [192.168.43.82] ([223.185.79.208]) by smtp.gmail.com with ESMTPSA id kk4-20020a170903070400b001e245d90d6fsm11944854plb.59.2024.04.24.06.44.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Apr 2024 06:44:36 -0700 (PDT) Message-ID: Date: Wed, 24 Apr 2024 07:44:31 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] selftests: Make ksft_exit functions return void instead of int To: Nathan Chancellor , shuah@kernel.org Cc: tglx@linutronix.de, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Shuah Khan References: <20240417-ksft-exit-int-to-void-v1-1-eff48fdbab39@kernel.org> Content-Language: en-US From: Shuah Khan In-Reply-To: <20240417-ksft-exit-int-to-void-v1-1-eff48fdbab39@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/17/24 09:37, Nathan Chancellor wrote: > 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 mechanical way. Only two manually changes were made to transform > > return !ret ? ksft_exit_pass() : ksft_exit_fail(); > > into the more idiomatic > > if (ret) > ksft_exit_fail(); > ksft_exit_pass(); > > as well as a few style clean ups now that the code is shorter. > > Signed-off-by: Nathan Chancellor > --- > 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(-) > Please generate separate patches for each test so it is easy to apply them and also reduce merge conflicts. You are missing maintainers for clone3, mm, pidfd tests. I can take these through kselftest tree, but I need the changes split. thanks, -- Shuah