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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACCACC433EF for ; Mon, 6 Dec 2021 19:00:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235355AbhLFTEZ (ORCPT ); Mon, 6 Dec 2021 14:04:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233853AbhLFTEY (ORCPT ); Mon, 6 Dec 2021 14:04:24 -0500 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09F5EC061746 for ; Mon, 6 Dec 2021 11:00:55 -0800 (PST) Received: by mail-ot1-x333.google.com with SMTP id w6-20020a9d77c6000000b0055e804fa524so14898371otl.3 for ; Mon, 06 Dec 2021 11:00:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=iMXyhhYM1muMv9jtGH7761BAJSehLUX2R720MHkszZs=; b=bxk1+6gwz716UvC5kPDAZdF39e0lNiACPiH3VTa/zTStmhTG07mZ8BL9grQumJi/Fg B2tzNMg2Sx/dL6wzMWB8FU923ANrhPHRjQgMX1CWEHrBlMIriB7L7EmCDkn3PPHuCCyR vHCg4GyXI3Ttxvp3qJBdyDeo5Zp92T3VV7sMc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=iMXyhhYM1muMv9jtGH7761BAJSehLUX2R720MHkszZs=; b=Z+TEKbdOc/3yctNp7luJp0lp8dvDI/O6fWjqzWHtC/ewx51ojXMp4UJI+KnrhEvPHx nJCdDo4ruH1ye1Ek/OEAhPzkkO3X607W1A0t3uwrbOyyTVsoJgic9gDxfqFPhBpooA37 g9z0L4T4xKLZJZ7UskvHkrS+cs/JKn+5s0MUox/248LDZMMOLFCstgDXnJf18uaL8xDI KWbX+ZOuK5xp2PqFaTL3TXJQuWlX7DZvaOZ3kfk+vv5vmilfNAECMJG9xGJdycjPAlQs fGCaKWUPh9MSnkYSnvEbaoa7zJUg+lbL8tTOYXe9zYhWBDWJlI8l7qziRH6y+pHO6p52 bxAQ== X-Gm-Message-State: AOAM5314tWHRaTICBTFFy46yPkk2EjcySzxGZHhfM3u6G0V6n4efUMZP l73zZaI0K6ZcAc5xC/jyEzTzmg== X-Google-Smtp-Source: ABdhPJymQYnvohPzSLEiN7EBa2qjtuMvyq0wuYedYjGh9lqitfhSnsYf27KggbnzyOSKvsp17YkE1g== X-Received: by 2002:a05:6830:183:: with SMTP id q3mr30410706ota.285.1638817254337; Mon, 06 Dec 2021 11:00:54 -0800 (PST) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id bg38sm3120915oib.40.2021.12.06.11.00.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Dec 2021 11:00:53 -0800 (PST) Subject: Re: [PATCH] mnt: remove unneeded conversion to bool To: Joe Perches , davidcomponentone@gmail.com, shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Yang Guang , Zeal Robot , Shuah Khan References: <3a7435c9e7e7aa8f24d22fd576ce912eb0540272.1637737086.git.yang.guang5@zte.com.cn> <07f4ba23-cf4c-6817-f7a4-5428f35d966c@linuxfoundation.org> <983ee57718a6e5838f79be96b7f7efc638177f76.camel@perches.com> <2236458d6a4e77bd09afb13bba65747a3416f293.camel@perches.com> From: Shuah Khan Message-ID: Date: Mon, 6 Dec 2021 12:00:51 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <2236458d6a4e77bd09afb13bba65747a3416f293.camel@perches.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/3/21 8:06 PM, Joe Perches wrote: > On Fri, 2021-12-03 at 17:24 -0700, Shuah Khan wrote: >> On 12/3/21 12:50 PM, Joe Perches wrote: >>> On Fri, 2021-12-03 at 11:26 -0700, Shuah Khan wrote: >>>> On 11/24/21 5:56 PM, davidcomponentone@gmail.com wrote: >>>>> From: Yang Guang >>>>> >>>>> The coccinelle report >>>>> ./tools/testing/selftests/mount/unprivileged-remount-test.c:285:54-59: >>>>> WARNING: conversion to bool not needed here >>>>> ./tools/testing/selftests/mount/unprivileged-remount-test.c:207:54-59: >>>>> WARNING: conversion to bool not needed here >>>>> Relational and logical operators evaluate to bool, >>>>> explicit conversion is overly verbose and unneeded. >>>>> >>>>> Reported-by: Zeal Robot >>>>> Signed-off-by: Yang Guang >>>>> --- >>>>> tools/testing/selftests/mount/unprivileged-remount-test.c | 4 ++-- >>>>> 1 file changed, 2 insertions(+), 2 deletions(-) >>>>> >>>>> diff --git a/tools/testing/selftests/mount/unprivileged-remount-test.c b/tools/testing/selftests/mount/unprivileged-remount-test.c >>>>> index 584dc6bc3b06..d2917054fe3a 100644 >>>>> --- a/tools/testing/selftests/mount/unprivileged-remount-test.c >>>>> +++ b/tools/testing/selftests/mount/unprivileged-remount-test.c >>>>> @@ -204,7 +204,7 @@ bool test_unpriv_remount(const char *fstype, const char *mount_options, >>>>> if (!WIFEXITED(status)) { >>>>> die("child did not terminate cleanly\n"); >>>>> } >>>>> - return WEXITSTATUS(status) == EXIT_SUCCESS ? true : false; >>>>> + return WEXITSTATUS(status) == EXIT_SUCCESS; >>>>> } >>>>> >>>>> create_and_enter_userns(); >>>>> @@ -282,7 +282,7 @@ static bool test_priv_mount_unpriv_remount(void) >>>>> if (!WIFEXITED(status)) { >>>>> die("child did not terminate cleanly\n"); >>>>> } >>>>> - return WEXITSTATUS(status) == EXIT_SUCCESS ? true : false; >>>>> + return WEXITSTATUS(status) == EXIT_SUCCESS; >>>>> } >>>>> >>>>> orig_mnt_flags = read_mnt_flags(orig_path); >>>>> >>>> >>>> This change doesn't look right. WEXITSTATUS(status) return could be >>>>> 1 or 0 or negative. >>> >>> The change is at least logically correct. >>> >>> And isn't WEXITSTATUS range limited from 0->255 ? >>> >>> https://www.gnu.org/software/libc/manual/html_node/Exit-Status.html >>> >> >> You are right. In any case, I don't see any value in changing the current >> logic. The way it is coded is cryptic enough :) > > Well, it'd be more like the rest of the kernel when changed. > > bool function() > { > ... > return ? true : false; > } > > is pretty redundant. > > Fair enough. Yang Guang, Applied patch. In the future, make sure to use selftests/: convention for patch summary. I fixed this one for now. thanks, -- Shuah