[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen/public: fix flexible array definitions



On 25/07/2023 2:55 pm, Juergen Gross wrote:
> Flexible arrays in public headers can be problematic with some
> compilers.
>
> Replace them with arr[XEN_FLEX_ARRAY_DIM] in order to avoid compilation
> errors.
>
> This includes arrays defined as "arr[1]", as seen with a recent Linux
> kernel [1].
>
> [1]: https://bugzilla.kernel.org/show_bug.cgi?id=217693
>
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>

I know this is a change in the public headers, and I know it will cause
changes in the behaviour of sizeof() against these, but

1) We expect people to copy these files, so the change here isn't
breaking others, and
2) The use of sizeof() on these structs is buggy in the first place, and
3) The use of sizeof() with these structs is unlikely because they're
variadic
4) It really genuinely is UB as reported by toolchains

It may not be great, but it's the least bad of a lot of bad options.

This definitely needs a note in CHANGELOG.  Subject to something
suitable there, Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

~Andrew



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.