diff options
| author | Gustavo A. R. Silva <gustavoars@kernel.org> | 2026-03-30 16:38:18 -0600 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2026-04-06 18:37:52 -0700 |
| commit | 18474aed5d0d382f8057ceed7811a735134d28b9 (patch) | |
| tree | f5a0f7f4b62ed80d12c3ce34bd5ce5d3f0a4845a /kernel | |
| parent | 42e33c9af49c5199504bbfb16f65756a90fe90bf (diff) | |
| download | linux-18474aed5d0d382f8057ceed7811a735134d28b9.tar.gz linux-18474aed5d0d382f8057ceed7811a735134d28b9.zip | |
bpf: Avoid -Wflex-array-members-not-at-end warnings
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:
./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@kernel.org>
Acked-by: Mykyta Yatsenko <yatsenko@meta.com>
Link: https://lore.kernel.org/r/acr7Whmn0br3xeBP@kspp
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/bpf/core.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 57811c07aa84..ee632f41bd83 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -2614,8 +2614,10 @@ static struct bpf_prog_dummy { }, }; -struct bpf_empty_prog_array bpf_empty_prog_array = { - .null_prog = NULL, +struct bpf_prog_array bpf_empty_prog_array = { + .items = { + { .prog = NULL }, + }, }; EXPORT_SYMBOL(bpf_empty_prog_array); @@ -2626,14 +2628,14 @@ struct bpf_prog_array *bpf_prog_array_alloc(u32 prog_cnt, gfp_t flags) if (prog_cnt) p = kzalloc_flex(*p, items, prog_cnt + 1, flags); else - p = &bpf_empty_prog_array.hdr; + p = &bpf_empty_prog_array; return p; } void bpf_prog_array_free(struct bpf_prog_array *progs) { - if (!progs || progs == &bpf_empty_prog_array.hdr) + if (!progs || progs == &bpf_empty_prog_array) return; kfree_rcu(progs, rcu); } @@ -2654,7 +2656,7 @@ static void __bpf_prog_array_free_sleepable_cb(struct rcu_head *rcu) void bpf_prog_array_free_sleepable(struct bpf_prog_array *progs) { - if (!progs || progs == &bpf_empty_prog_array.hdr) + if (!progs || progs == &bpf_empty_prog_array) return; call_rcu_tasks_trace(&progs->rcu, __bpf_prog_array_free_sleepable_cb); } |
