Messages in this thread | | | Subject | Re: [GIT pull] core/urgent for v5.4-rc7 | From | Joe Perches <> | Date | Mon, 11 Nov 2019 17:37:26 -0800 |
| |
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.
| |