Messages in this thread | | | From | Andy Shevchenko <> | Date | Wed, 24 Aug 2022 20:45:01 +0300 | Subject | Re: [PATCH v2 1/3] lib/find_bit: introduce FIND_FIRST_BIT() macro |
| |
On Wed, Aug 24, 2022 at 4:19 PM Yury Norov <yury.norov@gmail.com> wrote: > On Wed, Aug 24, 2022 at 12:10:02PM +0300, Andy Shevchenko wrote: > > On Wed, Aug 24, 2022 at 4:51 AM Yury Norov <yury.norov@gmail.com> wrote:
...
> > > +#define FIND_FIRST_BIT(EXPRESSION, size) \ > > > +({ \ > > > + unsigned long idx, val, sz = (size); \ > > > + \ > > > + for (idx = 0; idx * BITS_PER_LONG < sz; idx++) { \ > > > > I think we can do slightly better: > > > > for (unsigned long idx = 0; idx < sz; idx += BITS_PER_LONG) { > > unsigned long val; > > This will blow up the EXPRESSION. We can mitigate it on user side:
I'm not sure I understand how EXPRESSION is involved in all this. What I proposed is to replace the for-loop one-by-one to one-by-BITS_PER_LONG. But okay, I have re-read the above patch and now I see what you are doing, basically you use internal variables of the macro in the EXPRESSION. Hmm...
-- With Best Regards, Andy Shevchenko
| |