From 723c22fc7f5c5b8e48b1c1a0648cc42e0a99ada2 Mon Sep 17 00:00:00 2001 From: Huihuang Shi Date: Sat, 29 Sep 2018 16:12:39 +0800 Subject: [PATCH] HV:fix expression is not boolean Expression should be boolean immediate before 'if','while' key-words. V1->V2 add () to bool expression Tracked-On: #861 Signed-off-by: Huihuang Shi Acked-by: Eddie Dong --- hypervisor/arch/x86/ept.c | 2 +- hypervisor/arch/x86/guest/instr_emul.c | 2 +- hypervisor/arch/x86/mtrr.c | 2 +- hypervisor/debug/npk_log.c | 11 ++++++----- hypervisor/lib/crypto/hkdf_wrap.c | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/hypervisor/arch/x86/ept.c b/hypervisor/arch/x86/ept.c index 9247096bd5..1e1cb93e8e 100644 --- a/hypervisor/arch/x86/ept.c +++ b/hypervisor/arch/x86/ept.c @@ -68,7 +68,7 @@ uint64_t local_gpa2hpa(struct vm *vm, uint64_t gpa, uint32_t *size) void *eptp; struct vcpu *vcpu = vcpu_from_pid(vm, get_cpu_id()); - if (vcpu && (vcpu->arch_vcpu.cur_context == SECURE_WORLD)) { + if ((vcpu != NULL) && (vcpu->arch_vcpu.cur_context == SECURE_WORLD)) { eptp = vm->arch_vm.sworld_eptp; } else { eptp = vm->arch_vm.nworld_eptp; diff --git a/hypervisor/arch/x86/guest/instr_emul.c b/hypervisor/arch/x86/guest/instr_emul.c index 5d39a8c0b5..072ae80e8c 100644 --- a/hypervisor/arch/x86/guest/instr_emul.c +++ b/hypervisor/arch/x86/guest/instr_emul.c @@ -2330,7 +2330,7 @@ int decode_instruction(struct vcpu *vcpu) * by VMX itself before hit EPT violation. * */ - if (emul_ctxt->vie.op.op_flags & VIE_OP_F_CHECK_GVA_DI) { + if ((emul_ctxt->vie.op.op_flags & VIE_OP_F_CHECK_GVA_DI) != 0U) { retval = instr_check_di(vcpu, emul_ctxt); if (retval < 0) return retval; diff --git a/hypervisor/arch/x86/mtrr.c b/hypervisor/arch/x86/mtrr.c index 7b94652005..cfe6377331 100644 --- a/hypervisor/arch/x86/mtrr.c +++ b/hypervisor/arch/x86/mtrr.c @@ -65,7 +65,7 @@ get_subrange_start_of_fixed_mtrr(uint32_t index, uint32_t subrange_id) static inline bool is_mtrr_enabled(struct vcpu *vcpu) { - return vcpu->mtrr.def_type.bits.enable; + return (vcpu->mtrr.def_type.bits.enable != 0U); } static inline bool is_fixed_range_mtrr_enabled(struct vcpu *vcpu) diff --git a/hypervisor/debug/npk_log.c b/hypervisor/debug/npk_log.c index ea7ad7be94..975621a7cc 100644 --- a/hypervisor/debug/npk_log.c +++ b/hypervisor/debug/npk_log.c @@ -5,7 +5,8 @@ #include -static int32_t npk_log_enabled, npk_log_setup_ref; +static int32_t npk_log_setup_ref; +static bool npk_log_enabled; static uint64_t base; static inline int npk_write(const char *value, void *addr, size_t sz) @@ -42,15 +43,15 @@ void npk_log_setup(struct hv_npk_log_param *param) switch (param->cmd) { case HV_NPK_LOG_CMD_CONF: - if (param->mmio_addr || param->loglevel != 0xffffU) + if ((param->mmio_addr != 0UL) || (param->loglevel != 0xffffU)) param->res = HV_NPK_LOG_RES_OK; /* falls through */ case HV_NPK_LOG_CMD_ENABLE: - if (param->mmio_addr) + if (param->mmio_addr != 0UL) base = param->mmio_addr; if (param->loglevel != 0xffffU) npk_loglevel = param->loglevel; - if (base && param->cmd == HV_NPK_LOG_CMD_ENABLE) { + if ((base != 0UL) && (param->cmd == HV_NPK_LOG_CMD_ENABLE)) { if (!npk_log_enabled) for (i = 0; i < phys_cpu_num; i++) per_cpu(npk_log_ref, i) = 0; @@ -87,7 +88,7 @@ void npk_log_write(const char *buf, size_t buf_len) uint32_t ref; uint16_t len; - if (!npk_log_enabled || !channel) + if (!npk_log_enabled || (channel == NULL)) return; /* calculate the channel offset based on cpu_id and npk_log_ref */ diff --git a/hypervisor/lib/crypto/hkdf_wrap.c b/hypervisor/lib/crypto/hkdf_wrap.c index 5e3e8143a1..c4554d9b93 100644 --- a/hypervisor/lib/crypto/hkdf_wrap.c +++ b/hypervisor/lib/crypto/hkdf_wrap.c @@ -15,7 +15,7 @@ int hkdf_sha256(uint8_t *out_key, size_t out_len, const mbedtls_md_info_t *md; md = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256); - if (!md) { + if (md == NULL) { return 0; }