]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Prevent a false-positive warning from the compiler
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 1 Mar 2023 10:34:02 +0000 (11:34 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 23 Jan 2024 11:54:12 +0000 (12:54 +0100)
```
In file included from xsk.hh:50,
                 from xsk.cc:23:
In function ‘xdp_desc* xsk_ring_prod__tx_desc(xsk_ring_prod*, __u32)’,
    inlined from ‘void XskSocket::send(std::vector<std::unique_ptr<XskPacket>, std::allocator<std::unique_ptr<XskPacket> > >&)’ at xsk.cc:176:28:
/usr/include/xdp/xsk.h:76:27: warning: ‘idx’ may be used uninitialized [-Wmaybe-uninitialized]
   76 |         return &descs[idx & tx->mask];
      |                       ~~~~^~~~~~~~~~
```

pdns/xsk.cc

index f43d4a3c8555919ef8d9ccb0770d9328949206ff..778d3cf4ae4454ae703b5775bad94c11fe071c65 100644 (file)
@@ -167,7 +167,7 @@ void XskSocket::send(std::vector<XskPacketPtr>& packets)
   if (packetSize == 0) {
     return;
   }
-  uint32_t idx;
+  uint32_t idx{0};
   if (xsk_ring_prod__reserve(&tx, packetSize, &idx) != packets.size()) {
     return;
   }