This is a false positive, fixed by explicitly initializing
variable to NULL. Variable is always initialized during the for loop
above, which is guaranteed to run since queues >= 1.
This is correctly detected for normal builds, but not for gcov builds.
In function ‘af_xdp_read_poll’,
inlined from ‘net_init_af_xdp’ at ../net/af-xdp.c:546:5:
../net/af-xdp.c:78:10: error: ‘s’ may be used uninitialized
[-Werror=maybe-uninitialized]
78 | if (s->read_poll != enable) {
| ~^~~~~~~~~~~
../net/af-xdp.c: In function ‘net_init_af_xdp’:
../net/af-xdp.c:461:17: note: ‘s’ was declared here
461 | AFXDPState *s;
|
Signed-off-by: Pierrick Bouvier <[email protected]>
---
net/af-xdp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/af-xdp.c b/net/af-xdp.c
index 1ffd6363a8c..72d75748c6d 100644
--- a/net/af-xdp.c
+++ b/net/af-xdp.c
@@ -458,7 +458,7 @@ int net_init_af_xdp(const Netdev *netdev,
g_autofree int *sock_fds = NULL;
int i, queues;
Error *err = NULL;
- AFXDPState *s;
+ AFXDPState *s = NULL;
bool inhibit;
ifindex = if_nametoindex(opts->ifname);
--
2.43.0