[llvmlinux] [PATCH] sched/fair: disable clang -Wconstant-logical-operand

Peter Zijlstra peterz at infradead.org
Wed Aug 29 09:52:00 UTC 2018


On Tue, Aug 28, 2018 at 03:49:01PM -0700, Nick Desaulniers wrote:
> Tested-by: Nick Desaulniers <ndesaulniers at google.com>
> 
> Peter, can you send this upstream?

Something like the below?

---
Subject: sched,debug: Explicitly cast sched_feat() to bool
From: Peter Zijlstra <peterz at infradead.org>
Date: Wed Aug 29 11:45:21 CEST 2018

LLVM has a warning that tags expressions like:

	if (foo && non-bool-const)

This pattern triggers for CONFIG_SCHED_DEBUG=n where sched_feat() ends
up being whatever bit we select. Avoid the warning with an explicit
cast to bool.

Reported-by: Philipp Klocke <philipp97kl at gmail.com>
Tested-by: Nick Desaulniers <ndesaulniers at google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz at infradead.org>
---
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1393,7 +1393,7 @@ static const_debug __maybe_unused unsign
 	0;
 #undef SCHED_FEAT
 
-#define sched_feat(x) (sysctl_sched_features & (1UL << __SCHED_FEAT_##x))
+#define sched_feat(x) !!(sysctl_sched_features & (1UL << __SCHED_FEAT_##x))
 
 #endif /* SCHED_DEBUG && HAVE_JUMP_LABEL */
 


More information about the LLVMLinux mailing list