zephyr/ztest_assert.h: Fix implicit to bool conversion
The current zassert macro uses implicit conversion to boolean which has implication on analysis tools like clang-tidy-14. This add an aditional step to create a boolean value for the evaluation instead use the string direct which allows run analysis tool without this warning/error. Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
This commit is contained in:
parent
09cad20b48
commit
b0564dfd97
1 changed files with 8 additions and 4 deletions
|
@ -132,8 +132,10 @@ static inline bool z_zassume(bool cond, const char *default_msg, const char *fil
|
|||
*/
|
||||
#define zassert(cond, default_msg, msg, ...) \
|
||||
do { \
|
||||
bool _ret = z_zassert(cond, msg ? ("(" default_msg ")") : (default_msg), __FILE__, \
|
||||
__LINE__, __func__, msg ? msg : "", ##__VA_ARGS__); \
|
||||
bool _msg = (msg != NULL); \
|
||||
bool _ret = z_zassert(cond, _msg ? ("(" default_msg ")") : (default_msg), __FILE__,\
|
||||
__LINE__, __func__, _msg ? msg : "", ##__VA_ARGS__); \
|
||||
(void)_msg; \
|
||||
if (!_ret) { \
|
||||
/* If kernel but without multithreading return. */ \
|
||||
COND_CODE_1(KERNEL, (COND_CODE_1(CONFIG_MULTITHREADING, (), (return;))), \
|
||||
|
@ -161,8 +163,10 @@ static inline bool z_zassume(bool cond, const char *default_msg, const char *fil
|
|||
*/
|
||||
#define zassume(cond, default_msg, msg, ...) \
|
||||
do { \
|
||||
bool _ret = z_zassume(cond, msg ? ("(" default_msg ")") : (default_msg), __FILE__, \
|
||||
__LINE__, __func__, msg ? msg : "", ##__VA_ARGS__); \
|
||||
bool _msg = (msg != NULL); \
|
||||
bool _ret = z_zassume(cond, _msg ? ("(" default_msg ")") : (default_msg), __FILE__,\
|
||||
__LINE__, __func__, _msg ? msg : "", ##__VA_ARGS__); \
|
||||
(void)_msg; \
|
||||
if (!_ret) { \
|
||||
/* If kernel but without multithreading return. */ \
|
||||
COND_CODE_1(KERNEL, (COND_CODE_1(CONFIG_MULTITHREADING, (), (return;))), \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue