Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [PATCH] lib/interval_tree: fix allocation warning messages
@ 2026-08-08 12:36 Karl Mehltretter
  2026-08-08 17:50 ` Andrew Morton
  2026-08-09  1:44 ` Wei Yang
  0 siblings, 2 replies; 4+ messages in thread
From: Karl Mehltretter @ 2026-08-08 12:36 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Karl Mehltretter, Wei Yang, linux-kernel, llvm

WARN_ON_ONCE() takes a condition, not a message. The string literals
are always true, so the warnings still trigger but the messages are
never printed.

Use WARN_ONCE(1, ...) instead to print the messages and keep the
once-only behavior.

Found with a Coccinelle script. Clang's -Wstring-conversion also flags
such calls but is not enabled in kernel builds.

Fixes: 82114e45131f ("lib/interval_tree: add test case for interval_tree_iter_xxx() helpers")
Assisted-by: Claude:claude-fable-5 coccinelle
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
---
 lib/interval_tree_test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/interval_tree_test.c b/lib/interval_tree_test.c
index eba2d3e28980..b0b07270ce7c 100644
--- a/lib/interval_tree_test.c
+++ b/lib/interval_tree_test.c
@@ -140,13 +140,13 @@ static int intersection_range_check(void)
 
 	intxn1 = bitmap_alloc(nnodes, GFP_KERNEL);
 	if (!intxn1) {
-		WARN_ON_ONCE("Failed to allocate intxn1\n");
+		WARN_ONCE(1, "Failed to allocate intxn1\n");
 		return -ENOMEM;
 	}
 
 	intxn2 = bitmap_alloc(nnodes, GFP_KERNEL);
 	if (!intxn2) {
-		WARN_ON_ONCE("Failed to allocate intxn2\n");
+		WARN_ONCE(1, "Failed to allocate intxn2\n");
 		bitmap_free(intxn1);
 		return -ENOMEM;
 	}
-- 
2.39.5 (Apple Git-154)


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

* Re: [PATCH] lib/interval_tree: fix allocation warning messages
  2026-08-08 12:36 [PATCH] lib/interval_tree: fix allocation warning messages Karl Mehltretter
@ 2026-08-08 17:50 ` Andrew Morton
  2026-08-08 18:55   ` Karl Mehltretter
  2026-08-09  1:44 ` Wei Yang
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2026-08-08 17:50 UTC (permalink / raw)
  To: Karl Mehltretter; +Cc: Wei Yang, linux-kernel, llvm

On Sat,  8 Aug 2026 14:36:08 +0200 Karl Mehltretter <kmehltretter@gmail.com> wrote:

> WARN_ON_ONCE() takes a condition, not a message. The string literals
> are always true, so the warnings still trigger but the messages are
> never printed.
> 
> Use WARN_ONCE(1, ...) instead to print the messages and keep the
> once-only behavior.

lol, OK, thanks.

	fgrep -r 'WARN_ON_ONCE("' .

finds more.



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

* Re: [PATCH] lib/interval_tree: fix allocation warning messages
  2026-08-08 17:50 ` Andrew Morton
@ 2026-08-08 18:55   ` Karl Mehltretter
  0 siblings, 0 replies; 4+ messages in thread
From: Karl Mehltretter @ 2026-08-08 18:55 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Wei Yang, linux-kernel, llvm

On Sat, Aug 08, 2026 at 10:50:05AM +0100, Andrew Morton wrote:
> lol, OK, thanks.
> 
> 	fgrep -r 'WARN_ON_ONCE("' .
> 
> finds more.
> 

Indeed! I already sent patches for the other instances to their
respective maintainers.

Thanks,
Karl

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

* Re: [PATCH] lib/interval_tree: fix allocation warning messages
  2026-08-08 12:36 [PATCH] lib/interval_tree: fix allocation warning messages Karl Mehltretter
  2026-08-08 17:50 ` Andrew Morton
@ 2026-08-09  1:44 ` Wei Yang
  1 sibling, 0 replies; 4+ messages in thread
From: Wei Yang @ 2026-08-09  1:44 UTC (permalink / raw)
  To: Karl Mehltretter; +Cc: Andrew Morton, Wei Yang, linux-kernel, llvm

On Sat, Aug 08, 2026 at 02:36:08PM +0200, Karl Mehltretter wrote:
>WARN_ON_ONCE() takes a condition, not a message. The string literals
>are always true, so the warnings still trigger but the messages are
>never printed.
>
>Use WARN_ONCE(1, ...) instead to print the messages and keep the
>once-only behavior.
>
>Found with a Coccinelle script. Clang's -Wstring-conversion also flags
>such calls but is not enabled in kernel builds.
>
>Fixes: 82114e45131f ("lib/interval_tree: add test case for interval_tree_iter_xxx() helpers")
>Assisted-by: Claude:claude-fable-5 coccinelle
>Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>

Oops, thanks for fixing it.

Reviewed-by: Wei Yang <richard.weiyang@gmail.com>

>---
> lib/interval_tree_test.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/lib/interval_tree_test.c b/lib/interval_tree_test.c
>index eba2d3e28980..b0b07270ce7c 100644
>--- a/lib/interval_tree_test.c
>+++ b/lib/interval_tree_test.c
>@@ -140,13 +140,13 @@ static int intersection_range_check(void)
> 
> 	intxn1 = bitmap_alloc(nnodes, GFP_KERNEL);
> 	if (!intxn1) {
>-		WARN_ON_ONCE("Failed to allocate intxn1\n");
>+		WARN_ONCE(1, "Failed to allocate intxn1\n");
> 		return -ENOMEM;
> 	}
> 
> 	intxn2 = bitmap_alloc(nnodes, GFP_KERNEL);
> 	if (!intxn2) {
>-		WARN_ON_ONCE("Failed to allocate intxn2\n");
>+		WARN_ONCE(1, "Failed to allocate intxn2\n");
> 		bitmap_free(intxn1);
> 		return -ENOMEM;
> 	}
>-- 
>2.39.5 (Apple Git-154)

-- 
Wei Yang
Help you, Help me

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

end of thread, other threads:[~2026-08-09  1:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-08 12:36 [PATCH] lib/interval_tree: fix allocation warning messages Karl Mehltretter
2026-08-08 17:50 ` Andrew Morton
2026-08-08 18:55   ` Karl Mehltretter
2026-08-09  1:44 ` Wei Yang

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