]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
drm/v3d: Avoid -Wconstant-logical-operand in nsecs_to_jiffies_timeout()
authorNathan Chancellor <nathan@kernel.org>
Tue, 18 Jul 2023 21:44:19 +0000 (14:44 -0700)
committerMaíra Canal <mairacanal@riseup.net>
Thu, 27 Jul 2023 16:01:27 +0000 (13:01 -0300)
commitb27211db61aed86f095e76aa61eaef3bf3e0b7c2
tree8d6112a0dd7366dd529184ca07077a37e1f53cee
parent8373d11d7daddd1a209950cff2f0a7449876c2e3
drm/v3d: Avoid -Wconstant-logical-operand in nsecs_to_jiffies_timeout()

A proposed update to clang's -Wconstant-logical-operand to warn when the
left hand side is a constant shows the following instance in
nsecs_to_jiffies_timeout() when NSEC_PER_SEC is not a multiple of HZ,
such as CONFIG_HZ=300:

  In file included from drivers/gpu/drm/v3d/v3d_debugfs.c:12:
  drivers/gpu/drm/v3d/v3d_drv.h:343:24: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
    343 |         if (NSEC_PER_SEC % HZ &&
        |             ~~~~~~~~~~~~~~~~~ ^
  drivers/gpu/drm/v3d/v3d_drv.h:343:24: note: use '&' for a bitwise operation
    343 |         if (NSEC_PER_SEC % HZ &&
        |                               ^~
        |                               &
  drivers/gpu/drm/v3d/v3d_drv.h:343:24: note: remove constant to silence this warning
  1 warning generated.

Turn this into an explicit comparison against zero to make the
expression a boolean to make it clear this should be a logical check,
not a bitwise one.

Link: https://reviews.llvm.org/D142609
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Maíra Canal <mcanal@igalia.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Maíra Canal <mairacanal@riseup.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20230718-nsecs_to_jiffies_timeout-constant-logical-operand-v1-1-36ed8fc8faea@kernel.org
drivers/gpu/drm/v3d/v3d_drv.h