From fe0314e8c31b675b3e9a079e70acec064010b2b6 Mon Sep 17 00:00:00 2001 From: Huihuang Shi Date: Tue, 19 Jun 2018 14:06:47 +0800 Subject: [PATCH] HV:header:fix "expression is not Boolean" MISRA C explicit required expression should be boolean when in branch statements (if,while...). Signed-off-by: Huihuang Shi Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/instr_emul_wrapper.h | 8 ++++---- hypervisor/include/arch/x86/timer.h | 2 +- hypervisor/include/debug/trace.h | 2 +- hypervisor/include/lib/list.h | 2 +- hypervisor/include/lib/types.h | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hypervisor/arch/x86/guest/instr_emul_wrapper.h b/hypervisor/arch/x86/guest/instr_emul_wrapper.h index 647a8d8c6..bf1a2d7d2 100644 --- a/hypervisor/arch/x86/guest/instr_emul_wrapper.h +++ b/hypervisor/arch/x86/guest/instr_emul_wrapper.h @@ -121,10 +121,10 @@ struct seg_desc { #define SEG_DESC_TYPE(access) ((access) & 0x001f) #define SEG_DESC_DPL(access) (((access) >> 5) & 0x3) -#define SEG_DESC_PRESENT(access) (((access) & 0x0080) ? 1 : 0) -#define SEG_DESC_DEF32(access) (((access) & 0x4000) ? 1 : 0) -#define SEG_DESC_GRANULARITY(access) (((access) & 0x8000) ? 1 : 0) -#define SEG_DESC_UNUSABLE(access) (((access) & 0x10000) ? 1 : 0) +#define SEG_DESC_PRESENT(access) ((((access) & 0x0080U) != 0U) ? 1 : 0) +#define SEG_DESC_DEF32(access) ((((access) & 0x4000U) != 0U) ? 1 : 0) +#define SEG_DESC_GRANULARITY(access) ((((access) & 0x8000U) != 0U) ? 1 : 0) +#define SEG_DESC_UNUSABLE(access) ((((access) & 0x10000U) != 0U) ? 1 : 0) struct vm_guest_paging { uint64_t cr3; diff --git a/hypervisor/include/arch/x86/timer.h b/hypervisor/include/arch/x86/timer.h index f7a255179..c15e4c8e9 100644 --- a/hypervisor/include/arch/x86/timer.h +++ b/hypervisor/include/arch/x86/timer.h @@ -38,7 +38,7 @@ static inline void initialize_timer(struct timer *timer, int mode, uint64_t period_in_cycle) { - if (timer) { + if (timer != NULL) { timer->func = func; timer->priv_data = priv_data; timer->fire_tsc = fire_tsc; diff --git a/hypervisor/include/debug/trace.h b/hypervisor/include/debug/trace.h index 40bf91e8b..0631e9225 100644 --- a/hypervisor/include/debug/trace.h +++ b/hypervisor/include/debug/trace.h @@ -78,7 +78,7 @@ trace_check(int cpu_id, __unused int evid) if (cpu_id >= phy_cpu_num) return false; - if (!per_cpu(sbuf, cpu_id)[ACRN_TRACE]) + if (per_cpu(sbuf, cpu_id)[ACRN_TRACE] == NULL) return false; return true; diff --git a/hypervisor/include/lib/list.h b/hypervisor/include/lib/list.h index f7e42bbf0..e8ca48590 100644 --- a/hypervisor/include/lib/list.h +++ b/hypervisor/include/lib/list.h @@ -73,7 +73,7 @@ static inline void list_del_init(struct list_head *entry) INIT_LIST_HEAD(entry); } -static inline int list_empty(struct list_head *head) +static inline _Bool list_empty(struct list_head *head) { return head->next == head; } diff --git a/hypervisor/include/lib/types.h b/hypervisor/include/lib/types.h index 99dbd1957..08fb78734 100644 --- a/hypervisor/include/lib/types.h +++ b/hypervisor/include/lib/types.h @@ -32,15 +32,15 @@ typedef signed long int64_t; typedef unsigned int size_t; typedef __builtin_va_list va_list; -typedef uint8_t bool; +typedef _Bool bool; #ifndef NULL #define NULL ((void *) 0) #endif #ifndef true -#define true 1 -#define false 0 +#define true ((_Bool) 1) +#define false ((_Bool) 0) #endif #ifndef UINT64_MAX