linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] inotify: fix minmax.cocci warnings
@ 2021-04-06 20:49 Julia Lawall
  2021-04-07 16:05 ` Jan Kara
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2021-04-06 20:49 UTC (permalink / raw)
  To: Jan Kara, Amir Goldstein
  Cc: linux-fsdevel, linux-kernel, kbuild-all, Denis Efremov

From: kernel test robot <lkp@intel.com>

Opportunity for min().

Generated by: scripts/coccinelle/misc/minmax.cocci

Fixes: 8636e3295ce3 ("coccinelle: misc: add minmax script")
CC: Denis Efremov <efremov@linux.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux.git for-5.12
head:   cbc8ed0b4f7eeb782c153ec88d6d20bc0f0ca3a7
commit: 8636e3295ce33515c50ef728f0ff3800d97f9f44 [1/4] coccinelle: misc: add minmax script
:::::: branch date: 2 days ago
:::::: commit date: 2 weeks ago

 inotify_user.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- 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);
 }

 static struct inotify_inode_mark *inotify_idr_find_locked(struct fsnotify_group *group,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] inotify: fix minmax.cocci warnings
  2021-04-06 20:49 [PATCH] inotify: fix minmax.cocci warnings Julia Lawall
@ 2021-04-07 16:05 ` Jan Kara
  2021-04-07 17:02   ` Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kara @ 2021-04-07 16:05 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Jan Kara, Amir Goldstein, linux-fsdevel, linux-kernel,
	kbuild-all, Denis Efremov

On Tue 06-04-21 22:49:26, Julia Lawall wrote:
> From: kernel test robot <lkp@intel.com>
> 
> Opportunity for min().
> 
> Generated by: scripts/coccinelle/misc/minmax.cocci
> 
> Fixes: 8636e3295ce3 ("coccinelle: misc: add minmax script")
> CC: Denis Efremov <efremov@linux.com>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
...
> --- 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...

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] inotify: fix minmax.cocci warnings
  2021-04-07 16:05 ` Jan Kara
@ 2021-04-07 17:02   ` Julia Lawall
  2021-04-08  6:22     ` Denis Efremov
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2021-04-07 17:02 UTC (permalink / raw)
  To: Jan Kara
  Cc: Amir Goldstein, linux-fsdevel, linux-kernel, kbuild-all, Denis Efremov



On Wed, 7 Apr 2021, Jan Kara wrote:

> On Tue 06-04-21 22:49:26, Julia Lawall wrote:
> > From: kernel test robot <lkp@intel.com>
> >
> > Opportunity for min().
> >
> > Generated by: scripts/coccinelle/misc/minmax.cocci
> >
> > Fixes: 8636e3295ce3 ("coccinelle: misc: add minmax script")
> > CC: Denis Efremov <efremov@linux.com>
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
> ...
> > --- 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] inotify: fix minmax.cocci warnings
  2021-04-07 17:02   ` Julia Lawall
@ 2021-04-08  6:22     ` Denis Efremov
  0 siblings, 0 replies; 4+ messages in thread
From: Denis Efremov @ 2021-04-08  6:22 UTC (permalink / raw)
  To: Julia Lawall, Jan Kara
  Cc: Amir Goldstein, linux-fsdevel, linux-kernel, kbuild-all



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 <lkp@intel.com>
>>>
>>> Opportunity for min().
>>>
>>> Generated by: scripts/coccinelle/misc/minmax.cocci
>>>
>>> Fixes: 8636e3295ce3 ("coccinelle: misc: add minmax script")
>>> CC: Denis Efremov <efremov@linux.com>
>>> Reported-by: kernel test robot <lkp@intel.com>
>>> Signed-off-by: kernel test robot <lkp@intel.com>
>>> Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
>> ...
>>> --- 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-08  6:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-06 20:49 [PATCH] inotify: fix minmax.cocci warnings Julia Lawall
2021-04-07 16:05 ` Jan Kara
2021-04-07 17:02   ` Julia Lawall
2021-04-08  6:22     ` Denis Efremov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).