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 X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F04AC43460 for ; Thu, 8 Apr 2021 06:22:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52FA961178 for ; Thu, 8 Apr 2021 06:22:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230161AbhDHGWU (ORCPT ); Thu, 8 Apr 2021 02:22:20 -0400 Received: from mail-lf1-f51.google.com ([209.85.167.51]:38714 "EHLO mail-lf1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229687AbhDHGWR (ORCPT ); Thu, 8 Apr 2021 02:22:17 -0400 Received: by mail-lf1-f51.google.com with SMTP id j18so2040871lfg.5; Wed, 07 Apr 2021 23:22:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=ZWPFU3Bu5VUh+Nh5BTbIhbmq1hKiLogKUeJyuTQRjIg=; b=Wx19294Cv5HKQqVeKLgphkMIMS96TY0LVESgOUK3qyBEs/hX9EQC1RAVlI8v2rgS+T bRhyYe9CbAL/CyCNOKs7y7Xs5p70O3irEr8ZQ6xRSjSmWhfsRw4lja28eJ04CifWUZ/h szUTeShKcsbYoNCcn9AaH1lPeGl8AO+tzyaXR5XFg7MLA96QC6fkhYwqT+WEfhwtIrAB vmAOrG+sPFb0/UuDD6DoCBpNrIb8+hlvY5hOHVKZDwMNPeK+aDpUeas0N09oyU8gyhSS iwjgcgPOXZOX3Q4Mjjs5xr/W1YehdBEM4zfOVRt+ph+g5K8Ah4MSP4OpKH7EiUo04W5V AFeg== X-Gm-Message-State: AOAM533+XNDt1mwSeI4XkjM5Ac+kO6OqDikXI89bpR5kYuezq1tqKZGH kRVnLyy2QtHllHF8/nlLxRY= X-Google-Smtp-Source: ABdhPJyg9d+lxMZ/XM8In34VrK6USVTKp02AHW8+9f0c29jLKh3SeMW1ICdK8DG2XAMpYxtKBpXdOw== X-Received: by 2002:a05:6512:32ab:: with SMTP id q11mr4983244lfe.106.1617862924211; Wed, 07 Apr 2021 23:22:04 -0700 (PDT) Received: from [10.68.32.192] (broadband-188-32-236-56.ip.moscow.rt.ru. [188.32.236.56]) by smtp.gmail.com with ESMTPSA id p8sm226890lfu.125.2021.04.07.23.22.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Apr 2021 23:22:03 -0700 (PDT) Subject: Re: [PATCH] inotify: fix minmax.cocci warnings To: Julia Lawall , Jan Kara Cc: Amir Goldstein , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kbuild-all@lists.01.org References: <20210407160546.GA3271@quack2.suse.cz> From: Denis Efremov Message-ID: Date: Thu, 8 Apr 2021 09:22:02 +0300 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: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/7/21 8:02 PM, Julia Lawall wrote: > > > On Wed, 7 Apr 2021, Jan Kara wrote: > >> On Tue 06-04-21 22:49:26, Julia Lawall wrote: >>> From: kernel test robot >>> >>> Opportunity for min(). >>> >>> Generated by: scripts/coccinelle/misc/minmax.cocci >>> >>> Fixes: 8636e3295ce3 ("coccinelle: misc: add minmax script") >>> CC: Denis Efremov >>> Reported-by: kernel test robot >>> Signed-off-by: kernel test robot >>> Signed-off-by: Julia Lawall >> ... >>> --- a/fs/notify/inotify/inotify_user.c >>> +++ b/fs/notify/inotify/inotify_user.c >>> @@ -382,7 +382,7 @@ static int inotify_add_to_idr(struct idr >>> >>> spin_unlock(idr_lock); >>> idr_preload_end(); >>> - return ret < 0 ? ret : 0; >>> + return min(ret, 0); >>> } >> >> Honestly, while previous expression is a standard idiom for "if 'ret' holds >> an error, return it", the new expression is harder to understand for me. So >> I prefer to keep things as they are in this particular case... > > OK, I had doubts about it as well, but I forwarded it because I found them > equally obscure... > > Denis, maybe the semantic patch should be updated to avoid this case. No problem, I'll send an update. Thanks, Denis From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============4087276501099663942==" MIME-Version: 1.0 From: Denis Efremov To: kbuild-all@lists.01.org Subject: Re: [PATCH] inotify: fix minmax.cocci warnings Date: Thu, 08 Apr 2021 09:22:02 +0300 Message-ID: In-Reply-To: List-Id: --===============4087276501099663942== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On 4/7/21 8:02 PM, Julia Lawall wrote: > = > = > On Wed, 7 Apr 2021, Jan Kara wrote: > = >> On Tue 06-04-21 22:49:26, Julia Lawall wrote: >>> From: kernel test robot >>> >>> Opportunity for min(). >>> >>> Generated by: scripts/coccinelle/misc/minmax.cocci >>> >>> Fixes: 8636e3295ce3 ("coccinelle: misc: add minmax script") >>> CC: Denis Efremov >>> Reported-by: kernel test robot >>> Signed-off-by: kernel test robot >>> Signed-off-by: Julia Lawall >> ... >>> --- a/fs/notify/inotify/inotify_user.c >>> +++ b/fs/notify/inotify/inotify_user.c >>> @@ -382,7 +382,7 @@ static int inotify_add_to_idr(struct idr >>> >>> spin_unlock(idr_lock); >>> idr_preload_end(); >>> - return ret < 0 ? ret : 0; >>> + return min(ret, 0); >>> } >> >> Honestly, while previous expression is a standard idiom for "if 'ret' ho= lds >> an error, return it", the new expression is harder to understand for me.= So >> I prefer to keep things as they are in this particular case... > = > OK, I had doubts about it as well, but I forwarded it because I found them > equally obscure... > = > Denis, maybe the semantic patch should be updated to avoid this case. No problem, I'll send an update. Thanks, Denis --===============4087276501099663942==--