Re: [PATCH v12 01/11] bitops: Introduce the for_each_set_clump8 macro

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

 



On Tue, Mar 26, 2019 at 02:03:19PM +0100, Lukas Wunner wrote:
> On Tue, Mar 26, 2019 at 07:08:18PM +0900, William Breathitt Gray wrote:
> > On Tue, Mar 26, 2019 at 10:43:45AM +0100, Lukas Wunner wrote:

> > In this case, bitmap_get_value8 could be simplified to something like
> > this:
> > 
> >         index = BIT_WORD(start);
> >         offset = start % BITS_PER_LONG;
> >         return (bitmap[index] >> offset) & 0xFF;
> 

> Hm, shouldn't that be "offset = round_down(start, 8)" ?

No, the index points to the word, the offset points to the offset inside word.

> (I prefer the multi-line version FWIW.)

+1 here.

> > Would it be better to define bitmap_get_value8 as a macro then?
> 
> Or a static inline.

Please, no macro. It disadvantages in terms of type checking. 

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux