[PATCH] builtin: mark __builtin_strlen() as integer constant expression
Daniel Gomez <[email protected]> Thu, 19 Feb 2026 17:10:53 +0100
| Newsgroups | org.kernel.vger.linux-sparse,org.kernel.vger.linux-kernel,org.kernel.vger.linux-modules |
|---|---|
| Message-ID | <[email protected]> |
From: Daniel Gomez <[email protected]> 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 <[email protected]> --- 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 <[email protected]>