Re: [PATCH] MIPS: Remove unnecessary zero-length struct member

From: Thorsten Blum
Date: Thu Apr 17 2025 - 04:00:31 EST


On 16. Apr 2025, at 04:33, Maciej W. Rozycki wrote:
> On Fri, 11 Apr 2025, Thorsten Blum wrote:
>
>> Remove the zero-length struct member '__last' and use sizeof() to
>> calculate the value for MAX_REG_OFFSET.
>>
>> No functional changes intended.
>
> Have you verified that there's no change except for timestamp data in
> (non-debug) `vmlinux' produced with and w/o the patch applied?
>
> Also this is broken anyway: if you use MAX_REG_OFFSET for `offset' passed
> to `regs_get_register', then data past the end of `regs' will be accessed.

Yes, true. It seems like

if (unlikely(offset >= MAX_REG_OFFSET))
return 0;

should do the trick.

The comment also says "If @offset is bigger than MAX_REG_OFFSET", rather
than "is bigger than or equal to".

Happy to add it to v2 or a separate patch, if this is actually correct?!

Thanks,
Thorsten