Re: [PATCH] sparc: Replace one-element array with flexible array member

From: Thorsten Blum
Date: Mon Nov 11 2024 - 15:46:23 EST


On 11. Nov 2024, at 21:20, Gustavo A. R. Silva wrote:
> On 11/11/24 14:01, Thorsten Blum wrote:
>> Replace the deprecated one-element array with a modern flexible array
>> member in the struct hvtramp_descr.
>> Additionally, 15 unnecessary bytes are allocated for hdesc, but instead
>
> 15? unnecessary?

hvtramp_mapping is 16 bytes and the size is calculated as follows:

(16 * num_kernel_image_mappings - 1)

which is 15 bytes too many for any number of mappings because hdesc
includes the first map. It probably should have been:

16 * (num_kernel_image_mappings - 1)

unless I'm missing something.

> It seems this struct is a candidate for `__counted_by()`

Yes, but sparc doesn't seem to support it?

> Now the code is broken because it's allocating `num_kernel_image_mappings - 1`
> elements instead of `num_kernel_image_mappings`.

Ah sorry, missed that and will fix in v2 shortly.

Thanks,
Thorsten