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]
Date:   Mon, 4 Nov 2019 11:07:15 -0800
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Nathan Chancellor <natechancellor@...il.com>
Cc:     Mauro Carvalho Chehab <mchehab@...nel.org>,
        linux-media@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
        clang-built-linux <clang-built-linux@...glegroups.com>
Subject: Re: [PATCH] media: v4l2-device.h: Explicitly compare grpmask to zero
 in v4l2_device_mask_call_all

On Thu, Oct 24, 2019 at 1:17 PM Nathan Chancellor
<natechancellor@...il.com> wrote:
>
> When building with Clang + -Wtautological-constant-compare, several of
> the ivtv drivers warn along the lines of:
>
>  drivers/media/pci/cx18/cx18-driver.c:1005:21: warning: converting the
>  result of '<<' to a boolean always evaluates to true
>  [-Wtautological-constant-compare]
>                          cx18_call_hw(cx, CX18_HW_GPIO_RESET_CTRL,
>                                          ^
>  drivers/media/pci/cx18/cx18-cards.h:18:37: note: expanded from macro
>  'CX18_HW_GPIO_RESET_CTRL'
>  #define CX18_HW_GPIO_RESET_CTRL         (1 << 6)
>                                            ^
>  1 warning generated.
>
> This is because the shift operation is implicitly converted to a boolean
> in v4l2_device_mask_call_all before being negated. This can be solved by
> just comparing the mask result to 0 explicity so that there is no

s/explicity/explicitly/

Harmless enough change, thanks for the patch, and sorry for taking so
long to review.
Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>

> boolean conversion.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/752
> Signed-off-by: Nathan Chancellor <natechancellor@...il.com>
> ---
>
> I am aware that there is suddenly a style mismatch (some macros using
> !(grpmask) and this one using (grpmask) == 0) but I chose to display the
> minimal fix. If you want me to update all the macros to use this style,
> I'd be happy to in a followup patch.
>
> There are 19 of these warnings in the drivers/media/pci folder, which
> can be seen here:
>
> https://github.com/ClangBuiltLinux/linux/issues/488#issuecomment-545218125
>
> This is the simplest fix but if you all prefer an alternative one, I
> would be happy to see/review/test it. The ultimate goal is to get
> -Wtautological-compare enabled because there are several subwarnings
> that would be helpful to have and right now they are all disabled:
>
> https://github.com/ClangBuiltLinux/linux/issues/488
>
>  include/media/v4l2-device.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
> index e0b8f2602670..8564b3227887 100644
> --- a/include/media/v4l2-device.h
> +++ b/include/media/v4l2-device.h
> @@ -431,8 +431,8 @@ static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev)
>                 struct v4l2_subdev *__sd;                               \
>                                                                         \
>                 __v4l2_device_call_subdevs_p(v4l2_dev, __sd,            \
> -                       !(grpmsk) || (__sd->grp_id & (grpmsk)), o, f ,  \
> -                       ##args);                                        \
> +                       (grpmsk) == 0 || (__sd->grp_id & (grpmsk)), o,  \
> +                       f , ##args);                                    \
>         } while (0)
>
>  /**
> --


-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ