Re: [PATCH v2][next] bpf: Avoid thousands of -Wflex-array-members-not-at-end warnings
From: Kees Cook
Date: Sun Apr 05 2026 - 23:27:49 EST
On Sun, Apr 05, 2026 at 07:44:51PM -0700, Alexei Starovoitov wrote:
> On Mon, Mar 30, 2026 at 3:39 PM Gustavo A. R. Silva
> <gustavoars@xxxxxxxxxx> wrote:
> >
> > Apparently, struct bpf_empty_prog_array exists entirely to populate a
> > single element of "items" in a global variable. "null_prog" is only
> > used during the initializer.
> >
> > None of this is needed; globals will be correctly sized with an array
> > initializer of a flexible-array member.
> >
> > So, remove struct bpf_empty_prog_array and adjust the rest of the code,
> > accordingly.
> >
> > With these changes, fix the following warnings:
> >
> > 7659 ./include/linux/bpf.h:2369:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> >
> > Signed-off-by: Gustavo A. R. Silva <gustavoars@xxxxxxxxxx>
> > ---
> > Changes in v2:
> > - Remove struct bpf_empty_prog_array. (Kees)
>
> Kees,
>
> It really bothers me that you ask people to clean up
> warnings for the sake of removing warnings.
It's not for the sake of warnings; this is to remove the ambiguously
sized objects (i.e. structs that the compiler cannot reason about the
size of).
--
Kees Cook