lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdmO255nWf2PrfJ54X95ShNbYPf0FK2x=f57LmzOrCmJug@mail.gmail.com>
Date:   Wed, 25 Sep 2019 10:41:34 -0700
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Nathan Chancellor <natechancellor@...il.com>
Cc:     Steven Rostedt <rostedt@...dmis.org>,
        Ingo Molnar <mingo@...hat.com>,
        LKML <linux-kernel@...r.kernel.org>,
        clang-built-linux <clang-built-linux@...glegroups.com>,
        David Bolvansky <david.bolvansky@...il.com>
Subject: Re: [PATCH] tracing: Fix clang -Wint-in-bool-context warnings in
 IF_ASSIGN macro

On Wed, Sep 25, 2019 at 10:29 AM Nathan Chancellor
<natechancellor@...il.com> wrote:
>
> After r372664 in clang, the IF_ASSIGN macro causes a couple hundred
> warnings along the lines of:
>
> kernel/trace/trace_output.c:1331:2: warning: converting the enum
> constant to a boolean [-Wint-in-bool-context]
> kernel/trace/trace.h:409:3: note: expanded from macro
> 'trace_assign_type'
>                 IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry,
>                 ^
> kernel/trace/trace.h:371:14: note: expanded from macro 'IF_ASSIGN'
>                 WARN_ON(id && (entry)->type != id);     \
>                            ^
> 264 warnings generated.
>
> Add the implicit '!= 0' to the WARN_ON statement to fix the warnings.
>
> Link: https://github.com/llvm/llvm-project/commit/28b38c277a2941e9e891b2db30652cfd962f070b
> Link: https://github.com/ClangBuiltLinux/linux/issues/686
> Signed-off-by: Nathan Chancellor <natechancellor@...il.com>

I can't think of a case that this warning is a bug (maybe David can
explain more), but seems like a small fix that can stop a big spew of
warnings, and IIUC this is the lone instance we see in the kernel.  In
that case, I prefer a tiny change to outright disabling the warning in
case it does find interesting cases later.
Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>

> ---
>  kernel/trace/trace.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index 26b0a08f3c7d..f801d154ff6a 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -365,11 +365,11 @@ static inline struct trace_array *top_trace_array(void)
>         __builtin_types_compatible_p(typeof(var), type *)
>
>  #undef IF_ASSIGN
> -#define IF_ASSIGN(var, entry, etype, id)               \
> -       if (FTRACE_CMP_TYPE(var, etype)) {              \
> -               var = (typeof(var))(entry);             \
> -               WARN_ON(id && (entry)->type != id);     \
> -               break;                                  \
> +#define IF_ASSIGN(var, entry, etype, id)                       \
> +       if (FTRACE_CMP_TYPE(var, etype)) {                      \
> +               var = (typeof(var))(entry);                     \
> +               WARN_ON(id != 0 && (entry)->type != id);        \
> +               break;                                          \
>         }
>
>  /* Will cause compile errors if type is not found. */
> --
> 2.23.0
>


-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ