[PATCH 2/2] test: parenthesize assertion macro parameters

Marat Khalili marat.khalili at huawei.com
Thu Apr 30 13:53:10 CEST 2026


Acked-by: Marat Khalili <marat.khalili at huawei.com>

> -----Original Message-----
> From: Stephen Hemminger <stephen at networkplumber.org>
> Sent: Wednesday 29 April 2026 15:42
> To: dev at dpdk.org
> Cc: Weijun Pan <wpan3636 at gmail.com>; stable at dpdk.org; Thomas Monjalon <thomas at monjalon.net>; Jerin
> Jacob <jerinj at marvell.com>; Pavan Nikhilesh <pbhagavatula at marvell.com>
> Subject: [PATCH 2/2] test: parenthesize assertion macro parameters
> 
> From: Weijun Pan <wpan3636 at gmail.com>
> 
> Some test assertion macros use parameters directly in expressions,
> which can lead to unexpected evaluation due to operator precedence
> after macro substitution.
> 
> Fix this by parenthesizing macro parameters and the resulting
> expressions in rte_test.h
> 
> Bugzilla ID: 1925
> Fixes: 5afc521eac6a ("eal: add test assert macros")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Weijun Pan <wpan3636 at gmail.com>
> ---
>  .mailmap                   |  1 +
>  lib/eal/include/rte_test.h | 12 ++++++------
>  2 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/.mailmap b/.mailmap
> index 0e0d83e1c6..a72bba5fb8 100644
> --- a/.mailmap
> +++ b/.mailmap
> @@ -1771,6 +1771,7 @@ Weichun Chen <weichunx.chen at intel.com>
>  Weifeng Li <liweifeng96 at 126.com>
>  Weiguo Li <liweiguo at xencore.cn> <liwg06 at foxmail.com>
>  WeiJie Zhuang <zhuangwj at gmail.com>
> +Weijun Pan <wpan3636 at gmail.com> <wpan36 at wisc.edu>
>  Weiliang Luo <droidluo at gmail.com>
>  Weiyuan Li <weiyuanx.li at intel.com>
>  Wen Chiu <wchiu at brocade.com>
> diff --git a/lib/eal/include/rte_test.h b/lib/eal/include/rte_test.h
> index 62c8f165af..d132d3156b 100644
> --- a/lib/eal/include/rte_test.h
> +++ b/lib/eal/include/rte_test.h
> @@ -26,21 +26,21 @@
>  } while (0)
> 
>  #define RTE_TEST_ASSERT_EQUAL(a, b, msg, ...) \
> -	RTE_TEST_ASSERT(a == b, msg, ##__VA_ARGS__)
> +	RTE_TEST_ASSERT((a) == (b), msg, ##__VA_ARGS__)
> 
>  #define RTE_TEST_ASSERT_NOT_EQUAL(a, b, msg, ...) \
> -	RTE_TEST_ASSERT(a != b, msg, ##__VA_ARGS__)
> +	RTE_TEST_ASSERT((a) != (b), msg, ##__VA_ARGS__)
> 
>  #define RTE_TEST_ASSERT_SUCCESS(val, msg, ...) \
> -	RTE_TEST_ASSERT(val == 0, msg, ##__VA_ARGS__)
> +	RTE_TEST_ASSERT((val) == 0, msg, ##__VA_ARGS__)
> 
>  #define RTE_TEST_ASSERT_FAIL(val, msg, ...) \
> -	RTE_TEST_ASSERT(val != 0, msg, ##__VA_ARGS__)
> +	RTE_TEST_ASSERT((val) != 0, msg, ##__VA_ARGS__)
> 
>  #define RTE_TEST_ASSERT_NULL(val, msg, ...) \
> -	RTE_TEST_ASSERT(val == NULL, msg, ##__VA_ARGS__)
> +	RTE_TEST_ASSERT((val) == NULL, msg, ##__VA_ARGS__)
> 
>  #define RTE_TEST_ASSERT_NOT_NULL(val, msg, ...) \
> -	RTE_TEST_ASSERT(val != NULL, msg, ##__VA_ARGS__)
> +	RTE_TEST_ASSERT((val) != NULL, msg, ##__VA_ARGS__)
> 
>  #endif /* _RTE_TEST_H_ */
> --
> 2.53.0



More information about the stable mailing list