From: Maira Canal <mcanal@igalia.com>
To: Nathan Chancellor <nathan@kernel.org>,
jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com,
rodrigo.vivi@intel.com, tvrtko.ursulin@linux.intel.com,
emma@anholt.net, mwen@igalia.com
Cc: trix@redhat.com, intel-gfx@lists.freedesktop.org,
llvm@lists.linux.dev, ndesaulniers@google.com,
patches@lists.linux.dev, dri-devel@lists.freedesktop.org,
justinstitt@google.com
Subject: Re: [PATCH 0/2] Avoid -Wconstant-logical-operand in nsecs_to_jiffies_timeout()
Date: Thu, 27 Jul 2023 13:08:13 -0300 [thread overview]
Message-ID: <2b3d9647-b1db-cbb6-2421-b12ec3482eae@igalia.com> (raw)
In-Reply-To: <20230718-nsecs_to_jiffies_timeout-constant-logical-operand-v1-0-36ed8fc8faea@kernel.org>
On 7/18/23 18:44, Nathan Chancellor wrote:
> 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()
Applied both patches to drm-misc/drm-misc-next!
Best Regards,
- Maíra
>
> 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,
prev parent reply other threads:[~2023-07-27 16:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-18 21:44 [PATCH 0/2] Avoid -Wconstant-logical-operand in nsecs_to_jiffies_timeout() Nathan Chancellor
2023-07-18 21:44 ` [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 ` [PATCH 2/2] drm/i915: " Nathan Chancellor
2023-07-20 8:43 ` Tvrtko Ursulin
2023-07-20 15:16 ` Nathan Chancellor
2023-07-27 16:08 ` Maira Canal [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2b3d9647-b1db-cbb6-2421-b12ec3482eae@igalia.com \
--to=mcanal@igalia.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emma@anholt.net \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=justinstitt@google.com \
--cc=llvm@lists.linux.dev \
--cc=mwen@igalia.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=patches@lists.linux.dev \
--cc=rodrigo.vivi@intel.com \
--cc=trix@redhat.com \
--cc=tvrtko.ursulin@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox