kernel: Using boolean types for boolean constants
Make boolean expressions use boolean types. MISRA-C rule 14.4 Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
2c924119a3
commit
6fdc56d286
19 changed files with 64 additions and 46 deletions
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <arch/arc/syscall.h>
|
||||
#include <arch/arc/v2/exc.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -54,7 +55,7 @@ extern void _SysFatalErrorHandler(unsigned int cause, const NANO_ESF *esf);
|
|||
: "memory"); \
|
||||
CODE_UNREACHABLE; \
|
||||
} \
|
||||
} while (0)
|
||||
} while (false)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <arch/arm/syscall.h>
|
||||
#include <arch/arm/cortex_m/exc.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -51,7 +52,7 @@ extern void _SysFatalErrorHandler(unsigned int reason, const NANO_ESF *esf);
|
|||
: [reason] "i" (reason_p), [id] "i" (_SVC_CALL_RUNTIME_EXCEPT) \
|
||||
: "memory"); \
|
||||
CODE_UNREACHABLE; \
|
||||
} while (0)
|
||||
} while (false)
|
||||
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
|
||||
#define _ARCH_EXCEPT(reason_p) do { \
|
||||
__asm__ volatile ( \
|
||||
|
@ -63,7 +64,7 @@ extern void _SysFatalErrorHandler(unsigned int reason, const NANO_ESF *esf);
|
|||
: [reason] "i" (reason_p), [id] "i" (_SVC_CALL_RUNTIME_EXCEPT) \
|
||||
: "memory"); \
|
||||
CODE_UNREACHABLE; \
|
||||
} while (0)
|
||||
} while (false)
|
||||
#else
|
||||
#error Unknown ARM architecture
|
||||
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <irq.h>
|
||||
#include <sw_isr_table.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -104,7 +105,7 @@ extern void _irq_priority_set(unsigned int irq, unsigned int prio,
|
|||
extern void _arch_isr_direct_pm(void);
|
||||
#define _ARCH_ISR_DIRECT_PM() _arch_isr_direct_pm()
|
||||
#else
|
||||
#define _ARCH_ISR_DIRECT_PM() do { } while (0)
|
||||
#define _ARCH_ISR_DIRECT_PM() do { } while (false)
|
||||
#endif
|
||||
|
||||
#define _ARCH_ISR_DIRECT_HEADER() _arch_isr_direct_header()
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <kernel_arch_thread.h>
|
||||
#include <generated_dts_board.h>
|
||||
#include <mmustructs.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef _ASMLANGUAGE
|
||||
#include <arch/x86/asm_inline.h>
|
||||
|
@ -48,8 +49,8 @@ extern "C" {
|
|||
void _int_latency_start(void);
|
||||
void _int_latency_stop(void);
|
||||
#else
|
||||
#define _int_latency_start() do { } while (0)
|
||||
#define _int_latency_stop() do { } while (0)
|
||||
#define _int_latency_start() do { } while (false)
|
||||
#define _int_latency_stop() do { } while (false)
|
||||
#endif
|
||||
|
||||
/* interrupt/exception/error related definitions */
|
||||
|
@ -266,7 +267,7 @@ extern unsigned char _irq_to_interrupt_vector[];
|
|||
extern void _arch_irq_direct_pm(void);
|
||||
#define _ARCH_ISR_DIRECT_PM() _arch_irq_direct_pm()
|
||||
#else
|
||||
#define _ARCH_ISR_DIRECT_PM() do { } while (0)
|
||||
#define _ARCH_ISR_DIRECT_PM() do { } while (false)
|
||||
#endif
|
||||
|
||||
#define _ARCH_ISR_DIRECT_HEADER() _arch_isr_direct_header()
|
||||
|
@ -624,7 +625,7 @@ extern struct task_state_segment _main_tss;
|
|||
: [vector] "i" (CONFIG_X86_KERNEL_OOPS_VECTOR), \
|
||||
[reason] "i" (reason_p)); \
|
||||
CODE_UNREACHABLE; \
|
||||
} while (0)
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
/** Dummy ESF for fatal errors that would otherwise not have an ESF */
|
||||
|
|
|
@ -12,11 +12,13 @@
|
|||
#ifndef ZEPHYR_INCLUDE_DEBUG_OBJECT_TRACING_COMMON_H_
|
||||
#define ZEPHYR_INCLUDE_DEBUG_OBJECT_TRACING_COMMON_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef CONFIG_OBJECT_TRACING
|
||||
|
||||
#define SYS_TRACING_OBJ_INIT(name, obj) do { } while ((0))
|
||||
#define SYS_TRACING_OBJ_INIT_DLL(name, obj) do { } while ((0))
|
||||
#define SYS_TRACING_OBJ_REMOVE_DLL(name, obj) do { } while ((0))
|
||||
#define SYS_TRACING_OBJ_INIT(name, obj) do { } while (false)
|
||||
#define SYS_TRACING_OBJ_INIT_DLL(name, obj) do { } while (false)
|
||||
#define SYS_TRACING_OBJ_REMOVE_DLL(name, obj) do { } while (false)
|
||||
|
||||
#else
|
||||
|
||||
|
@ -40,7 +42,7 @@
|
|||
_trace_list_ ## name = obj; \
|
||||
irq_unlock(key); \
|
||||
} \
|
||||
while (0)
|
||||
while (false)
|
||||
|
||||
/**
|
||||
* @def SYS_TRACING_OBJ_INIT_DLL
|
||||
|
@ -67,7 +69,7 @@
|
|||
_trace_list_ ## name = obj; \
|
||||
irq_unlock(key); \
|
||||
} \
|
||||
while (0)
|
||||
while (false)
|
||||
|
||||
/**
|
||||
* @def SYS_TRACING_OBJ_REMOVE_DLL
|
||||
|
@ -95,7 +97,7 @@
|
|||
} \
|
||||
irq_unlock(key); \
|
||||
} \
|
||||
while (0)
|
||||
while (false)
|
||||
|
||||
#endif /*CONFIG_OBJECT_TRACING*/
|
||||
#endif /*ZEPHYR_INCLUDE_DEBUG_OBJECT_TRACING_COMMON_H_*/
|
||||
|
|
|
@ -26,6 +26,7 @@ GTEXT(_timer_int_handler)
|
|||
#else /* _ASMLANGUAGE */
|
||||
|
||||
#include <device.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
extern int _sys_clock_driver_init(struct device *device);
|
||||
|
||||
|
@ -39,8 +40,8 @@ extern void sys_clock_disable(void);
|
|||
extern void _timer_idle_enter(s32_t ticks);
|
||||
extern void _timer_idle_exit(void);
|
||||
#else
|
||||
#define _timer_idle_enter(ticks) do { } while ((0))
|
||||
#define _timer_idle_exit() do { } while ((0))
|
||||
#define _timer_idle_enter(ticks) do { } while (false)
|
||||
#define _timer_idle_exit() do { } while (false)
|
||||
#endif /* CONFIG_TICKLESS_IDLE */
|
||||
|
||||
extern void _nano_sys_clock_tick_announce(s32_t ticks);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#if !defined(_ASMLANGUAGE)
|
||||
#include <kernel_includes.h>
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -4206,9 +4207,9 @@ extern void *k_calloc(size_t nmemb, size_t size);
|
|||
/* polling API - PRIVATE */
|
||||
|
||||
#ifdef CONFIG_POLL
|
||||
#define _INIT_OBJ_POLL_EVENT(obj) do { (obj)->poll_event = NULL; } while ((0))
|
||||
#define _INIT_OBJ_POLL_EVENT(obj) do { (obj)->poll_event = NULL; } while (false)
|
||||
#else
|
||||
#define _INIT_OBJ_POLL_EVENT(obj) do { } while ((0))
|
||||
#define _INIT_OBJ_POLL_EVENT(obj) do { } while (false)
|
||||
#endif
|
||||
|
||||
/* private - implementation data created as needed, per-type */
|
||||
|
@ -4563,7 +4564,7 @@ extern void _sys_power_save_idle_exit(s32_t ticks);
|
|||
printk("@ %s:%d:\n", __FILE__, __LINE__); \
|
||||
_NanoFatalErrorHandler(reason, &_default_esf); \
|
||||
CODE_UNREACHABLE; \
|
||||
} while (0)
|
||||
} while (false)
|
||||
|
||||
#endif /* _ARCH__EXCEPT */
|
||||
|
||||
|
@ -4605,7 +4606,7 @@ extern void _init_static_threads(void);
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
#define _init_static_threads() do { } while ((0))
|
||||
#define _init_static_threads() do { } while (false)
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <logging/log_msg.h>
|
||||
#include <logging/log_instance.h>
|
||||
#include <misc/util.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -153,7 +154,7 @@ extern "C" {
|
|||
do { \
|
||||
u32_t args[] = {__LOG_ARGUMENTS(__VA_ARGS__)}; \
|
||||
log_n(_str, args, ARRAY_SIZE(args), _src_level); \
|
||||
} while (0)
|
||||
} while (false)
|
||||
|
||||
#define _LOG_INTERNAL_4(_src_level, _str, ...) \
|
||||
_LOG_INTERNAL_LONG(_src_level, _str, __VA_ARGS__)
|
||||
|
@ -206,7 +207,7 @@ extern "C" {
|
|||
/* evaluated once when log is enabled.*/ \
|
||||
log_printf_arg_checker(__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
} while (false)
|
||||
|
||||
#define _LOG(_level, ...) \
|
||||
__LOG(_level, \
|
||||
|
@ -237,7 +238,7 @@ extern "C" {
|
|||
}; \
|
||||
log_hexdump(_str, _data, _length, src_level); \
|
||||
} \
|
||||
} while (0)
|
||||
} while (false)
|
||||
|
||||
#define _LOG_HEXDUMP(_level, _data, _length, _str) \
|
||||
__LOG_HEXDUMP(_level, \
|
||||
|
@ -286,7 +287,7 @@ extern "C" {
|
|||
LOG_FILTER_SLOT_SHIFT(_id)); \
|
||||
*(_filters) |= ((_filter) & LOG_FILTER_SLOT_MASK) << \
|
||||
LOG_FILTER_SLOT_SHIFT(_id); \
|
||||
} while (0)
|
||||
} while (false)
|
||||
|
||||
#define LOG_FILTER_AGGR_SLOT_IDX 0
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ extern void posix_exit(int exit_code);
|
|||
(void)printk(fmt, ##__VA_ARGS__); \
|
||||
__ASSERT_POST; \
|
||||
} \
|
||||
} while ((0))
|
||||
} while (false)
|
||||
|
||||
#define __ASSERT_EVAL(expr1, expr2, test, fmt, ...) \
|
||||
do { \
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#ifndef _ASMLANGUAGE
|
||||
|
||||
#include <zephyr/types.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Helper to pass a int as a pointer or vice-versa.
|
||||
* Those are available for 32 bits architectures:
|
||||
|
@ -181,7 +182,7 @@ static inline s64_t arithmetic_shift_right(s64_t value, u8_t shift)
|
|||
* ENABLED: _IS_ENABLED3(_YYYY, 1, 0)
|
||||
* DISABLED _IS_ENABLED3(_XXXX 1, 0)
|
||||
*/
|
||||
#define _IS_ENABLED2(one_or_two_args) _IS_ENABLED3(one_or_two_args 1, 0)
|
||||
#define _IS_ENABLED2(one_or_two_args) _IS_ENABLED3(one_or_two_args true, false)
|
||||
|
||||
/* And our second argument is thus now cooked to be 1 in the case
|
||||
* where the value is defined to 1, and 0 if not:
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <net/net_core.h>
|
||||
#include <net/ptp_time.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -170,7 +171,7 @@ struct gptp_hdr {
|
|||
(uscaled_ns_ptr)->low = \
|
||||
gptp_get_current_time_nanosecond(port) << 16; \
|
||||
(uscaled_ns_ptr)->high = 0; \
|
||||
} while (0)
|
||||
} while (false)
|
||||
|
||||
/**
|
||||
* @typedef gptp_phase_dis_callback_t
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* @brief Networking
|
||||
* @defgroup networking Networking
|
||||
|
@ -53,12 +55,12 @@ extern "C" {
|
|||
#define NET_ASSERT(cond) do { \
|
||||
if (!(cond)) { \
|
||||
NET_ERR("{assert: '" #cond "' failed}"); \
|
||||
} } while (0)
|
||||
} } while (false)
|
||||
#define NET_ASSERT_INFO(cond, fmt, ...) do { \
|
||||
if (!(cond)) { \
|
||||
NET_ERR("{assert: '" #cond "' failed} " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
} } while (0)
|
||||
} } while (false)
|
||||
#else /* NET_LOG_ENABLED */
|
||||
#define NET_DBG(...)
|
||||
#define NET_ERR(...)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#ifndef ZEPHYR_INCLUDE_TOOLCHAIN_GCC_H_
|
||||
#define ZEPHYR_INCLUDE_TOOLCHAIN_GCC_H_
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief GCC toolchain abstraction
|
||||
|
@ -28,6 +29,7 @@
|
|||
#endif
|
||||
|
||||
#include <toolchain/common.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define ALIAS_OF(of) __attribute__((alias(#of)))
|
||||
|
||||
|
@ -85,7 +87,7 @@ do { \
|
|||
} *__p = (__typeof__(__p)) (p); \
|
||||
__p->__v = (v); \
|
||||
compiler_barrier(); \
|
||||
} while (0)
|
||||
} while (false)
|
||||
|
||||
#else
|
||||
|
||||
|
@ -95,7 +97,7 @@ do { \
|
|||
__typeof__(*p) __v; \
|
||||
} *__p = (__typeof__(__p)) (p); \
|
||||
__p->__v = (v); \
|
||||
} while (0)
|
||||
} while (false)
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -137,8 +139,8 @@ do { \
|
|||
#define __deprecated __attribute__((deprecated))
|
||||
#define ARG_UNUSED(x) (void)(x)
|
||||
|
||||
#define likely(x) __builtin_expect((long)!!(x), 1L)
|
||||
#define unlikely(x) __builtin_expect((long)!!(x), 0L)
|
||||
#define likely(x) __builtin_expect((long)!!(x), true)
|
||||
#define unlikely(x) __builtin_expect((long)!!(x), false)
|
||||
|
||||
#define popcount(x) __builtin_popcount(x)
|
||||
|
||||
|
@ -364,6 +366,6 @@ A##a:
|
|||
|
||||
#define compiler_barrier() do { \
|
||||
__asm__ __volatile__ ("" ::: "memory"); \
|
||||
} while ((0))
|
||||
} while (false)
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_TOOLCHAIN_GCC_H_ */
|
||||
|
|
|
@ -27,7 +27,7 @@ s32_t _sys_idle_threshold_ticks = CONFIG_TICKLESS_IDLE_THRESH;
|
|||
((ticks == K_FOREVER) || (ticks >= _sys_idle_threshold_ticks))
|
||||
#endif
|
||||
#else
|
||||
#define _must_enter_tickless_idle(ticks) ((void)ticks, (0))
|
||||
#define _must_enter_tickless_idle(ticks) ((void)ticks, false)
|
||||
#endif /* CONFIG_TICKLESS_IDLE */
|
||||
|
||||
#ifdef CONFIG_SYS_POWER_MANAGEMENT
|
||||
|
@ -153,7 +153,7 @@ void _sys_power_save_idle_exit(s32_t ticks)
|
|||
#if K_IDLE_PRIO < 0
|
||||
#define IDLE_YIELD_IF_COOP() k_yield()
|
||||
#else
|
||||
#define IDLE_YIELD_IF_COOP() do { } while ((0))
|
||||
#define IDLE_YIELD_IF_COOP() do { } while (false)
|
||||
#endif
|
||||
|
||||
void idle(void *unused1, void *unused2, void *unused3)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <kernel_structs.h>
|
||||
#include <tracing.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef CONFIG_MULTITHREADING
|
||||
#define _VALID_PRIO(prio, entry_point) \
|
||||
|
@ -24,7 +25,7 @@
|
|||
(prio), \
|
||||
K_LOWEST_APPLICATION_THREAD_PRIO, \
|
||||
K_HIGHEST_APPLICATION_THREAD_PRIO); \
|
||||
} while ((0))
|
||||
} while (false)
|
||||
#else
|
||||
#define _VALID_PRIO(prio, entry_point) ((prio) == -1)
|
||||
#define _ASSERT_VALID_PRIO(prio, entry_point) __ASSERT((prio) == -1, "")
|
||||
|
|
|
@ -122,7 +122,7 @@ K_THREAD_STACK_DEFINE(_interrupt_stack3, CONFIG_ISR_STACK_SIZE);
|
|||
#ifdef CONFIG_SYS_CLOCK_EXISTS
|
||||
#define initialize_timeouts() do { \
|
||||
sys_dlist_init(&_timeout_q); \
|
||||
} while ((0))
|
||||
} while (false)
|
||||
#else
|
||||
#define initialize_timeouts() do { } while ((0))
|
||||
#endif
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <kernel_structs.h>
|
||||
#include <kernel_internal.h>
|
||||
#include <misc/__assert.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
static u8_t max_partitions;
|
||||
|
||||
|
@ -26,7 +27,8 @@ static bool sane_partition(const struct k_mem_partition *part,
|
|||
write = K_MEM_PARTITION_IS_WRITABLE(part->attr);
|
||||
|
||||
if (exec && write) {
|
||||
__ASSERT(0, "partition is writable and executable <start %x>",
|
||||
__ASSERT(false,
|
||||
"partition is writable and executable <start %x>",
|
||||
part->start);
|
||||
return false;
|
||||
}
|
||||
|
@ -45,7 +47,7 @@ static bool sane_partition(const struct k_mem_partition *part,
|
|||
cur_exec = K_MEM_PARTITION_IS_EXECUTABLE(parts[i].attr);
|
||||
|
||||
if ((cur_write && exec) || (cur_exec && write)) {
|
||||
__ASSERT(0, "overlapping partitions are "
|
||||
__ASSERT(false, "overlapping partitions are "
|
||||
"writable and executable "
|
||||
"<%x...%x>, <%x...%x>",
|
||||
part->start, end,
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
#include <syscall_handler.h>
|
||||
#include <tracing.h>
|
||||
|
||||
#define RECORD_STATE_CHANGE(mutex) do { } while ((0))
|
||||
#define RECORD_CONFLICT(mutex) do { } while ((0))
|
||||
#define RECORD_STATE_CHANGE(mutex) do { } while (false)
|
||||
#define RECORD_CONFLICT(mutex) do { } while (false)
|
||||
|
||||
|
||||
extern struct k_mutex _k_mutex_list_start[];
|
||||
|
|
|
@ -67,7 +67,7 @@ static inline int is_condition_met(struct k_poll_event *event, u32_t *state)
|
|||
case K_POLL_TYPE_IGNORE:
|
||||
return 0;
|
||||
default:
|
||||
__ASSERT(0, "invalid event type (0x%x)\n", event->type);
|
||||
__ASSERT(false, "invalid event type (0x%x)\n", event->type);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ static inline int register_event(struct k_poll_event *event,
|
|||
/* nothing to do */
|
||||
break;
|
||||
default:
|
||||
__ASSERT(0, "invalid event type\n");
|
||||
__ASSERT(false, "invalid event type\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ static inline void clear_event_registration(struct k_poll_event *event)
|
|||
/* nothing to do */
|
||||
break;
|
||||
default:
|
||||
__ASSERT(0, "invalid event type\n");
|
||||
__ASSERT(false, "invalid event type\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ int _impl_k_poll(struct k_poll_event *events, int num_events, s32_t timeout)
|
|||
if (rc == 0) {
|
||||
++last_registered;
|
||||
} else {
|
||||
__ASSERT(0, "unexpected return code\n");
|
||||
__ASSERT(false, "unexpected return code\n");
|
||||
}
|
||||
}
|
||||
irq_unlock(key);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue