diff --git a/hypervisor/acpi_parser/dmar_parse.c b/hypervisor/acpi_parser/dmar_parse.c index 9ce01c611..cfbdcb639 100644 --- a/hypervisor/acpi_parser/dmar_parse.c +++ b/hypervisor/acpi_parser/dmar_parse.c @@ -65,9 +65,8 @@ static int32_t handle_dmar_devscope(struct dmar_dev_scope *dev_scope, void *addr if ((remaining >= (int32_t)sizeof(struct acpi_dmar_device_scope)) && (remaining >= (int32_t)apci_devscope->length)) { path = (struct acpi_dmar_pci_path *)(apci_devscope + 1); - path_len = (apci_devscope->length - - sizeof(struct acpi_dmar_device_scope)) / - sizeof(struct acpi_dmar_pci_path); + path_len = (int32_t)((apci_devscope->length - sizeof(struct acpi_dmar_device_scope)) / + sizeof(struct acpi_dmar_pci_path)); dmar_bdf = dmar_path_bdf(path_len, apci_devscope->bus, path); dev_scope->id = apci_devscope->enumeration_id; @@ -122,8 +121,7 @@ static int32_t handle_one_drhd(struct acpi_dmar_hardware_unit *acpi_drhd, struct drhd->dev_cnt = dev_count; - remaining = acpi_drhd->header.length - - sizeof(struct acpi_dmar_hardware_unit); + remaining = (int32_t)(acpi_drhd->header.length - sizeof(struct acpi_dmar_hardware_unit)); dev_scope = drhd->devices; diff --git a/hypervisor/arch/x86/cpu_caps.c b/hypervisor/arch/x86/cpu_caps.c index 89fd559b1..f6e80b20f 100644 --- a/hypervisor/arch/x86/cpu_caps.c +++ b/hypervisor/arch/x86/cpu_caps.c @@ -189,7 +189,7 @@ bool is_ac_enabled(void) { bool ac_enabled = false; - if (has_core_cap(CORE_CAP_SPLIT_LOCK) && (msr_read(MSR_TEST_CTL) & MSR_TEST_CTL_AC_SPLITLOCK)) { + if (has_core_cap(CORE_CAP_SPLIT_LOCK) && ((msr_read(MSR_TEST_CTL) & MSR_TEST_CTL_AC_SPLITLOCK) != 0UL)) { ac_enabled = true; } @@ -200,7 +200,7 @@ bool is_gp_enabled(void) { bool gp_enabled = false; - if (has_core_cap(CORE_CAP_UC_LOCK) && (msr_read(MSR_TEST_CTL) & MSR_TEST_CTL_GP_UCLOCK)) { + if (has_core_cap(CORE_CAP_UC_LOCK) && ((msr_read(MSR_TEST_CTL) & MSR_TEST_CTL_GP_UCLOCK) != 0UL)) { gp_enabled = true; } diff --git a/hypervisor/arch/x86/cpu_state_tbl.c b/hypervisor/arch/x86/cpu_state_tbl.c index b10382957..9c26b343f 100644 --- a/hypervisor/arch/x86/cpu_state_tbl.c +++ b/hypervisor/arch/x86/cpu_state_tbl.c @@ -133,7 +133,7 @@ static struct cpu_state_info cpu_pm_state_info; static int32_t get_state_tbl_idx(const char *cpuname) { int32_t i; - int32_t count = ARRAY_SIZE(cpu_state_tbl); + int32_t count = (int32_t)ARRAY_SIZE(cpu_state_tbl); int32_t ret = -1; if (cpuname != NULL) { diff --git a/hypervisor/arch/x86/guest/guest_memory.c b/hypervisor/arch/x86/guest/guest_memory.c index 426b735c1..233ba2a07 100644 --- a/hypervisor/arch/x86/guest/guest_memory.c +++ b/hypervisor/arch/x86/guest/guest_memory.c @@ -198,7 +198,7 @@ static int32_t local_gva2gpa_common(struct acrn_vcpu *vcpu, const struct page_wa static int32_t local_gva2gpa_pae(struct acrn_vcpu *vcpu, struct page_walk_info *pw_info, uint64_t gva, uint64_t *gpa, uint32_t *err_code) { - int32_t index; + uint32_t index; uint64_t *base; uint64_t entry; uint64_t addr; diff --git a/hypervisor/arch/x86/guest/pm.c b/hypervisor/arch/x86/guest/pm.c index 2a7b91c92..c7a8ef1bf 100644 --- a/hypervisor/arch/x86/guest/pm.c +++ b/hypervisor/arch/x86/guest/pm.c @@ -290,7 +290,7 @@ static bool rt_vm_pm1a_io_write(struct acrn_vcpu *vcpu, uint16_t addr, size_t wi if (width != 2U) { pr_dbg("Invalid address (0x%x) or width (0x%x)", addr, width); } else { - if ((((v & VIRTUAL_PM1A_SLP_EN) != 0U) && (((v & VIRTUAL_PM1A_SLP_TYP) >> 10U) == 5U)) != 0U) { + if (((v & VIRTUAL_PM1A_SLP_EN) != 0U) && (((v & VIRTUAL_PM1A_SLP_TYP) >> 10U) == 5U)) { poweroff_if_rt_vm(vcpu->vm); } } diff --git a/hypervisor/arch/x86/trampoline.c b/hypervisor/arch/x86/trampoline.c index 9deb48170..9729b2307 100644 --- a/hypervisor/arch/x86/trampoline.c +++ b/hypervisor/arch/x86/trampoline.c @@ -63,7 +63,7 @@ static void update_trampoline_code_refs(uint64_t dest_pa) { void *ptr; uint64_t val; - int32_t i; + uint32_t i; /* * calculate the fixup CS:IP according to fixup target address @@ -88,7 +88,7 @@ static void update_trampoline_code_refs(uint64_t dest_pa) *(uint64_t *)(ptr) += dest_pa; ptr = hpa2hva(dest_pa + trampoline_relo_addr(&trampoline_pdpt_addr)); - for (i = 0; i < 4; i++) { + for (i = 0U; i < 4U; i++) { *(uint64_t *)(ptr + sizeof(uint64_t) * i) += dest_pa; } diff --git a/hypervisor/boot/boot.c b/hypervisor/boot/boot.c index 49cd7e5d2..09c28b988 100644 --- a/hypervisor/boot/boot.c +++ b/hypervisor/boot/boot.c @@ -11,7 +11,7 @@ #include #include -static struct acrn_boot_info acrn_bi = { 0U }; +static struct acrn_boot_info acrn_bi = { 0 }; /** * @pre (p_start != NULL) && (p_end != NULL) diff --git a/hypervisor/include/arch/x86/asm/lib/bits.h b/hypervisor/include/arch/x86/asm/lib/bits.h index d0b8d0586..3f66826e8 100644 --- a/hypervisor/include/arch/x86/asm/lib/bits.h +++ b/hypervisor/include/arch/x86/asm/lib/bits.h @@ -293,7 +293,7 @@ build_bitmap_testandclear(bitmap32_test_and_clear_lock, "l", uint32_t, BUS_LOCK) static inline uint16_t bitmap_weight(uint64_t bits) { - return __builtin_popcountl(bits); + return (uint16_t)__builtin_popcountl(bits); } #endif /* BITS_H*/ diff --git a/hypervisor/include/public/acrn_hv_defs.h b/hypervisor/include/public/acrn_hv_defs.h index e7985a694..752adc452 100644 --- a/hypervisor/include/public/acrn_hv_defs.h +++ b/hypervisor/include/public/acrn_hv_defs.h @@ -282,7 +282,7 @@ struct hc_api_version { uint32_t minor_version; } __aligned(8); -#define ACRN_PLATFORM_LAPIC_IDS_MAX 64 +#define ACRN_PLATFORM_LAPIC_IDS_MAX 64U /** * Hypervisor API, return it for HC_GET_PLATFORM_INFO hypercall */ diff --git a/hypervisor/lib/sprintf.c b/hypervisor/lib/sprintf.c index 3182054b0..4caf0373a 100755 --- a/hypervisor/lib/sprintf.c +++ b/hypervisor/lib/sprintf.c @@ -528,7 +528,7 @@ void do_print(const char *fmt_arg, struct print_param *param, else if (ch == 'c') { char c[2]; - c[0] = __builtin_va_arg(args, int32_t); + c[0] = (char)__builtin_va_arg(args, int32_t); c[1] = 0; print_string(param, c); }