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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2043C433EF for ; Fri, 29 Oct 2021 22:09:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4F1C861039 for ; Fri, 29 Oct 2021 22:09:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4F1C861039 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6E9A2940008; Fri, 29 Oct 2021 18:09:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 699CF940007; Fri, 29 Oct 2021 18:09:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51269940008; Fri, 29 Oct 2021 18:09:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0094.hostedemail.com [216.40.44.94]) by kanga.kvack.org (Postfix) with ESMTP id 2B621940007 for ; Fri, 29 Oct 2021 18:09:02 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A43312B372 for ; Fri, 29 Oct 2021 22:09:01 +0000 (UTC) X-FDA: 78750866082.15.538BC6B Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by imf14.hostedemail.com (Postfix) with ESMTP id E93406001982 for ; Fri, 29 Oct 2021 22:09:01 +0000 (UTC) Received: by mail-lf1-f52.google.com with SMTP id y26so23619703lfa.11 for ; Fri, 29 Oct 2021 15:09:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=di/e3U69r52jrUeczVhaYDryYZW3gCVqBTzf643dQXA=; b=siBSBhQHt2JQUMIuCfPk5GMcIJNl0sLVLxcKN3UsD4tXyGsgH3WEWmSLRrAU/CgOkw m1nBFpfcWScothbQo3334805jUCqyZQ8DCMDfGtkall3bc49XmL233VpH2q3j/+xFte9 H0r15nSoS9F9GuF7B63uNxW+7Ro8dcavpFMfm7bhQMo2Vvfgp4TWW+3M9JUoM38dNugs rstEr9hxp9UEYR0ROMJpxTgiGN4DOplGQ1NzWvKr4b35mAULO00ymFwtPcIDnTsEKn8m jxt9g64HfQr5nudTmSAfnlxV2b9aUfDlhUqiT38vVaxq1IY+t4Pgy66YeliSwD0dFHmd Zy0A== 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=di/e3U69r52jrUeczVhaYDryYZW3gCVqBTzf643dQXA=; b=5Bxf+IaCPU9KDLILxgEC0Ma4AqVPDgExTitSlPdRyNIx50njbvxtl9F9lRXaVpfS7L OJJjb9nicM/wBpcXSsKhkbfYdvMdj73PqOVZQtgaKWOXQ0PMC2gDkhhNO2BIm9kDYgJO D6NN+uE1S2dL/LIxnymjIHigvKH28a0B5SS0YVzBAj3YJs/Ypuo8TSLlsmxV2LxoJRPL qDtVyh+XiTCeB6nQ90ozx/EU5POedtOWArswPZoYwnS5TZPErxMDQxb82ll0Z57ojRhs qs0SgH5dYQjGJog38dGakVBjy0a1GdnHvHBVA4wxfRjuQqs7FhN86np0nlYWoKrELrCJ IBqQ== X-Gm-Message-State: AOAM531aie/f/UWImh95IbLhcdwt5HD55QQTB4ZIx9ehgFfwq62XVO6c FW6mKnUm0pj5NWQWKJAQzotTXpHoKhX3A/6XOpuGEg== X-Google-Smtp-Source: ABdhPJwmyW+e4e+AUcbzMdhS2DXM0GnCOpIZOeUkkp5Q1k3OVptGZfyDFzZPb93dXqg7+B8HDftbWq2U+Ey5QM7jG4M= X-Received: by 2002:a05:6512:3ba5:: with SMTP id g37mr12990042lfv.651.1635545339252; Fri, 29 Oct 2021 15:08:59 -0700 (PDT) MIME-Version: 1.0 References: <20211029114312.1921603-1-anders.roxell@linaro.org> <834d18b6-4106-045f-0264-20e54edf47bc@linuxfoundation.org> In-Reply-To: <834d18b6-4106-045f-0264-20e54edf47bc@linuxfoundation.org> From: Nick Desaulniers Date: Fri, 29 Oct 2021 15:08:48 -0700 Message-ID: Subject: Re: [PATCH] selftests: kselftest.h: mark functions with 'noreturn' To: Shuah Khan , Anders Roxell Cc: 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" X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E93406001982 X-Stat-Signature: wdccgbpuq6szxgri5fmyxeot73qeku78 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=siBSBhQH; spf=pass (imf14.hostedemail.com: domain of ndesaulniers@google.com designates 209.85.167.52 as permitted sender) smtp.mailfrom=ndesaulniers@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1635545341-895626 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000006, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. 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? -- Thanks, ~Nick Desaulniers