[RFC] Tag various character arrays with NGX_NONSTRING.

In nginx we have a number of character arrays which are intentionally
not NUL terminated which GCC 15 will now warn about e.g.

  src/http/v2/ngx_http_v2_filter_module.c:118:36: error: initializer-string for array of ‘unsigned char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (6 chars into 5 available) [-Werror=unterminated-string-initialization]
    118 |     static const u_char nginx[5] = "\x84\xaa\x63\x55\xe7";
        |                                    ^~~~~~~~~~~~~~~~~~~~~~

Fix this by tagging the array with NGX_NONSTRING which will quell this
warning.

Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
This commit is contained in:
Andrew Clayton 2025-04-15 23:58:29 +01:00
parent dfc019fa43
commit 032b688102

View File

@ -115,9 +115,9 @@ ngx_http_v2_header_filter(ngx_http_request_t *r)
ngx_http_core_srv_conf_t *cscf;
u_char addr[NGX_SOCKADDR_STRLEN];
static const u_char nginx[5] = "\x84\xaa\x63\x55\xe7";
static const u_char nginx[5] NGX_NONSTRING = "\x84\xaa\x63\x55\xe7";
#if (NGX_HTTP_GZIP)
static const u_char accept_encoding[12] =
static const u_char accept_encoding[12] NGX_NONSTRING =
"\x8b\x84\x84\x2d\x69\x5b\x05\x44\x3c\x86\xaa\x6f";
#endif