git: c17271f92431 - stable/15 - crypto: avoid warnings about too-long initializer strings

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Fri, 02 Jan 2026 20:51:53 UTC
The branch stable/15 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=c17271f9243159079f6f54fbf13a025e979ee79c

commit c17271f9243159079f6f54fbf13a025e979ee79c
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-12-30 12:46:20 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2026-01-02 20:41:35 +0000

    crypto: avoid warnings about too-long initializer strings
    
    Mark `sigma` and `tau` as `__non_string`, to avoid warnings from clang
    21 similar to:
    
        sys/crypto/chacha20/chacha.c:53:31: error: initializer-string for character array is too long, array size is 16 but initializer has size 17 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
           53 | static const char sigma[16] = "expand 32-byte k";
              |                               ^~~~~~~~~~~~~~~~~~
        sys/crypto/chacha20/chacha.c:54:29: error: initializer-string for character array is too long, array size is 16 but initializer has size 17 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
           54 | static const char tau[16] = "expand 16-byte k";
              |                             ^~~~~~~~~~~~~~~~~~
    
    MFC after:      3 days
    Reviewed by:    markj
    Differential Revision: https://reviews.freebsd.org/D54364
    
    (cherry picked from commit 710ec409dffed3306ced253bba85dbdc7758510b)
---
 sys/crypto/chacha20/chacha.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/crypto/chacha20/chacha.c b/sys/crypto/chacha20/chacha.c
index 52f7e18c651c..b5f51bd10cc9 100644
--- a/sys/crypto/chacha20/chacha.c
+++ b/sys/crypto/chacha20/chacha.c
@@ -50,8 +50,8 @@ typedef struct chacha_ctx chacha_ctx;
   a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
   c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
 
-static const char sigma[16] = "expand 32-byte k";
-static const char tau[16] = "expand 16-byte k";
+static const char sigma[16] __nonstring = "expand 32-byte k";
+static const char tau[16] __nonstring = "expand 16-byte k";
 
 LOCAL void
 chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits)