lkml.org 
[lkml]   [2019]   [Nov]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [GIT pull] core/urgent for v5.4-rc7
From
Date
On Mon, 2019-11-11 at 09:12 -0800, Linus Torvalds wrote:
> On Sun, Nov 10, 2019 at 5:50 PM Joe Perches <joe@perches.com> wrote:
> > The !! logical usage is not particularly common in the kernel.
> > There seems to be only a couple/few dozen.
>
> Your grep pattern is for the explicitly silly "turn a boolean to a
> boolean". That should certainly be rare.
>
> But I meant it in a more general way - there's a lot of common use of
> "!!" for "turn this expression into a boolean". A trivial grep for
> that (didn't check how correct it was - there might be comments that
> are very excited too) implies that we have a fair amount of this
> pattern:
>
> $ git grep '[^!]!![^!]' -- '*.[ch]' | wc -l
> 7007

Likely the majority of those are bit comparison coercions to 0/1 like

int val = !!(A & B)

> so the '!!' pattern itself isn't rare.

And likely these !! patterns are preferred to (A & B) != 0

I don't care much either way as either form, unlike !!(A == B),
is not redundant.


\
 
 \ /
  Last update: 2019-11-12 02:38    [W:0.054 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site