Messages in this thread | | | Date | Tue, 19 Jul 2022 00:06:24 +0300 | From | Andy Shevchenko <> | Subject | Re: [PATCH 02/16] lib/bitmap: don't call bitmap_set() with len == 0 |
| |
On Mon, Jul 18, 2022 at 12:28:30PM -0700, Yury Norov wrote: > bitmap_parselist() format allows passing 0-length regions, but because > len == 0 is not covered by small_const_nbits() macro, we have to call > __bitmap_set() and do some prologue calculations just for nothing.
...
> static void bitmap_set_region(const struct region *r, unsigned long *bitmap) > { > - unsigned int start; > + unsigned int start, len; > > - for (start = r->start; start <= r->end; start += r->group_len) > - bitmap_set(bitmap, start, min(r->end - start + 1, r->off)); > + for (start = r->start; start <= r->end; start += r->group_len) { > + len = min(r->end - start + 1, r->off); > + if (len > 0) > + bitmap_set(bitmap, start, len);
Maybe I'm missing something, but how small_const_nbits() can possible be useful here? I mean in which cases the compiler would be able to prove that len is a const with < sizeof(unsigned long) bits?
> + } > }
-- With Best Regards, Andy Shevchenko
| |