tc_util: protect macro arg expansion
Calling TC_END_REPORT(complex_expression) might have side effects when complex_expression is later put inside (result == TC_PASS? A : B) evaluation, because result will be replaced verbatim. To avoid operator assignment order changing things, protect replacement of result by adding parenthesis. Change-Id: I8fd07d97d4b49b4cd48a1c6ad345bf49fb2537b5 Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
This commit is contained in:
parent
c20b48b9ed
commit
3ad37fbebc
|
@ -80,14 +80,14 @@
|
|||
#define TC_END(result, fmt, ...) PRINT_DATA(fmt, ##__VA_ARGS__)
|
||||
|
||||
/* prints result and the function name */
|
||||
#define _TC_END_RESULT(result, func) \
|
||||
do { \
|
||||
PRINT_LINE; \
|
||||
TC_END(result, "%s - %s.\n", \
|
||||
result == TC_PASS ? PASS : FAIL, func); \
|
||||
#define _TC_END_RESULT(result, func) \
|
||||
do { \
|
||||
PRINT_LINE; \
|
||||
TC_END(result, "%s - %s.\n", \
|
||||
(result) == TC_PASS ? PASS : FAIL, func); \
|
||||
} while (0)
|
||||
#define TC_END_RESULT(result) \
|
||||
_TC_END_RESULT(result, __func__)
|
||||
_TC_END_RESULT((result), __func__)
|
||||
|
||||
#define TC_END_REPORT(result) \
|
||||
do { \
|
||||
|
@ -95,7 +95,7 @@
|
|||
TC_PRINT_RUNID; \
|
||||
TC_END(result, \
|
||||
"PROJECT EXECUTION %s\n", \
|
||||
result == TC_PASS ? "SUCCESSFUL" : "FAILED"); \
|
||||
(result) == TC_PASS ? "SUCCESSFUL" : "FAILED"); \
|
||||
} while (0)
|
||||
|
||||
#endif /* __TC_UTIL_H__ */
|
||||
|
|
Loading…
Reference in a new issue