Skip to content

Commit 714162f

Browse files
Shawnshhwenlingz
authored andcommitted
HV: fix violations touched type conversion
ACRN Coding guidelines requires type conversion shall be explicity. Tracked-On: #861 Signed-off-by: Huihuang Shi <huihuang.shi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 5d6c9c3 commit 714162f

File tree

13 files changed

+26
-25
lines changed

13 files changed

+26
-25
lines changed

hypervisor/arch/x86/configs/vmptable.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ int32_t mptable_build(struct acrn_vm *vm)
105105
(const void *)&mptable_template, sizeof(struct mptable_info));
106106

107107
mptable->mpch.entry_count = vcpu_num + MPE_NUM_BUSES + MPEII_NUM_LOCAL_IRQ;
108-
mptable->mpch.base_table_length = sizeof(struct mpcth)
109-
+ vcpu_num * sizeof(struct proc_entry)
110-
+ MPE_NUM_BUSES * sizeof(struct bus_entry)
111-
+ MPEII_NUM_LOCAL_IRQ * sizeof(struct int_entry);
108+
mptable->mpch.base_table_length = (uint16_t)sizeof(struct mpcth)
109+
+ vcpu_num * (uint16_t)sizeof(struct proc_entry)
110+
+ MPE_NUM_BUSES * (uint16_t)sizeof(struct bus_entry)
111+
+ MPEII_NUM_LOCAL_IRQ * (uint16_t)sizeof(struct int_entry);
112112

113113
mptable_length = sizeof(struct mpfps) + mptable->mpch.base_table_length;
114114
if (mptable_length <= MPTABLE_MAX_LENGTH) {

hypervisor/arch/x86/guest/trusty.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,9 @@ static bool setup_trusty_info(struct acrn_vcpu *vcpu, uint32_t mem_size, uint64_
349349

350350
stac();
351351
mem = (struct trusty_mem *)(hpa2hva(mem_base_hpa));
352-
(void)memcpy_s(&mem->first_page.key_info, sizeof(struct trusty_key_info),
352+
(void)memcpy_s((void *)&mem->first_page.key_info, sizeof(struct trusty_key_info),
353353
&key_info, sizeof(key_info));
354-
(void)memcpy_s(&mem->first_page.startup_param, sizeof(struct trusty_startup_param),
354+
(void)memcpy_s((void *)&mem->first_page.startup_param, sizeof(struct trusty_startup_param),
355355
&startup_param, sizeof(startup_param));
356356
clac();
357357
success = true;

hypervisor/arch/x86/guest/vcpuid.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ static int32_t set_vcpuid_sgx(struct acrn_vm *vm)
210210
if (result == 0) {
211211
init_vcpuid_entry(CPUID_SGX_LEAF, 1U, CPUID_CHECK_SUBLEAF, &entry);
212212
/* MPX not present to guest */
213-
entry.ecx &= ~XCR0_BNDREGS;
214-
entry.ecx &= ~XCR0_BNDCSR;
213+
entry.ecx &= (uint32_t) ~XCR0_BNDREGS;
214+
entry.ecx &= (uint32_t) ~XCR0_BNDCSR;
215215
result = set_vcpuid_entry(vm, &entry);
216216
}
217217
if (result == 0) {

hypervisor/arch/x86/ioapic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ create_rte_for_gsi_irq(uint32_t irq, uint32_t vr)
225225
rte.bits.intr_polarity = IOAPIC_RTE_INTPOL_AHI;
226226

227227
/* Dest field */
228-
rte.bits.dest_field = ALL_CPUS_MASK;
228+
rte.bits.dest_field = (uint8_t) ALL_CPUS_MASK;
229229
}
230230

231231
return rte;

hypervisor/arch/x86/seed/seed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static uint32_t parse_seed_arg(void)
7171
arg -= len;
7272
len = (arg_end != NULL) ? (uint32_t)(arg_end - arg) :
7373
strnlen_s(arg, MAX_BOOTARGS_SIZE);
74-
(void)memset((void *)arg, (char)' ', len);
74+
(void)memset((void *)arg, (uint8_t)' ', len);
7575
break;
7676
}
7777
}

hypervisor/boot/cmdline.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int32_t parse_hv_cmdline(void)
4343
while ((*end != ' ') && ((*end) != '\0'))
4444
end++;
4545

46-
if (!handle_dbg_cmd(start, end - start)) {
46+
if (!handle_dbg_cmd(start, (int32_t)(end - start))) {
4747
/* if not handled by handle_dbg_cmd, it can be handled further */
4848
}
4949
start = end + 1;

hypervisor/boot/guest/vboot_info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ static int32_t depri_boot_sw_loader(struct acrn_vm *vm)
299299
* We copy the info saved in depri_boot to boot_context and
300300
* init bsp with boot_context.
301301
*/
302-
(void)memcpy_s(&(vcpu_regs->gprs), sizeof(struct acrn_gp_regs),
302+
(void)memcpy_s((void *)&(vcpu_regs->gprs), sizeof(struct acrn_gp_regs),
303303
&(depri_boot_ctx->vcpu_regs.gprs), sizeof(struct acrn_gp_regs));
304304

305305
vcpu_regs->rip = depri_boot_ctx->vcpu_regs.rip;

hypervisor/debug/console.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ static void vuart_console_rx_chars(struct acrn_vuart *vu)
7979
*/
8080
static void vuart_console_tx_chars(struct acrn_vuart *vu)
8181
{
82-
char c;
82+
char c = vuart_getchar(vu);
8383

84-
while ((c = vuart_getchar(vu)) != -1) {
84+
while(c != -1) {
8585
printf("%c", c);
86+
c = vuart_getchar(vu);
8687
}
8788
}
8889

hypervisor/debug/profiling.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ void profiling_pre_vmexit_handler(struct acrn_vcpu *vcpu)
13821382
get_cpu_var(profiling_info.vm_info).guest_cs
13831383
= exec_vmread64(VMX_GUEST_CS_SEL);
13841384

1385-
get_cpu_var(profiling_info.vm_info).guest_vm_id = (int32_t)vcpu->vm->vm_id;
1385+
get_cpu_var(profiling_info.vm_info).guest_vm_id = (int16_t)vcpu->vm->vm_id;
13861386
}
13871387
}
13881388

hypervisor/debug/shell.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,8 @@ static int32_t shell_to_vm_console(int32_t argc, char **argv)
876876
struct acrn_vm *vm;
877877
struct acrn_vuart *vu;
878878

879-
if (argc == 2U) {
880-
vm_id = sanitize_vmid(strtol_deci(argv[1]));
879+
if (argc == 2) {
880+
vm_id = sanitize_vmid((uint16_t)strtol_deci(argv[1]));
881881
}
882882

883883
/* Get the virtual device node */

0 commit comments

Comments
 (0)