[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <52b54aa5-71ec-8363-27e4-24400680e08e@iogearbox.net>
Date: Sat, 2 Mar 2019 01:11:16 +0100
From: Daniel Borkmann <daniel@...earbox.net>
To: Yonghong Song <yhs@...com>, netdev@...r.kernel.org
Cc: Alexei Starovoitov <ast@...com>, kernel-team@...com
Subject: Re: [PATCH bpf-next] samples/bpf: silence compiler warning for
xdpsock_user.c
On 03/01/2019 07:19 AM, Yonghong Song wrote:
> Compiling xdpsock_user.c with 4.8.5, I hit the following
> compilation warning:
> HOSTCC samples/bpf/xdpsock_user.o
> /data/users/yhs/work/net-next/samples/bpf/xdpsock_user.c: In function ‘main’:
> /data/users/yhs/work/net-next/samples/bpf/xdpsock_user.c:449:6: warning: ‘idx_cq’ may be used unini
> tialized in this function [-Wmaybe-uninitialized]
> u32 idx_cq, idx_fq;
> ^
> /data/users/yhs/work/net-next/samples/bpf/xdpsock_user.c:606:7: warning: ‘idx_rx’ may be used unini
> tialized in this function [-Wmaybe-uninitialized]
> u32 idx_rx, idx_tx = 0;
> ^
> /data/users/yhs/work/net-next/samples/bpf/xdpsock_user.c:506:6: warning: ‘idx_rx’ may be used unini
> tialized in this function [-Wmaybe-uninitialized]
> u32 idx_rx, idx_fq = 0;
>
> As an example, the code pattern looks like:
> u32 idx_cq;
> ...
> ret = xsk_ring_prod__reserve(&xsk->umem->fq, rcvd, &idx_fq);
> if (ret) {
> ...
> }
> ... idx_fq ...
> The compiler warns since it does not know whether &idx_fq is assigned
> or not inside the library function xsk_ring_prod__reserve().
>
> Let us assign an initial value 0 to such auto variables to silence
> compiler warning.
>
> Fixes: 248c7f9c0e21 ("samples/bpf: convert xdpsock to use libbpf for AF_XDP access")
> Signed-off-by: Yonghong Song <yhs@...com>
Applied, thanks!
Powered by blists - more mailing lists