From 3596a037ab44a1ad588fb388d5d4ee8f3d2a1ca7 Mon Sep 17 00:00:00 2001 From: Harman Kalra Date: Wed, 24 Jun 2020 15:50:47 +0530 Subject: [PATCH] eal: fix parentheses in alignment macros Found an issue while using RTE_ALIGN_MUL_NEAR with an expression, like as passed in estimate_tsc_freq(). RTE_ALIGN_MUL_FLOOR resulted in unexpected value as parathesis are required to evaluate an expression. Fixes: 5120203d753f ("eal: add macros to align value to multiple") Cc: stable@dpdk.org Signed-off-by: Harman Kalra --- lib/librte_eal/include/rte_common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/include/rte_common.h b/lib/librte_eal/include/rte_common.h index 586f815c54..8f487a563d 100644 --- a/lib/librte_eal/include/rte_common.h +++ b/lib/librte_eal/include/rte_common.h @@ -304,7 +304,7 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) * than the first parameter. */ #define RTE_ALIGN_MUL_CEIL(v, mul) \ - (((v + (typeof(v))(mul) - 1) / ((typeof(v))(mul))) * (typeof(v))(mul)) + ((((v) + (typeof(v))(mul) - 1) / ((typeof(v))(mul))) * (typeof(v))(mul)) /** * Macro to align a value to the multiple of given value. The resultant @@ -312,7 +312,7 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) * than the first parameter. */ #define RTE_ALIGN_MUL_FLOOR(v, mul) \ - ((v / ((typeof(v))(mul))) * (typeof(v))(mul)) + (((v) / ((typeof(v))(mul))) * (typeof(v))(mul)) /** * Macro to align value to the nearest multiple of the given value. @@ -323,7 +323,7 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) ({ \ typeof(v) ceil = RTE_ALIGN_MUL_CEIL(v, mul); \ typeof(v) floor = RTE_ALIGN_MUL_FLOOR(v, mul); \ - (ceil - v) > (v - floor) ? floor : ceil; \ + (ceil - (v)) > ((v) - floor) ? floor : ceil; \ }) /** -- 2.20.1