On Tue, Jan 06, 2026 at 08:41:35AM -0700, Dave Jiang wrote:
> 
> 
> On 1/5/26 8:52 PM, Alison Schofield wrote:
> > Placing nd_cmd_pkg anywhere but at the end of a structure can lead to
> > undefined behavior for the flex array member. Move nd_cmd_pkg to the
> > end of all affected structures.
> > 
> > Reproduce using Clang:
> > ~/git/ndctl$ rm -rf build
> > ~/git/ndctl$ CC=clang meson setup build
> > ~/git/ndctl$ meson compile -C build
> > 
> > ../ndctl/lib/hpe1.h:324:20: warning: field 'gen' with variable sized type 
> > 'struct nd_cmd_pkg' not at the end of a struct or class is a GNU extension 
> > [-Wgnu-variable-sized-type-not-at-end]
> > 
> > Reported-by: Cristian Rodriguez <[email protected]>
> > Closes: https://github.com/pmem/ndctl/issues/296
> > Signed-off-by: Alison Schofield <[email protected]>
> 
> Reviewed-by: Dave Jiang <[email protected]>
> 
> I wonder if a comment needs to be inserted to the definition of 'nd_cmd_pkg' 
> to warn users that the struct should never be placed anywhere besides the end 
> when used as a member of another struct.

Yes, a comment will be useful.
I'll add it upon applying if I don't rev for anything else.
Thanks for the review!


Reply via email to