Re: is there a "single_bit_set" macro somewhere?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 23 Apr 2009, Robert P. J. Day wrote:

> On Thu, 23 Apr 2009, Julia Lawall wrote:
> 
> > I found 8 occurrences with the following Coccinelle semantic match:
> >
> > @@ expression n; @@
> >
> > * (n & (n-1)) == 0
> >
> >
> > The most unpleasant was:
> >
> > (!(((fp)->ipend & ~0x30) & (((fp)->ipend & ~0x30) - 1)))
> >
> > in the file arch/blackfin/kernel/traps.c.
> >
> > At least some of them seemed to have comments nearby that suggested
> > that searching for a single 1-bit was indeed the goal.  I haven't
> > looked at all of them, though.
> 
>   behold, the power of shell and REs, which searches for four
> variations of that test:

Actually, it seems that it was specifying == 0 that was not really 
necessary.  Perhaps the possibility of parentheses is useful too.

With the following semantic patch, I find 93 occurrences.

@@ expression n; @@

* (n) & ((n)-1)

That could indeed be worth doing something about, if they are indeed all 
representing a check for a single bit.

julia
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux