]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUILD: ssl: silence build warning on uninitialised counters
authorWilly Tarreau <w@1wt.eu>
Fri, 6 Nov 2020 12:19:18 +0000 (13:19 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 6 Nov 2020 12:22:44 +0000 (13:22 +0100)
commit4299528390ce197a06c0ef1d59a4696fa9c19c30
tree7ab048f11034383e52bed0e7aab4553a5477d2c1
parentf5fe70620c9f9bdda5026e1f8b3673fe83257a7c
BUILD: ssl: silence build warning on uninitialised counters

Since commit d0447a7c3 ("MINOR: ssl: add counters for ssl sessions"),
gcc 9+ complains about this:

  CC      src/ssl_sock.o
src/ssl_sock.c: In function 'ssl_sock_io_cb':
src/ssl_sock.c:5416:3: warning: 'counters_px' may be used uninitialized in this function [-Wmaybe-uninitialized]
 5416 |   ++counters_px->reused_sess;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/ssl_sock.c:5133:23: note: 'counters_px' was declared here
 5133 |  struct ssl_counters *counters, *counters_px;
      |                                  ^~~~~~~~~~~

Either a listener or a server are expected there, so ther counters are
always initialized and the compiler cannot know this. Let's preset
them and test before updating the counter, we're not in a hot path
here.

No backport is needed.
src/ssl_sock.c