Skip to content

Commit 1664e0c

Browse files
Shawnshhlijinxia
authored andcommitted
HV:fix rest integer violations
Fix integer related violations. V1->V2: clean all memset/calloc integer violations excpet bsp/boot directory Signed-off-by: Huihuang Shi <huihuang.shi@intel.com> Reviewed-by: Junjie Mao <junjie.mao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 56904bc commit 1664e0c

File tree

11 files changed

+24
-24
lines changed

11 files changed

+24
-24
lines changed

hypervisor/arch/x86/guest/guest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ uint64_t create_guest_initial_paging(struct vm *vm)
760760
* number for it(without trusty) is GUEST_INIT_PT_PAGE_NUM-1.
761761
* here make sure they are init as 0 (page entry no present)
762762
*/
763-
(void)memset(pml4_addr, 0, PAGE_SIZE_4K * GUEST_INIT_PT_PAGE_NUM-1);
763+
(void)memset(pml4_addr, 0U, PAGE_SIZE_4K * GUEST_INIT_PT_PAGE_NUM-1);
764764

765765
/* Write PML4E */
766766
table_present = (IA32E_COMM_P_BIT | IA32E_COMM_RW_BIT);
@@ -800,7 +800,7 @@ uint64_t create_guest_initial_paging(struct vm *vm)
800800
*/
801801
if (vm->sworld_control.sworld_enabled && !is_vm0(vm)) {
802802
/* clear page entry for trusty */
803-
(void)memset(pml4_addr + 6 * PAGE_SIZE_4K, 0, PAGE_SIZE_4K);
803+
(void)memset(pml4_addr + 6U * PAGE_SIZE_4K, 0U, PAGE_SIZE_4K);
804804

805805
/* Write PDPTE for trusy memory, PD will use 7th page */
806806
pd_base_paddr = GUEST_INIT_PAGE_TABLE_START +

hypervisor/arch/x86/guest/vcpu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ int create_vcpu(uint16_t pcpu_id, struct vm *vm, struct vcpu **rtn_vcpu_handle)
4141
pr_info("Creating VCPU %hu", pcpu_id);
4242

4343
/* Allocate memory for VCPU */
44-
vcpu = calloc(1, sizeof(struct vcpu));
44+
vcpu = calloc(1U, sizeof(struct vcpu));
4545
ASSERT(vcpu != NULL, "");
4646

4747
/* Initialize the physical CPU ID for this VCPU */
@@ -96,7 +96,7 @@ int create_vcpu(uint16_t pcpu_id, struct vm *vm, struct vcpu **rtn_vcpu_handle)
9696
ASSERT(vcpu->arch_vcpu.vmcs != NULL, "");
9797

9898
/* Memset VMCS region for this VCPU */
99-
(void)memset(vcpu->arch_vcpu.vmcs, 0, CPU_PAGE_SIZE);
99+
(void)memset(vcpu->arch_vcpu.vmcs, 0U, CPU_PAGE_SIZE);
100100

101101
/* Initialize exception field in VCPU context */
102102
vcpu->arch_vcpu.exception_info.exception = VECTOR_INVALID;
@@ -283,7 +283,7 @@ void reset_vcpu(struct vcpu *vcpu)
283283
vcpu->arch_vcpu.cur_context = NORMAL_WORLD;
284284
vcpu->arch_vcpu.irq_window_enabled = 0;
285285
vcpu->arch_vcpu.inject_event_pending = false;
286-
(void)memset(vcpu->arch_vcpu.vmcs, 0, CPU_PAGE_SIZE);
286+
(void)memset(vcpu->arch_vcpu.vmcs, 0U, CPU_PAGE_SIZE);
287287

288288
vlapic = vcpu->arch_vcpu.vlapic;
289289
vlapic_reset(vlapic);

hypervisor/arch/x86/io.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ void allow_guest_io_access(struct vm *vm, uint32_t address_arg, uint32_t nbytes)
407407
b = vm->arch_vm.iobitmap[1];
408408
}
409409
a = address & 0x7fffU;
410-
b[a >> 5] &= ~(1 << (a & 0x1fU));
410+
b[a >> 5U] &= ~(1U << (a & 0x1fU));
411411
address++;
412412
}
413413
}
@@ -437,7 +437,7 @@ static struct vm_io_handler *create_io_handler(uint32_t port, uint32_t len,
437437

438438
struct vm_io_handler *handler;
439439

440-
handler = calloc(1, sizeof(struct vm_io_handler));
440+
handler = calloc(1U, sizeof(struct vm_io_handler));
441441

442442
if (handler != NULL) {
443443
handler->desc.addr = port;
@@ -461,12 +461,12 @@ void setup_io_bitmap(struct vm *vm)
461461
(vm->arch_vm.iobitmap[1] != NULL), "");
462462

463463
if (is_vm0(vm)) {
464-
(void)memset(vm->arch_vm.iobitmap[0], 0x00, CPU_PAGE_SIZE);
465-
(void)memset(vm->arch_vm.iobitmap[1], 0x00, CPU_PAGE_SIZE);
464+
(void)memset(vm->arch_vm.iobitmap[0], 0x00U, CPU_PAGE_SIZE);
465+
(void)memset(vm->arch_vm.iobitmap[1], 0x00U, CPU_PAGE_SIZE);
466466
} else {
467467
/* block all IO port access from Guest */
468-
(void)memset(vm->arch_vm.iobitmap[0], 0xFF, CPU_PAGE_SIZE);
469-
(void)memset(vm->arch_vm.iobitmap[1], 0xFF, CPU_PAGE_SIZE);
468+
(void)memset(vm->arch_vm.iobitmap[0], 0xFFU, CPU_PAGE_SIZE);
469+
(void)memset(vm->arch_vm.iobitmap[1], 0xFFU, CPU_PAGE_SIZE);
470470
}
471471
}
472472

@@ -498,7 +498,7 @@ int register_mmio_emulation_handler(struct vm *vm,
498498
int status = -EINVAL;
499499
struct mem_io_node *mmio_node;
500500

501-
if (vm->hw.created_vcpus > 0 && vm->hw.vcpu_array[0]->launched) {
501+
if (vm->hw.created_vcpus > 0U && vm->hw.vcpu_array[0]->launched) {
502502
ASSERT(false, "register mmio handler after vm launched");
503503
return status;
504504
}

hypervisor/arch/x86/trusty2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ void destroy_secure_world(struct vm *vm)
187187
if ((uint64_t)size < entry.page_size)
188188
adjust_size = size;
189189

190-
(void)memset(HPA2HVA(hpa), 0, adjust_size);
190+
(void)memset(HPA2HVA(hpa), 0U, adjust_size);
191191
/* restore memory to SOS ept mapping */
192192
map_params.pml4_base = vm0->arch_vm.nworld_eptp;
193193
map_params.pml4_inverted = vm0->arch_vm.m2p;

hypervisor/common/hypercall.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ int32_t hcall_sos_offline_cpu(struct vm *vm, uint64_t lapicid)
3838
foreach_vcpu(i, vm, vcpu) {
3939
if (vlapic_get_apicid(vcpu->arch_vcpu.vlapic) == lapicid) {
4040
/* should not offline BSP */
41-
if (vcpu->vcpu_id == 0)
41+
if (vcpu->vcpu_id == 0U)
4242
return -1;
4343
pause_vcpu(vcpu, VCPU_ZOMBIE);
4444
reset_vcpu(vcpu);

hypervisor/common/ptdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ alloc_entry(struct vm *vm, enum ptdev_intr_type type)
6868
struct ptdev_remapping_info *entry;
6969

7070
/* allocate */
71-
entry = calloc(1, sizeof(*entry));
71+
entry = calloc(1U, sizeof(*entry));
7272
ASSERT(entry != NULL, "alloc memory failed");
7373
entry->type = type;
7474
entry->vm = vm;

hypervisor/debug/logmsg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void do_logmsg(uint32_t severity, const char *fmt, ...)
113113
pcpu_id = get_cpu_id();
114114
buffer = per_cpu(logbuf, pcpu_id);
115115

116-
(void)memset(buffer, 0, LOG_MESSAGE_MAX_SIZE);
116+
(void)memset(buffer, 0U, LOG_MESSAGE_MAX_SIZE);
117117
/* Put time-stamp, CPU ID and severity into buffer */
118118
snprintf(buffer, LOG_MESSAGE_MAX_SIZE,
119119
"[%lluus][cpu=%hu][sev=%u][seq=%u]:",
@@ -197,7 +197,7 @@ void print_logmsg_buffer(uint16_t pcpu_id)
197197

198198
do {
199199
uint32_t idx;
200-
(void)memset(buffer, 0, LOG_ENTRY_SIZE + 1);
200+
(void)memset(buffer, 0U, LOG_ENTRY_SIZE + 1);
201201

202202
if (*sbuf == NULL) {
203203
return;

hypervisor/debug/printf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int vprintf(const char *fmt, va_list args)
4444
int nchars = 0;
4545

4646
/* initialize parameters */
47-
(void)memset(&param, 0, sizeof(param));
47+
(void)memset(&param, 0U, sizeof(param));
4848
param.emit = charout;
4949
param.data = &nchars;
5050

hypervisor/debug/sbuf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct shared_buf *sbuf_allocate(uint32_t ele_num, uint32_t ele_size)
5656
return NULL;
5757
}
5858

59-
sbuf = calloc(1, sbuf_allocate_size);
59+
sbuf = calloc(1U, sbuf_allocate_size);
6060
if (sbuf == NULL) {
6161
pr_err("%s no memory!", __func__);
6262
return NULL;

hypervisor/debug/shell.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ void shell_init(void)
450450
(void)strcpy_s((void *)p_shell->name, SHELL_NAME_MAX_LEN, "Serial");
451451

452452
/* Zero fill the input buffer */
453-
(void)memset((void *)p_shell->input_line[p_shell->input_line_active], 0,
453+
(void)memset((void *)p_shell->input_line[p_shell->input_line_active], 0U,
454454
SHELL_CMD_MAX_LEN + 1U);
455455
}
456456

@@ -1045,7 +1045,7 @@ int shell_show_vioapic_info(int argc, char **argv)
10451045

10461046
int shell_show_ioapic_info(__unused int argc, __unused char **argv)
10471047
{
1048-
char *temp_str = alloc_pages(2);
1048+
char *temp_str = alloc_pages(2U);
10491049

10501050
if (temp_str == NULL) {
10511051
return -ENOMEM;
@@ -1061,7 +1061,7 @@ int shell_show_ioapic_info(__unused int argc, __unused char **argv)
10611061

10621062
int shell_show_vmexit_profile(__unused int argc, __unused char **argv)
10631063
{
1064-
char *temp_str = alloc_pages(2);
1064+
char *temp_str = alloc_pages(2U);
10651065

10661066
if (temp_str == NULL) {
10671067
return -ENOMEM;

0 commit comments

Comments
 (0)