Re: [PATCH] net/intel: Replace manual array size calculation with ARRAY_SIZE
Jakub Raczynski <[email protected]>
| Newsgroups | org.kernel.vger.kernel-janitors,org.kernel.vger.netdev |
|---|---|
| Message-ID | <aeiHkejLjhRKyj/[email protected]> |
On Tue, Apr 21, 2026 at 05:11:19PM +0300, Dan Carpenter wrote: > On Tue, Apr 21, 2026 at 01:40:29PM +0200, Jakub Raczynski wrote: > > > > - if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])))) > > + if (!((u32)aq_rc < ARRAY_SIZE(aq_to_posix))) > > This still isn't beautiful. There are so many parens. The !(foo < size) > formulation is weird. The cast is unnnecessary. Better to write it as: > > if (aq_rc >= ARRAY_SIZE(aq_to_posix)) > return -ERANGE; > > > return -ERANGE; > > > > return aq_to_posix[aq_rc]; > > regards, > dan carpenter > Alright, will beautify it and resend soon. I can see potential original intention of not comparing unsigned from sizeof with int, maybe that was original compiler configuration to include that warning. But at this variable range it is irrelevant and it is probably most disabled warning ever. regards Jakub Raczynski