Skip to content

Commit 2c92411

Browse files
Flavio Ceolinnashif
authored andcommitted
misc: assert: Using boolean constants
Using booleans true/false instead of using 1/0 in boolean expressions. MISRA-C rule 14.4 Signed-off-by: Flavio Ceolin <[email protected]>
1 parent 070716e commit 2c92411

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

include/misc/__assert.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
#ifndef ZEPHYR_INCLUDE_MISC___ASSERT_H_
6262
#define ZEPHYR_INCLUDE_MISC___ASSERT_H_
6363

64+
#include <stdbool.h>
65+
6466
#ifdef CONFIG_ASSERT
6567
#ifndef __ASSERT_ON
6668
#define __ASSERT_ON CONFIG_ASSERT_LEVEL
@@ -106,21 +108,21 @@ extern void posix_exit(int exit_code);
106108
do { \
107109
expr2; \
108110
__ASSERT(test, fmt, ##__VA_ARGS__); \
109-
} while (0)
111+
} while (false)
110112

111113
#if (__ASSERT_ON == 1)
112114
#warning "__ASSERT() statements are ENABLED"
113115
#endif
114116
#else
115117
#define __ASSERT(test, fmt, ...) \
116118
do {/* nothing */ \
117-
} while ((0))
119+
} while (false)
118120
#define __ASSERT_EVAL(expr1, expr2, test, fmt, ...) expr1
119121
#endif
120122
#else
121123
#define __ASSERT(test, fmt, ...) \
122124
do {/* nothing */ \
123-
} while ((0))
125+
} while (false)
124126
#define __ASSERT_EVAL(expr1, expr2, test, fmt, ...) expr1
125127
#endif
126128

0 commit comments

Comments
 (0)