From d9c2fd793fe1e8c8fbfd7aec9af3482fa5f0dacc Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Tue, 18 Mar 2025 05:09:31 +0000 Subject: Tag various character arrays with NXT_NONSTRING MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Unit we have a number of character arrays which are intentionally not NUL terminated. With GCC 15 this static const char hex[16] = "0123456789ABCDEF"; will trigger a warning like $ gcc -Wextra -c nonstring.c nonstring.c: In function ‘hexit’: nonstring.c:9:37: warning: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (17 chars into 16 available) [-Wunterminated-string-initialization] 9 | static const char hex[16] = "0123456789ABCDEF"; | ^~~~~~~~~~~~~~~~~~ By adding NXT_NONSTRING like static const char hex[16] NXT_NONSTRING = "0123456789ABCDEF"; we no longer get the warning. Cc: Alejandro Colomar Co-authored-by: Alejandro Colomar Signed-off-by: Alejandro Colomar Signed-off-by: Andrew Clayton --- src/nxt_string.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nxt_string.c') diff --git a/src/nxt_string.c b/src/nxt_string.c index 1ca595a1..a23ee058 100644 --- a/src/nxt_string.c +++ b/src/nxt_string.c @@ -598,7 +598,7 @@ nxt_encode_uri(u_char *dst, u_char *src, size_t length) u_char *end; nxt_uint_t n; - static const u_char hex[16] = "0123456789ABCDEF"; + static const u_char hex[16] NXT_NONSTRING = "0123456789ABCDEF"; end = src + length; @@ -644,7 +644,7 @@ nxt_encode_complex_uri(u_char *dst, u_char *src, size_t length) u_char *reserved, *end, ch; nxt_uint_t n; - static const u_char hex[16] = "0123456789ABCDEF"; + static const u_char hex[16] NXT_NONSTRING = "0123456789ABCDEF"; reserved = (u_char *) "?#\0"; -- cgit