Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
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: [Intel-gfx] [PATCH 1/2] drm/v3d: Avoid -Wconstant-logical-operand in nsecs_to_jiffies_timeout()
Date: Thu, 27 Jul 2023 11:01:27 -0300	[thread overview]
Message-ID: <daaf05b5-3b18-c365-62e8-e7848c403ab7@igalia.com> (raw)
In-Reply-To: <20230718-nsecs_to_jiffies_timeout-constant-logical-operand-v1-1-36ed8fc8faea@kernel.org>

Hi Nathan,

On 7/18/23 18:44, Nathan Chancellor wrote:
> 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>

Thanks for all the hard work with clang! Let me know if you need someone
to push it to drm-misc-next.

Best Regards,
- Maíra

> ---
>   drivers/gpu/drm/v3d/v3d_drv.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h
> index b74b1351bfc8..7f664a4b2a75 100644
> --- a/drivers/gpu/drm/v3d/v3d_drv.h
> +++ b/drivers/gpu/drm/v3d/v3d_drv.h
> @@ -340,7 +340,7 @@ struct v3d_submit_ext {
>   static inline unsigned long nsecs_to_jiffies_timeout(const u64 n)
>   {
>   	/* nsecs_to_jiffies64() does not guard against overflow */
> -	if (NSEC_PER_SEC % HZ &&
> +	if ((NSEC_PER_SEC % HZ) != 0 &&
>   	    div_u64(n, NSEC_PER_SEC) >= MAX_JIFFY_OFFSET / HZ)
>   		return MAX_JIFFY_OFFSET;
>   
> 

  parent reply	other threads:[~2023-07-27 14:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=daaf05b5-3b18-c365-62e8-e7848c403ab7@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