]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: log: fix gcc warn about truncating NUL terminator while init char arrays
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Thu, 27 Mar 2025 09:16:03 +0000 (10:16 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 27 Mar 2025 10:52:33 +0000 (11:52 +0100)
commit44f98f1747e8b2ef400dafa249b3f70a2844e8fe
treec277949b4c07fe03262b08483c305c07912f3f4b
parent9b53a4a7fb364c492681265b9844848c57fe82c2
BUG/MINOR: log: fix gcc warn about truncating NUL terminator while init char arrays

gcc 15 throws such kind of warnings about initialization of some char arrays:

src/log.c:181:33: error: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (17 chars into 16 available) [-Werror=unterminated-string-initialization]
  181 | const char sess_term_cond[16] = "-LcCsSPRIDKUIIII"; /* normal, Local, CliTo, CliErr, SrvTo, SrvErr, PxErr, Resource, Internal, Down, Killed, Up, -- */
      |                                 ^~~~~~~~~~~~~~~~~~
src/log.c:182:33: error: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (9 chars into 8 available) [-Werror=unterminated-string-initialization]
  182 | const char sess_fin_state[8]  = "-RCHDLQT";     /* cliRequest, srvConnect, srvHeader, Data, Last, Queue, Tarpit */

So, let's make it happy by not giving the sizes of these char arrays
explicitly, thus he can accomodate there NUL terminators.

Reported in GitHub issue #2910.

This should be backported up to 2.6.
src/log.c