Skip to content

Commit a8df1f5

Browse files
arndbkernel-patches-bot
authored andcommitted
bpf: fix incorrect initialization of bpf_ctx_convert_map
gcc -Wextra points out that a field may get overridden in some configurations such as x86 allmodconfig, when the next index after the one that has been assigned last already had a value, in this case for index BPF_PROG_TYPE_SK_LOOKUP, which comes after BPF_PROG_TYPE_LSM in the list: kernel/bpf/btf.c:4225:2: warning: initialized field overwritten [-Woverride-init] 4225 | 0, /* avoid empty array */ | ^ kernel/bpf/btf.c:4225:2: note: (near initialization for 'bpf_ctx_convert_map[30]') Move the zero-initializer first instead. This avoids the warning since nothing else uses index 0, and the last element does not have to be zero. Fixes: e9ddbb7 ("bpf: Introduce SK_LOOKUP program type with a dedicated attach point") Fixes: 4c80c7b ("bpf: Fix build in minimal configurations, again") Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 96511a8 commit a8df1f5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/bpf/btf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4218,11 +4218,11 @@ enum {
42184218
__ctx_convert_unused, /* to avoid empty enum in extreme .config */
42194219
};
42204220
static u8 bpf_ctx_convert_map[] = {
4221+
[0] = 0, /* avoid empty array */
42214222
#define BPF_PROG_TYPE(_id, _name, prog_ctx_type, kern_ctx_type) \
42224223
[_id] = __ctx_convert##_id,
42234224
#include <linux/bpf_types.h>
42244225
#undef BPF_PROG_TYPE
4225-
0, /* avoid empty array */
42264226
};
42274227
#undef BPF_MAP_TYPE
42284228
#undef BPF_LINK_TYPE

0 commit comments

Comments
 (0)