Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH 0/2] Avoid -Wconstant-logical-operand in nsecs_to_jiffies_timeout()
@ 2023-07-18 21:44 Nathan Chancellor
  2023-07-18 21:44 ` [Intel-gfx] [PATCH 1/2] drm/v3d: " Nathan Chancellor
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Nathan Chancellor @ 2023-07-18 21:44 UTC (permalink / raw)
  To: jani.nikula, joonas.lahtinen, rodrigo.vivi, tvrtko.ursulin, emma,
	mwen
  Cc: trix, intel-gfx, llvm, ndesaulniers, patches, dri-devel,
	Nathan Chancellor, justinstitt

Hi all,

A proposed update to clang's -Wconstant-logical-operand [1] to warn when
the left hand side is a constant as well now triggers with the modulo
expression in nsecs_to_jiffies_timeout() when NSEC_PER_SEC is not a
multiple of HZ, such as CONFIG_HZ=300:

  drivers/gpu/drm/i915/gem/i915_gem_wait.c:189:24: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
    189 |         if (NSEC_PER_SEC % HZ &&
        |             ~~~~~~~~~~~~~~~~~ ^
  drivers/gpu/drm/i915/gem/i915_gem_wait.c:189:24: note: use '&' for a bitwise operation
    189 |         if (NSEC_PER_SEC % HZ &&
        |                               ^~
        |                               &
  drivers/gpu/drm/i915/gem/i915_gem_wait.c:189:24: note: remove constant to silence this warning
  1 warning generated.

  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.

These patches add an explicit comparison to zero to make the
expression a boolean, which clears up the warning.

The patches have no real dependency on each other but I felt like they
made send together since it is the same code.

If these could go into mainline sooner rather than later to avoid
breaking builds that can hit this with CONFIG_WERROR, that would be
nice, but I won't insist since I don't think our own CI has builds that
has those conditions, but others might.

---
Nathan Chancellor (2):
      drm/v3d: Avoid -Wconstant-logical-operand in nsecs_to_jiffies_timeout()
      drm/i915: Avoid -Wconstant-logical-operand in nsecs_to_jiffies_timeout()

 drivers/gpu/drm/i915/gem/i915_gem_wait.c | 2 +-
 drivers/gpu/drm/v3d/v3d_drv.h            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
---
base-commit: fdf0eaf11452d72945af31804e2a1048ee1b574c
change-id: 20230718-nsecs_to_jiffies_timeout-constant-logical-operand-4a944690f3e9

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-07-27 16:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-18 21:44 [Intel-gfx] [PATCH 0/2] Avoid -Wconstant-logical-operand in nsecs_to_jiffies_timeout() Nathan Chancellor
2023-07-18 21:44 ` [Intel-gfx] [PATCH 1/2] drm/v3d: " Nathan Chancellor
2023-07-21 18:36   ` Nick Desaulniers
2023-07-27 14:01   ` Maira Canal
2023-07-27 14:41     ` Nathan Chancellor
2023-07-18 21:44 ` [Intel-gfx] [PATCH 2/2] drm/i915: " Nathan Chancellor
2023-07-20  8:43   ` Tvrtko Ursulin
2023-07-20 15:16     ` Nathan Chancellor
2023-07-18 23:25 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
2023-07-19  0:45 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2023-07-27 16:08 ` [Intel-gfx] [PATCH 0/2] " Maira Canal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox