nfp: bpf: improve handling for disabled BPF syscall
authorArnd Bergmann <arnd@arndb.de>
Fri, 23 Sep 2016 20:23:59 +0000 (22:23 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 26 Sep 2016 06:26:29 +0000 (02:26 -0400)
commitb47c62c5de2bc43a26bcaca8d7a93bf9dee66ffe
tree2f55cb728bfb2cae2fd2143cddb3ccbbc5be7141
parente2072600a24161b7ddcfb26814f69f5fbc8ef85a
nfp: bpf: improve handling for disabled BPF syscall

I stumbled over a new warning during randconfig testing,
with CONFIG_BPF_SYSCALL disabled:

drivers/net/ethernet/netronome/nfp/nfp_net_offload.c: In function 'nfp_net_bpf_offload':
drivers/net/ethernet/netronome/nfp/nfp_net_offload.c:263:3: error: '*((void *)&res+4)' may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/net/ethernet/netronome/nfp/nfp_net_offload.c:263:3: error: 'res.n_instr' may be used uninitialized in this function [-Werror=maybe-uninitialized]

As far as I can tell, this is a false positive caused by the compiler
getting confused about a function that is partially inlined, but it's
easy to avoid while improving the code:

The nfp_bpf_jit() stub helper for that configuration is unusual as it
is defined in a header file but not marked 'static inline'. By moving
the compile-time check into the caller using the IS_ENABLED() macro,
we can remove that stub and simplify the nfp_net_bpf_offload_prepare()
function enough to unconfuse the compiler.

Fixes: 7533fdc0f77f ("nfp: bpf: add hardware bpf offload")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfp_bpf.h
drivers/net/ethernet/netronome/nfp/nfp_net_offload.c