Re: [PATCH v2][next] bpf: Avoid thousands of -Wflex-array-members-not-at-end warnings

From: Gustavo A. R. Silva

Date: Mon Apr 06 2026 - 20:23:38 EST




On 4/6/26 17:24, Alexei Starovoitov wrote:
On Sun, Apr 5, 2026 at 8:27 PM Kees Cook <kees@xxxxxxxxxx> wrote:

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).

I read through the AI debug logs. What steps it took to reason that
the fix is correct, and it convinced me that I'm wrong.

What prompted you to think this was a "ticking time bomb"?

Applied.

Thanks

-Gustavo