Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp161853pxf; Wed, 7 Apr 2021 23:23:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2Mzp3FSPCvqGvqy5qW7mwdDuXkEcJWoGKPcggwtAy7U4xa75wW+hqmwxCiyC7/Zwi1GQA X-Received: by 2002:a17:906:34cc:: with SMTP id h12mr8167514ejb.301.1617863011017; Wed, 07 Apr 2021 23:23:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617863011; cv=none; d=google.com; s=arc-20160816; b=VOtxJlkYB8uMa2xAnqb1Gnzqs6gwS9YuSFoPz+qEcRh7qPdITdvgymg9XeWZkrIkpx uPIjfuuiHWSiADqOevmk3ub2+mSy0eNufpFz1cIyzEOd3baOCKatSBmMADyneDRieiig 7QbYX+p36H06C0wNTxsc71BHP1yRUkYkIJ+4cS7i9RdTSfw8Mb/wUT7v5xf5QW4E1pZO a8XwDWnpItBnp8bBenhK22Ory8lGcQmsDvof1MzyFw5TIzU7mCwPrN+sYzwvRoB3Azzp sT5ncWF/AwHnhTmYaEkcnF1U2T1STVn2IqCYUsB5hQh/CyTbgl5DoXbeLPMsL9xGUD0C IfaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=ZWPFU3Bu5VUh+Nh5BTbIhbmq1hKiLogKUeJyuTQRjIg=; b=V56SxE3WGHHviZNLOpzDX8zjW9JFGmnR3nmcV8/few6EGz9KGaW70dT+luv6FMmtc7 sDfaRSP8mpDpHvdy2i5IfHnDB4Ud1cHymOqvY5ftcb5LOXeZ2yEJvlmRFXSPss5iQRW5 UZi2+3DBPvRWlEME4tUai8p5AUcMzT2t5XVh8rDgrA1opLAAcoMDdaCW6mRBBSftVejs g0xGqHZs98LcRM3myKwdyqReDEuedNBnER0AMH2BuxEn1eR7jHPaWI4MvDrtDxxb5VRO 9C46kiGcnOy9lJxgUHittRV+6v4Bagpa/izfWnj8vaLercR0GuPRUoMHpTArZT4i5oc2 f4Jw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d20si10136829edx.559.2021.04.07.23.23.08; Wed, 07 Apr 2021 23:23:31 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230117AbhDHGWT (ORCPT + 99 others); Thu, 8 Apr 2021 02:22:19 -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-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