kernel: Using boolean constants instead of 0 or 1
MISRA C requires that every controlling expression of and if or while statement have a boolean type. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
4218d5f8f0
commit
b3d9202704
9 changed files with 20 additions and 14 deletions
|
@ -17,6 +17,7 @@
|
|||
#include <toolchain.h>
|
||||
#include <linker/sections.h>
|
||||
#include <syscall_handler.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
extern struct k_alert _k_alert_list_start[];
|
||||
extern struct k_alert _k_alert_list_end[];
|
||||
|
@ -48,7 +49,7 @@ void _alert_deliver(struct k_work *work)
|
|||
{
|
||||
struct k_alert *alert = CONTAINER_OF(work, struct k_alert, work_item);
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
if ((alert->handler)(alert) == 0) {
|
||||
/* do nothing -- handler has processed the alert */
|
||||
} else {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <drivers/system_timer.h>
|
||||
#include <wait_q.h>
|
||||
#include <power.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if defined(CONFIG_TICKLESS_IDLE)
|
||||
/*
|
||||
|
@ -20,7 +21,7 @@
|
|||
s32_t _sys_idle_threshold_ticks = CONFIG_TICKLESS_IDLE_THRESH;
|
||||
|
||||
#if defined(CONFIG_TICKLESS_KERNEL)
|
||||
#define _must_enter_tickless_idle(ticks) (1)
|
||||
#define _must_enter_tickless_idle(ticks) (true)
|
||||
#else
|
||||
#define _must_enter_tickless_idle(ticks) \
|
||||
((ticks == K_FOREVER) || (ticks >= _sys_idle_threshold_ticks))
|
||||
|
@ -47,7 +48,6 @@ void __attribute__((weak)) _sys_soc_resume_from_deep_sleep(void)
|
|||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Indicate that kernel is idling in tickless mode
|
||||
|
@ -64,7 +64,7 @@ static void set_kernel_idle_time_in_ticks(s32_t ticks)
|
|||
_kernel.idle = ticks;
|
||||
}
|
||||
#else
|
||||
#define set_kernel_idle_time_in_ticks(x) do { } while (0)
|
||||
#define set_kernel_idle_time_in_ticks(x) do { } while (false)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SMP
|
||||
|
@ -175,7 +175,7 @@ void idle(void *unused1, void *unused2, void *unused3)
|
|||
* busy waiting is needed to prevent lock contention. Long
|
||||
* term we need to wake up idle CPUs with an IPI.
|
||||
*/
|
||||
while (1) {
|
||||
while (true) {
|
||||
k_busy_wait(100);
|
||||
k_yield();
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#define ZEPHYR_KERNEL_INCLUDE_KERNEL_INTERNAL_H_
|
||||
|
||||
#include <kernel.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef _ASMLANGUAGE
|
||||
|
||||
|
@ -198,7 +199,7 @@ extern void _thread_monitor_exit(struct k_thread *thread);
|
|||
#else
|
||||
#define _thread_monitor_exit(thread) \
|
||||
do {/* nothing */ \
|
||||
} while (0)
|
||||
} while (false)
|
||||
#endif /* CONFIG_THREAD_MONITOR */
|
||||
|
||||
extern void smp_init(void);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <kernel.h>
|
||||
#include <misc/printk.h>
|
||||
#include <kernel_internal.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
extern const _k_syscall_handler_t _k_syscall_table[K_SYSCALL_LIMIT];
|
||||
|
||||
|
@ -259,7 +260,7 @@ extern int z_user_string_copy(char *dst, char *src, size_t maxlen);
|
|||
if (expr) { \
|
||||
_arch_syscall_oops(ssf); \
|
||||
} \
|
||||
} while (0)
|
||||
} while (false)
|
||||
|
||||
static inline __attribute__((warn_unused_result)) __printf_like(2, 3)
|
||||
bool z_syscall_verify_msg(bool expr, const char *fmt, ...)
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <entropy.h>
|
||||
#include <logging/log_ctrl.h>
|
||||
#include <tracing.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* kernel build timestamp items */
|
||||
#define BUILD_TIMESTAMP "BUILD: " __DATE__ " " __TIME__
|
||||
|
@ -55,7 +56,7 @@ static const unsigned int boot_delay;
|
|||
#endif
|
||||
|
||||
#if !defined(CONFIG_BOOT_BANNER)
|
||||
#define PRINT_BOOT_BANNER() do { } while (0)
|
||||
#define PRINT_BOOT_BANNER() do { } while (false)
|
||||
#else
|
||||
#define PRINT_BOOT_BANNER() printk("***** " BOOT_BANNER " *****\n")
|
||||
#endif
|
||||
|
@ -493,7 +494,7 @@ FUNC_NORETURN void _Cstart(void)
|
|||
bg_thread_main(NULL, NULL, NULL);
|
||||
|
||||
irq_lock();
|
||||
while (1) {
|
||||
while (true) {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <init.h>
|
||||
#include <string.h>
|
||||
#include <misc/__assert.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Linker-defined symbols bound the static pool structs */
|
||||
extern struct k_mem_pool _k_mem_pool_list_start[];
|
||||
|
@ -59,7 +60,7 @@ int k_mem_pool_alloc(struct k_mem_pool *p, struct k_mem_block *block,
|
|||
end = _tick_get() + _ms_to_ticks(timeout);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
u32_t level_num, block_num;
|
||||
|
||||
/* There is a "managed race" in alloc that can fail
|
||||
|
|
|
@ -252,7 +252,7 @@ static inline void handle_timeouts(s32_t ticks)
|
|||
_handle_expired_timeouts(&expired);
|
||||
}
|
||||
#else
|
||||
#define handle_timeouts(ticks) do { } while ((0))
|
||||
#define handle_timeouts(ticks) do { } while (false)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIMESLICING
|
||||
|
@ -295,7 +295,7 @@ static void handle_time_slicing(s32_t ticks)
|
|||
#endif
|
||||
}
|
||||
#else
|
||||
#define handle_time_slicing(ticks) do { } while (0)
|
||||
#define handle_time_slicing(ticks) do { } while (false)
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -661,7 +661,7 @@ void k_thread_access_grant(struct k_thread *thread, ...)
|
|||
va_list args;
|
||||
va_start(args, thread);
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
void *object = va_arg(args, void *);
|
||||
if (object == NULL) {
|
||||
break;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <kernel_structs.h>
|
||||
#include <wait_q.h>
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
static void work_q_main(void *work_q_ptr, void *p2, void *p3)
|
||||
{
|
||||
|
@ -22,7 +23,7 @@ static void work_q_main(void *work_q_ptr, void *p2, void *p3)
|
|||
ARG_UNUSED(p2);
|
||||
ARG_UNUSED(p3);
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
struct k_work *work;
|
||||
k_work_handler_t handler;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue