From: Vincent Bernat Date: Tue, 10 Mar 2026 07:37:08 +0000 (+0100) Subject: client: fix compilation warning about unterminated strings X-Git-Tag: 1.0.21~10 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=747113fa7ed1075139e2b01fbbef7ed934f9abdb;p=thirdparty%2Flldpd.git client: fix compilation warning about unterminated strings With GCC 15, we get: ``` ../../../src/client/json_writer.c: In function ‘json_element_dump’: ../../../src/client/json_writer.c:160:43: warning: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (3 chars into 2 available) [-Wunterminated-string-initialization] 160 | static const char pairs[2][2] = { "{}", "[]" }; | ^~~~ ../../../src/client/json_writer.c:160:49: warning: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (3 chars into 2 available) [-Wunterminated-string-initialization] 160 | static const char pairs[2][2] = { "{}", "[]" }; | ^~~~ ``` This is a false positive as they are not used as strings, but let's accomodate the compiler by using enough space for the NUL terminator. --- diff --git a/src/client/json_writer.c b/src/client/json_writer.c index dc6665ad..b0c616d3 100644 --- a/src/client/json_writer.c +++ b/src/client/json_writer.c @@ -157,7 +157,7 @@ json_string_dump(FILE *fh, const char *s) static void json_element_dump(FILE *fh, struct element *current, int indent) { - static const char pairs[2][2] = { "{}", "[]" }; + static const char pairs[2][3] = { "{}", "[]" }; struct element *el; switch (current->tag) { case STRING: