bpf: fix constraint in test_tcpbpf_kern.c
authorJose E. Marchesi <jose.marchesi@oracle.com>
Tue, 23 Jan 2024 20:56:24 +0000 (21:56 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 23 Jan 2024 23:53:04 +0000 (15:53 -0800)
GCC emits a warning:

  progs/test_tcpbpf_kern.c:60:9: error: ‘op’ is used uninitialized [-Werror=uninitialized]

when an uninialized op is used with a "+r" constraint.  The + modifier
means a read-write operand, but that operand in the selftest is just
written to.

This patch changes the selftest to use a "=r" constraint.  This
pacifies GCC.

Tested in bpf-next master.
No regressions.

Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
Cc: Yonghong Song <yhs@meta.com>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: david.faust@oracle.com
Cc: cupertino.miranda@oracle.com
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20240123205624.14746-1-jose.marchesi@oracle.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c

index cf7ed8c..a3f3f43 100644 (file)
@@ -59,7 +59,7 @@ int bpf_testcb(struct bpf_sock_ops *skops)
 
        asm volatile (
                "%[op] = *(u32 *)(%[skops] +96)"
-               : [op] "+r"(op)
+               : [op] "=r"(op)
                : [skops] "r"(skops)
                :);