Re: [PATCH 2/4] wait: Make ___wait_is_interruptible() return 0 or 1
From: Vineet Gupta
Date: Thu Nov 05 2026 - 12:48:58 EST
On 11/5/26 1:03 AM, Peter Zijlstra wrote:
On Wed, Nov 04, 2026 at 08:07:19AM -0800, Vineet Gupta wrote:
GCC 17 adds -Wconstant-logical-operand to -Wall. It warns when an operandWhat is the actual purpose of this warning? This doesn't seem to serve
of && or || folds to a constant other than 0 or 1. With a constant state
such as TASK_KILLABLE, ___wait_is_interruptible() breaks the build with
CONFIG_WERROR=y:
include/linux/wait.h:285:39: error: use of logical '||' with constant operand '256' [-Werror=constant-logical-operand]
clang has the same warning, but it does not check an operator that comes
from a macro expansion.
Compare the masked state against 0. All callers test the result as a
truth value, so the behaviour does not change.
Signed-off-by: Vineet Gupta <vineet.gupta@xxxxxxxxx>
---
include/linux/wait.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/wait.h b/include/linux/wait.h
index c2af98b0074d..ebabdfb5b30c 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -283,7 +283,7 @@ static inline void wake_up_pollfree(struct wait_queue_head *wq_head)
#define ___wait_is_interruptible(state) \
(!__builtin_constant_p(state) || \
- (state & (TASK_INTERRUPTIBLE | TASK_WAKEKILL)))
+ (state & (TASK_INTERRUPTIBLE | TASK_WAKEKILL)) != 0)
extern void init_wait_entry(struct wait_queue_entry *wq_entry, int flags);
any value. Any non-zero value is a true, why is this a problem?
I think the intent of the toggle was to catch && vs. & mixups in source (and it only catches that in 1 direction). Clearly that is not applicable here and it seems it has never caught this in the kernel anyway.
GCC doing this, don't mean we can't turn if off again.
I will send a v2 which turns the GCC version off.
Thx,
-Vineet