From: Weijun Pan <[email protected]>

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

Signed-off-by: Weijun Pan <[email protected]>
Acked-by: Stephen Hemminger <[email protected]>
Acked-by: Marat Khalili <[email protected]>
---
 .mailmap                   |  1 +
 lib/eal/include/rte_test.h | 12 ++++++------
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/.mailmap b/.mailmap
index 895412e568..3c08fe9aa3 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1772,6 +1772,7 @@ Weichun Chen <[email protected]>
 Weifeng Li <[email protected]>
 Weiguo Li <[email protected]> <[email protected]>
 WeiJie Zhuang <[email protected]>
+Weijun Pan <[email protected]> <[email protected]>
 Weiliang Luo <[email protected]>
 Weiyuan Li <[email protected]>
 Wen Chiu <[email protected]>
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

Reply via email to