|SUCCESS| eal: silence -Wconstant-logical-operand in RTE_IS_POWER_OF_2

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Mon May 18 19:55:41 CEST 2026


Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/164086

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-05-18

Reviewing patch series.patch for DPDK coding standards compliance.

commit 1da41afe90a6e97f88ad63ef1b52a3a7c872b969
Author: Stephen Hemminger <stephen at networkplumber.org>

    eal: silence -Wconstant-logical-operand in RTE_IS_POWER_OF_2

This patch modifies the RTE_IS_POWER_OF_2 macro to eliminate compiler
warnings by making the zero check explicit.

> 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)))

Does this change introduce a potential issue when the macro is called
with expressions containing assignments or side effects? While the
original implicit boolean conversion of (n) happens once, could (n) != 0
cause problems if n contains side effects like function calls or
increment operators?

Would it be safer to capture the macro argument in a temporary variable
to ensure single evaluation, particularly given that this is a widely
used utility macro that might be called with complex expressions?


More information about the test-report mailing list