Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4739895pxb; Tue, 2 Nov 2021 15:07:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRvOqeJX8V84MUgjkoQxs0Yr2b2sVoRjl4fDwbhIsc2fS2KNGnySqn5XFmdFj/DQ1g6UVD X-Received: by 2002:a17:907:a411:: with SMTP id sg17mr24014848ejc.84.1635890832534; Tue, 02 Nov 2021 15:07:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635890832; cv=none; d=google.com; s=arc-20160816; b=REfASqgxXGzXzRRKjEXqaBbemhHdAlT34CX0wB7wOiHguXUUFlcIGzcE6ykkqHSdwt nPNPwnYSg4srkxLAQBkEOI0DIiJ04cTiGZNwTO1mgL0SoSZKedjPu6bToBCRWXCjW4dK KeAGI6D8Sc8W8SOJLn4U/BkTU5C3MF0u31QVUJottS7G2ff1YaTo7yU06AqPtzCQ6dbe dVqhmtbxJS25KU1HGfBaJeEiAKu08mafGh+E+A2PsiKvHNdl9uRrlVPBdsIadiWzUs5M KvyPMSTozlgiC4BKKOhDHcoNkrA4rGWvMQdQkgSnONlO7IpmYZbu31VuQElU7/hSGqQU aGjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=n4F13XQgVfHrFjDyFI3dMs7NsVDxr8/9oSk7fc0QDng=; b=sY6QysLX7DsgQvqH0F/aoc5t/8E9xFTEqdRohGWNusDD237jXwHuLKraOPhDuixisW 6GrNn1v/+/vqk1AMOPc5HhRwJYa3/NUq5s9299HY6rJ2KZUMmbLylAMMUcbqZPa9oG4f 3AQFf4O1/PK324VwzLCRUO29TSIG+JZsDSPtkYQZOu82EVIqp0DnjEyvuBUtpthtkb84 J2LNATelaOLq6+tyuGhWKpKBJ1euALDvEivQ1gFVwqEWXqEEJviQ4W13ueWExtTwRoRc ANuPEbMEJ8ZfsZoac78npvCYwA+wQA/55DC7DhxJoa/tGtaJiHI+1b7Vgizgw/itWseS GSTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="P4nJjt/f"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z22si550431edd.349.2021.11.02.15.06.48; Tue, 02 Nov 2021 15:07:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="P4nJjt/f"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbhKBWHY (ORCPT + 99 others); Tue, 2 Nov 2021 18:07:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229672AbhKBWHX (ORCPT ); Tue, 2 Nov 2021 18:07:23 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23A6FC061714 for ; Tue, 2 Nov 2021 15:04:48 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id z20so2277072edc.13 for ; Tue, 02 Nov 2021 15:04:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=n4F13XQgVfHrFjDyFI3dMs7NsVDxr8/9oSk7fc0QDng=; b=P4nJjt/fXf671D9eUvZ9+y2bS+QDywI1rCVkTQODwOQV83TwA4krXZ7DTRv5643PYu nMXoWLhAOqQBTli5Xrp/KuciRht6NbwzCpTkhpKUxgRFTYGZqdUrZatUog5rJSs2lgfX H6N6qANOFFyiXZvTthW1CuCVJ0KXY4zPBZuHt48oUWyz7Ayj3g9Ooc4FgS6CFJV6h5CY Lbmoz5D1O8xBo+glIM6hvtuQctVF6/T2kHB1n8bmxK8tALLMaAH9NRZb2/MkJ+mLParS RIDHAd2t3NPegMZM91FO1Zejd4HVII8jRLkmTu7iNKMf59bppokv5o2c09jEw+LX5pn8 v4Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=n4F13XQgVfHrFjDyFI3dMs7NsVDxr8/9oSk7fc0QDng=; b=SPDprrrLnQWbZCxqG/9dro1AzkPhfWjVH642TWW7e3Yab26vW78LVyeCoRabJlYZqJ 1XMhRW8tyyvJk9eRV/TtqbUXP4a7dE8ryeJ38MTChcp9+bI7eebpJLap90CS9MjLlM26 FVuPbS+h3fn3nNCWobyGiSjIb9ooj9evbI1w0HanX4/aCBVAGEFKVYZBPau/Of6Ol1Nm RMwc+OuhxDKxQiX7YiL1dHMOktwhOB2AnxjugxI+Fo3EvPu7YXUDtCAoVHIg2SH+ikFO 3tLC4zYG88XMENt88qBkmjzzuZKzqGKg7ybNnaxxTmxfZdbLGXefpi99fQ59T1/wokFD T4xg== X-Gm-Message-State: AOAM532KTTsrvsE4vnHz/9PtqmFK5WOcXWtIiU0ZFU9ONWy3n9BYL9TX j0TtWVbzViKzMYtw8u/tA+00nMyZPRkmxoRl9iYLhA== X-Received: by 2002:a05:6402:1e8e:: with SMTP id f14mr20147051edf.250.1635890686722; Tue, 02 Nov 2021 15:04:46 -0700 (PDT) MIME-Version: 1.0 References: <20211029114312.1921603-1-anders.roxell@linaro.org> <834d18b6-4106-045f-0264-20e54edf47bc@linuxfoundation.org> In-Reply-To: From: Anders Roxell Date: Tue, 2 Nov 2021 23:04:35 +0100 Message-ID: Subject: Re: [PATCH] selftests: kselftest.h: mark functions with 'noreturn' To: Nick Desaulniers Cc: Shuah Khan , shuah@kernel.org, fenghua.yu@intel.com, reinette.chatre@intel.com, john.stultz@linaro.org, tglx@linutronix.de, akpm@linux-foundation.org, nathan@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 30 Oct 2021 at 00:08, Nick Desaulniers wrote: > > On Fri, Oct 29, 2021 at 11:19 AM Shuah Khan wrote: > > > > On 10/29/21 5:43 AM, Anders Roxell wrote: > > > When building kselftests/capabilities the following warning shows up: > > > > > > clang -O2 -g -std=gnu99 -Wall test_execve.c -lcap-ng -lrt -ldl -o test_execve > > > test_execve.c:121:13: warning: variable 'have_outer_privilege' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] > > > } else if (unshare(CLONE_NEWUSER | CLONE_NEWNS) == 0) { > > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > test_execve.c:136:9: note: uninitialized use occurs here > > > return have_outer_privilege; > > > ^~~~~~~~~~~~~~~~~~~~ > > > test_execve.c:121:9: note: remove the 'if' if its condition is always true > > > } else if (unshare(CLONE_NEWUSER | CLONE_NEWNS) == 0) { > > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > test_execve.c:94:27: note: initialize the variable 'have_outer_privilege' to silence this warning > > > bool have_outer_privilege; > > > ^ > > > = false > > > > > > Rework so all the ksft_exit_*() functions have attribue > > > '__attribute__((noreturn))' so the compiler knows that there wont be > > > any return from the function. That said, without > > > '__attribute__((noreturn))' the compiler warns about the above issue > > > since it thinks that it will get back from the ksft_exit_skip() > > > function, which it wont. > > > Cleaning up the callers that rely on ksft_exit_*() return code, since > > > the functions ksft_exit_*() have never returned anything. > > > > > > Signed-off-by: Anders Roxell > > > > Lot of changes to fix this warning. Is this necessary? I would > > like to explore if there is an easier and localized change that > > can fix the problem. > > via `man 3 exit`: > ``` > The exit() function causes normal process termination ... > ... > RETURN VALUE > The exit() function does not return. > ``` > so seeing `ksft_exit_pass`, `ksft_exit_fail`, `ksft_exit_fail_msg`, > `ksft_exit_xfail`, `ksft_exit_xpass`, and `ksft_exit_skip` all > unconditional call `exit` yet return an `int` looks wrong to me on > first glance. So on that point this patch and its resulting diffstat > LGTM. I'll respin the patch with these changes only. > > That said, there are many changes that explicitly call `ksft_exit` > with an expression; are those setting the correct exit code? Note that > ksft_exit_pass is calling exit with KSFT_PASS which is 0. So some of > the negations don't look quite correct to me. For example: > > - return !ksft_get_fail_cnt() ? ksft_exit_pass() : ksft_exit_fail(); > + ksft_exit(!ksft_get_fail_cnt()); > > so if ksft_get_fail_cnt() returns 0, then we were calling > ksft_exit_pass() which exited with 0. Now we'd be exiting with 1? oh, right, thank you for your review. I will drop all the 'ksft_exit()' changes, they should be fixed and go in as separete patches. Cheers, Anders