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

Philipp K philipp97kl at gmail.com
Wed Aug 29 12:51:11 UTC 2018


Am Mi., 29. Aug. 2018 um 11:52 Uhr schrieb Peter Zijlstra <
peterz at infradead.org>:

> 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 */
>
>
Tested-by: Philipp Klocke <philipp97kl at gmail.com>

[tested that warning is not reported on v4.16-rc5]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfoundation.org/pipermail/llvmlinux/attachments/20180829/2e4ba8fd/attachment.html>


More information about the LLVMLinux mailing list