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.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 35E76C433ED for ; Wed, 7 Apr 2021 17:03:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07CD3610CC for ; Wed, 7 Apr 2021 17:03:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354489AbhDGRDK (ORCPT ); Wed, 7 Apr 2021 13:03:10 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:11009 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229751AbhDGRDE (ORCPT ); Wed, 7 Apr 2021 13:03:04 -0400 IronPort-HdrOrdr: =?us-ascii?q?A9a23=3Aw9vIHqsa0jACAfO/1Fj7Ros27skDrtV00zAX?= =?us-ascii?q?/kB9WHVpW+afkN2jm+le6A/shF8qOE0ItNicNMC7K0/02oVy5eAqUIuKeCnDlC?= =?us-ascii?q?+WIJp57Y3kqgeOJwTb+vRG3altN4hSYeeaMXFAgcz34Ba1Hr8bqbG62Zq1juTT?= =?us-ascii?q?xWoFd2BXQpxnhj0WNi+mCEFsACFJCZ0lfaDx2vZ6?= X-IronPort-AV: E=Sophos;i="5.82,203,1613430000"; d="scan'208";a="502059670" Received: from 173.121.68.85.rev.sfr.net (HELO hadrien) ([85.68.121.173]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Apr 2021 19:02:53 +0200 Date: Wed, 7 Apr 2021 19:02:53 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Jan Kara cc: Amir Goldstein , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kbuild-all@lists.01.org, Denis Efremov Subject: Re: [PATCH] inotify: fix minmax.cocci warnings In-Reply-To: <20210407160546.GA3271@quack2.suse.cz> Message-ID: References: <20210407160546.GA3271@quack2.suse.cz> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. julia