]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: compiler: add __nonstring macro
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Mon, 31 Mar 2025 09:47:45 +0000 (11:47 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 31 Mar 2025 11:50:28 +0000 (13:50 +0200)
commitb3038614696fee43b6eaa826f47f273a8619690d
tree6e2192e43b9ab4d49a70262124d5a69940baf3ee
parent415d44606549ec0e1c566a4da3b16b65d5857598
MINOR: compiler: add __nonstring macro

GCC 15 throws the following warning on fixed-size char arrays if they do not
contain terminated NUL:

src/tools.c:2041:25: error: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (17 chars into 16 available) [-Werror=unterminated-string-initialization]
 2041 | const char hextab[16] = "0123456789ABCDEF";

We are using a couple of such definitions for some constants. Converting them
to flexible arrays, like: hextab[] = "0123456789ABCDEF" may have consequences,
as enlarged arrays won't fit anymore where they were possibly located due to
the memory alignement constraints.

GCC adds 'nonstring' variable attribute for such char arrays, but clang and
other compilers don't have it. Let's wrap 'nonstring' with our
__nonstring macro, which will test if the compiler supports this attribute.

This fixes the issue #2910.
include/haproxy/compiler.h
src/tools.c