All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: <dev@dpdk.org>, <stable@dpdk.org>,
	Jack Bond-Preston <jack.bond-preston@foss.arm.com>,
	Gavin Hu <gahu@nvidia.com>,
	"Honnappa Nagarahalli" <honnappa.nagarahalli@arm.com>,
	Pablo de Lara <pablo.de.lara.guarch@intel.com>
Subject: Re: [PATCH] eal: silence -Wconstant-logical-operand in RTE_IS_POWER_OF_2
Date: Mon, 18 May 2026 17:56:08 +0100	[thread overview]
Message-ID: <agtEqEv2fB7R7_Aa@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <20260518163401.580696-1-stephen@networkplumber.org>

On Mon, May 18, 2026 at 09:33:31AM -0700, Stephen Hemminger wrote:
> Newer GCC warns when a non-boolean constant is an operand of &&, which
> trips whenever RTE_IS_POWER_OF_2 is used in a static_assert with a
> power-of-two literal. Make the zero check explicit.
> 
> Fixes: 7c872b96983a ("hash: validate hash bucket entries while compiling")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

One further suggestion below, since you are changing this.
> ---
>  lib/eal/include/rte_bitops.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/eal/include/rte_bitops.h b/lib/eal/include/rte_bitops.h
> index aa6ac73abb..d2719ecd5e 100644
> --- a/lib/eal/include/rte_bitops.h
> +++ b/lib/eal/include/rte_bitops.h
> @@ -1299,7 +1299,7 @@ rte_fls_u64(uint64_t x)
>  /**
>   * Macro to return 1 if n is a power of 2, 0 otherwise
>   */
> -#define RTE_IS_POWER_OF_2(n) ((n) && !(((n) - 1) & (n)))
> +#define RTE_IS_POWER_OF_2(n) ((n) != 0 && !(((n) - 1) & (n)))
>  

I'd also suggest changing the second part of the && to match, changing the
"!" for explicit "== 0":

#define RTE_IS_POWER_OF_2(n) ((n) != 0 && (((n) - 1) & (n)) == 0)

>  /**
>   * Returns true if n is a power of 2
> -- 
> 2.53.0
> 

  reply	other threads:[~2026-05-18 16:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18 16:33 [PATCH] eal: silence -Wconstant-logical-operand in RTE_IS_POWER_OF_2 Stephen Hemminger
2026-05-18 16:56 ` Bruce Richardson [this message]
2026-05-18 17:10   ` Stephen Hemminger
2026-05-19  9:26 ` Jack Bond-Preston
2026-05-19 13:49 ` [PATCH v2] " Stephen Hemminger
2026-05-27  8:41   ` Thomas Monjalon

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=agtEqEv2fB7R7_Aa@bricha3-mobl1.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=gahu@nvidia.com \
    --cc=honnappa.nagarahalli@arm.com \
    --cc=jack.bond-preston@foss.arm.com \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=stable@dpdk.org \
    --cc=stephen@networkplumber.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.