]> Git Repo - linux.git/commit
net: bareudp: avoid uninitialized variable warning
authorArnd Bergmann <[email protected]>
Tue, 5 May 2020 17:22:14 +0000 (19:22 +0200)
committerDavid S. Miller <[email protected]>
Fri, 8 May 2020 00:28:18 +0000 (17:28 -0700)
commitee2875566868687a95b8ec23913c0d6bce220efd
treeae7cb51f3a8b189f1d969c6c1102931eeedcc781
parent8aef199481df0d2b6d110b8be321d5358511fe01
net: bareudp: avoid uninitialized variable warning

clang points out that building without IPv6 would lead to returning
an uninitialized variable if a packet with family!=AF_INET is
passed into bareudp_udp_encap_recv():

drivers/net/bareudp.c:139:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
        if (family == AF_INET)
            ^~~~~~~~~~~~~~~~~
drivers/net/bareudp.c:146:15: note: uninitialized use occurs here
        if (unlikely(err)) {
                     ^~~
include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
 # define unlikely(x)    __builtin_expect(!!(x), 0)
                                            ^
drivers/net/bareudp.c:139:2: note: remove the 'if' if its condition is always true
        if (family == AF_INET)
        ^~~~~~~~~~~~~~~~~~~~~~

This cannot happen in practice, so change the condition in a way that
gcc sees the IPv4 case as unconditionally true here.
For consistency, change all the similar constructs in this file the
same way, using "if(IS_ENABLED())" instead of #if IS_ENABLED()".

Fixes: 571912c69f0e ("net: UDP tunnel encapsulation module for tunnelling different protocols like MPLS, IP, NSH etc.")
Signed-off-by: Arnd Bergmann <[email protected]>
Reviewed-by: Nathan Chancellor <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
drivers/net/bareudp.c
include/net/udp_tunnel.h
This page took 0.05741 seconds and 4 git commands to generate.