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)
committerAurelien DARRAGON <adarragon@haproxy.com>
Tue, 15 Apr 2025 16:08:15 +0000 (18:08 +0200)
commitd77be2405b6cd5d0cc6c29953cf43315967f02d2
treec611717203ef0daeef0eb1c66a0363e26fadf88c
parentebeece75c2e138e7c7c111ee7f66a65e79d32ef3
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.

(cherry picked from commit 44f98f1747e8b2ef400dafa249b3f70a2844e8fe)
Signed-off-by: Aurelien DARRAGON <adarragon@haproxy.com>
src/log.c