The branch main has been updated by dim:

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

commit e6546807f4c1a8a6a6fa53fceab7b8c80e3ed802
Author:     Dimitry Andric <[email protected]>
AuthorDate: 2025-12-25 20:13:48 +0000
Commit:     Dimitry Andric <[email protected]>
CommitDate: 2025-12-27 21:58:25 +0000

    sh: avoid warnings about too-long initializer strings
    
    Mark `optletter` and `t_op::op_text` as `__non_string`, to avoid
    warnings from clang 21 similar to:
    
        bin/sh/options.h:77:36: error: initializer-string for character array 
is too long, array size is 19 but initializer has size 20 (including the null 
terminating character); did you mean to use the 'nonstring' attribute? 
[-Werror,-Wunterminated-string-initialization]
           77 | const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh";
              |                                    ^~~~~~~~~~~~~~~~~~~~~
        bin/test/test.c:153:3: error: initializer-string for character array is 
too long, array size is 2 but initializer has size 3 (including the null 
terminating character); did you mean to use the 'nonstring' attribute? 
[-Werror,-Wunterminated-string-initialization]
          153 |         {"==",  STREQ},
              |          ^~~~
    
    MFC after:      3 days
    Reviewed by:    jilles
    Differential Revision: https://reviews.freebsd.org/D54362
---
 bin/sh/options.h | 2 +-
 bin/test/test.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/sh/options.h b/bin/sh/options.h
index a059e19707b1..2ce2e6ebedf2 100644
--- a/bin/sh/options.h
+++ b/bin/sh/options.h
@@ -74,7 +74,7 @@ extern char optval[NOPTS];
 extern const char optletter[NSHORTOPTS];
 #ifdef DEFINE_OPTIONS
 char optval[NOPTS];
-const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh";
+const char optletter[NSHORTOPTS] __nonstring = "efIimnsxvVECabupTPh";
 static const unsigned char optname[] =
        "\007errexit"
        "\006noglob"
diff --git a/bin/test/test.c b/bin/test/test.c
index a35c5b424d3f..5ba5df5d7e44 100644
--- a/bin/test/test.c
+++ b/bin/test/test.c
@@ -116,7 +116,7 @@ enum token {
 #define TOKEN_TYPE(token) ((token) & 0xff00)
 
 static const struct t_op {
-       char op_text[2];
+       char op_text[2] __nonstring;
        short op_num;
 } ops1[] = {
        {"=",   STREQ},

Reply via email to