]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUILD: quic: remove GCC undefined error in qc_release_lost_pkts()
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 30 Jan 2025 15:24:10 +0000 (16:24 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 31 Jan 2025 14:34:30 +0000 (15:34 +0100)
commit4ad2accfee59acad4fd5bc0e2b15b4aa23bd57a1
tree3a923bcfbf4b914d0ccbd59898f61b28dc3460d4
parentc17e02923256fef61f74b986045b7eb8d1e126c7
BUILD: quic: remove GCC undefined error in qc_release_lost_pkts()

Every once in a while, GCC reports issues with qc_release_lost_pkts()
function. It seems that its static analysis is foiled by the code
structuring. The latest warning reports the following issue :

  CC      src/quic_loss.o
src/quic_loss.c: In function ‘qc_release_lost_pkts’:
src/quic_loss.c:313:58: error: potential null pointer dereference [-Werror=null-dereference]
  313 |                         unsigned int period = newest_lost->time_sent_ms - oldest_lost->time_sent_ms;
      |                                               ~~~~~~~~~~~^~~~~~~~~~~~~~

To fix definitely this, change slightly the code. <oldest_lost> and
<newest_lost> are now initialized on the first list entry outside of the
loop. This is enough to guarantee to GCC that they cannot be NULL for
the remainder of the function.
src/quic_loss.c