Skip to content

Commit

Permalink
bpf: suppress -Wcast-function-type warning
Browse files Browse the repository at this point in the history
Building with -Wextra shows lots of warnings in the bpf
code such as

kernel/bpf/verifier.c: In function ‘jit_subprogs’:
include/linux/filter.h:345:4: warning: cast between incompatible function types from ‘unsigned int (*)(const void *, const struct bpf_insn *)’ to ‘u64 (*)(u64,  u64,  u64,  u64,  u64)’ {aka ‘long long unsigned int (*)(long long unsigned int,  long long unsigned int,  long long unsigned int,  long long unsigned int,  long long unsigned int)’} [-Wcast-function-type]
  345 |   ((u64 (*)(u64, u64, u64, u64, u64))(x))
      |    ^
kernel/bpf/verifier.c:10706:16: note: in expansion of macro ‘BPF_CAST_CALL’
10706 |    insn->imm = BPF_CAST_CALL(func[subprog]->bpf_func) -
      |                ^~~~~~~~~~~~~

This appears to be intentional, so change the cast in a way that
suppresses the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
  • Loading branch information
arndb authored and kernel-patches-bot committed Nov 2, 2020
1 parent 44bfa52 commit 85393a1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/linux/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ static inline bool insn_is_zext(const struct bpf_insn *insn)
/* Function call */

#define BPF_CAST_CALL(x) \
((u64 (*)(u64, u64, u64, u64, u64))(x))
((u64 (*)(u64, u64, u64, u64, u64))(uintptr_t)(x))

#define BPF_EMIT_CALL(FUNC) \
((struct bpf_insn) { \
Expand Down

0 comments on commit 85393a1

Please sign in to comment.