[PATCH] bpf: shut up -Woverride-init warning
From: Arnd Bergmann
Date: Wed Jun 08 2016 - 04:46:40 EST
gcc -Woverride-init provides useful warnings about bugs in some drivers,
but it warns about an intentional duplicate inialization in the bpf
code:
kernel/bpf/core.c: In function '__bpf_prog_run':
kernel/bpf/core.c:476:26: error: initialized field overwritten [-Werror=override-init]
kernel/bpf/core.c:476:26: note: (near initialization for 'jumptable[12]')
kernel/bpf/core.c:477:26: error: initialized field overwritten [-Werror=override-init]
kernel/bpf/core.c:477:26: note: (near initialization for 'jumptable[4]')
kernel/bpf/core.c:478:26: error: initialized field overwritten [-Werror=override-init]
kernel/bpf/core.c:478:26: note: (near initialization for 'jumptable[28]')
kernel/bpf/core.c:479:26: error: initialized field overwritten [-Werror=override-init]
kernel/bpf/core.c:479:26: note: (near initialization for 'jumptable[20]')
kernel/bpf/core.c:480:26: error: initialized field overwritten [-Werror=override-init]
kernel/bpf/core.c:480:26: note: (near initialization for 'jumptable[92]')
kernel/bpf/core.c:481:26: error: initialized field overwritten [-Werror=override-init]
This uses a #pragma to shut up that warning, as a preparation for enabling
the warning by default in the future.
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 503d4211988a..8944778d9c13 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -547,6 +547,7 @@ EXPORT_SYMBOL_GPL(__bpf_call_base);
*
* Decode and execute eBPF instructions.
*/
+#pragma GCC diagnostic ignored "-Woverride-init"
static unsigned int __bpf_prog_run(void *ctx, const struct bpf_insn *insn)
{
u64 stack[MAX_BPF_STACK / sizeof(u64)];
@@ -1003,6 +1004,7 @@ static unsigned int __bpf_prog_run(void *ctx, const struct bpf_insn *insn)
WARN_RATELIMIT(1, "unknown opcode %02x\n", insn->code);
return 0;
}
+#pragma GCC diagnostic warning "-Woverride-init"
STACK_FRAME_NON_STANDARD(__bpf_prog_run); /* jump table */
bool bpf_prog_array_compatible(struct bpf_array *array,