Re: [PATCH] net/intel: Replace manual array size calculation with ARRAY_SIZE

Jakub Raczynski
2026-04-22T08:32:20Z

[-- Attachment #1: Type: text/plain, Size: 898 bytes --]

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

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]