[Git][hardenedbsd/HardenedBSD][hardened/current/cross-dso-cfi] 3 commits: sh: avoid warnings about too-long initializer strings

0 views
Skip to first unread message

HardenedBSD Services (@hardenedbsd-services)

unread,
Dec 27, 2025, 8:01:56 PM (23 hours ago) Dec 27
to src-com...@hardenedbsd.org


HardenedBSD Services pushed to branch hardened/current/cross-dso-cfi at HardenedBSD / HardenedBSD


Commits:
e6546807 by Dimitry Andric at 2025-12-27T22:58:25+01:00
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

- - - - -
1033ea95 by HardenedBSD Sync Services at 2025-12-27T18:01:37-07:00
Merge branch 'freebsd/current/main' into hardened/current/master

- - - - -
8d2af24b by HardenedBSD Sync Services at 2025-12-27T18:01:50-07:00
Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi

- - - - -


2 changed files:

- bin/sh/options.h
- bin/test/test.c


Changes:

=====================================
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"


=====================================
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},



View it on GitLab: https://git.hardenedbsd.org/hardenedbsd/HardenedBSD/-/compare/042c22021d7a374cb10bda4f62c642a0091060dc...8d2af24ba19bb3d9cf48e80bb5f4774a11b15dde

--
View it on GitLab: https://git.hardenedbsd.org/hardenedbsd/HardenedBSD/-/compare/042c22021d7a374cb10bda4f62c642a0091060dc...8d2af24ba19bb3d9cf48e80bb5f4774a11b15dde
You're receiving this email because of your account on git.hardenedbsd.org.


Reply all
Reply to author
Forward
0 new messages