# Re: \[PATCH v2 net-next 2/6\] bitmap: add a couple more helpers to work with arrays of u32s

- From: Andy Shevchenko \<andriy.shevchenko@linux.intel.com\>
- Date: 2022-10-20 13:21:14 
- List: netdev
- Page: https://ratatoskr.run/netdev/2022/10/1973752
- Thread: https://ratatoskr.run/netdev/2022/10/1969944/t.md

```text
On Wed, Oct 19, 2022 at 05:21:01PM -0700, Yury Norov wrote:
> On Tue, Oct 18, 2022 at 04:00:23PM +0200, Alexander Lobakin wrote:

...

> > +static inline size_t bitmap_arr32_size(size_t nbits)
> > +{
> > +	return array_size(BITS_TO_U32(nbits), sizeof(u32));
> 
> To me this looks simpler: round_up(nbits, 32) / BITS_PER_BYTE.
> Can you check which generates better code?

It's not only about better code, but also about overflow protection, which your
proposal is missing.

> > +}

-- 
With Best Regards,
Andy Shevchenko


```
