From: Daniel Gomez <da.gomez@kernel.org>
To: Chris Li <sparse@chrisli.org>, linux-sparse@vger.kernel.org
Cc: Aaron Tomlin <atomlin@atomlin.com>,
Andy Shevchenko <andriy.shevchenko@intel.com>,
Dan Carpenter <dan.carpenter@linaro.org>,
Daniel Gomez <da.gomez@kernel.org>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Eric Biggers <ebiggers@kernel.org>,
linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org,
"Luck, Tony" <tony.luck@intel.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Sami Tolvanen <samitolvanen@google.com>,
Daniel Gomez <da.gomez@samsung.com>
Subject: [PATCH] builtin: mark __builtin_strlen() as integer constant expression
Date: Thu, 19 Feb 2026 17:10:53 +0100 [thread overview]
Message-ID: <20260219-fix-builtin-strlen-v1-1-3ec3efc0cda7@samsung.com> (raw)
From: Daniel Gomez <da.gomez@samsung.com>
Commit ae83f3b72621 ("module: Add compile-time check for embedded
NUL characters") in the Linux kernel added static assert checks for
__builtin_strlen() inside MODULE_INFO() macros. But sparse does not mark
the result as CEF_SET_ICE during evaluation, making these assertions
fail with:
error: static assertion failed: "MODULE_INFO(...) contains embedded
NUL byte"
Fix by marking __builtin_strlen() as an integer constant expression at
eval time. This matches other builtins like __builtin_constant_p() or
__builtin_safe_p().
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
Discussion:
https://lore.kernel.org/all/aTc9s210am0YqMV4@agluck-desk3/
---
builtin.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/builtin.c b/builtin.c
index 9149c43d..7573abf8 100644
--- a/builtin.c
+++ b/builtin.c
@@ -616,6 +616,7 @@ static int expand_strlen(struct expression *expr, int cost)
}
static struct symbol_op strlen_op = {
+ .evaluate = evaluate_to_int_const_expr,
.expand = expand_strlen,
};
---
base-commit: fbdde3127b83e6d09e0ba808d7925dd84407f3c6
change-id: 20260219-fix-builtin-strlen-08eb3a02609b
Best regards,
--
Daniel Gomez <da.gomez@samsung.com>
next reply other threads:[~2026-02-19 16:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-19 16:10 Daniel Gomez [this message]
2026-02-19 16:41 ` [PATCH] builtin: mark __builtin_strlen() as integer constant expression Sami Tolvanen
2026-02-19 17:00 ` Daniel Gomez
2026-02-19 17:06 ` Chris Li
2026-02-19 19:20 ` Andy Shevchenko
2026-02-20 8:06 ` Chris Li
2026-02-20 8:30 ` Andy Shevchenko
2026-02-20 19:34 ` Chris Li
2026-02-24 10:26 ` Andy Shevchenko
2026-02-19 16:53 ` Daniel Gomez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260219-fix-builtin-strlen-v1-1-3ec3efc0cda7@samsung.com \
--to=da.gomez@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=atomlin@atomlin.com \
--cc=da.gomez@samsung.com \
--cc=dan.carpenter@linaro.org \
--cc=dmitry.torokhov@gmail.com \
--cc=ebiggers@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=linux-sparse@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=samitolvanen@google.com \
--cc=sparse@chrisli.org \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).