Re: [PATCH 2/4] wait: Make ___wait_is_interruptible() return 0 or 1

From: Peter Zijlstra

Date: Thu Nov 05 2026 - 04:04:01 EST


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 operand
> 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);

What is the actual purpose of this warning? This doesn't seem to serve
any value. Any non-zero value is a true, why is this a problem?

GCC doing this, don't mean we can't turn if off again.