public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] builtin: mark __builtin_strlen() as integer constant expression
@ 2026-02-19 16:10 Daniel Gomez
  2026-02-19 16:41 ` Sami Tolvanen
  2026-02-19 16:53 ` Daniel Gomez
  0 siblings, 2 replies; 10+ messages in thread
From: Daniel Gomez @ 2026-02-19 16:10 UTC (permalink / raw)
  To: Chris Li, linux-sparse
  Cc: Aaron Tomlin, Andy Shevchenko, Dan Carpenter, Daniel Gomez,
	Dmitry Torokhov, Eric Biggers, linux-kernel, linux-modules,
	Luck, Tony, Luis Chamberlain, Petr Pavlu, Sami Tolvanen,
	Daniel Gomez

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>


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-02-24 10:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-19 16:10 [PATCH] builtin: mark __builtin_strlen() as integer constant expression Daniel Gomez
2026-02-19 16:41 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox