Skip to content

Commit d16d9e5

Browse files
rarindamwenlingz
authored andcommitted
HV: Fix missing brackets for MISRA C Violations
Patch 4 of 7. Added changes to make sure Misra C violations are fixed for rules 11S and 12S. Signed-off-by: Arindam Roy <arindam.roy@intel.com>
1 parent 82e0cdb commit d16d9e5

File tree

7 files changed

+229
-129
lines changed

7 files changed

+229
-129
lines changed

hypervisor/arch/x86/guest/vm.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
9999
}
100100

101101
for (id = 0U; id < (size_t)(sizeof(long) * 8U); id++) {
102-
if (!bitmap_test_and_set(id, &vmid_bitmap))
102+
if (!bitmap_test_and_set(id, &vmid_bitmap)) {
103103
break;
104+
}
104105
}
105106
vm->attr.id = id;
106107
vm->attr.boot_idx = id;
@@ -113,12 +114,14 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
113114
/* For UOS: This VM software information is configure in DM */
114115
if (is_vm0(vm)) {
115116
status = prepare_vm0_memmap_and_e820(vm);
116-
if (status != 0)
117+
if (status != 0) {
117118
goto err2;
119+
}
118120
#ifndef CONFIG_EFI_STUB
119121
status = init_vm0_boot_info(vm);
120-
if (status != 0)
122+
if (status != 0) {
121123
goto err2;
124+
}
122125
#endif
123126
} else {
124127
/* populate UOS vm fields according to vm_desc */
@@ -143,8 +146,9 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
143146

144147
if (is_vm0(vm)) {
145148
/* Load pm S state data */
146-
if (vm_load_pm_s_state(vm) == 0)
149+
if (vm_load_pm_s_state(vm) == 0) {
147150
register_pm1ab_handler(vm);
151+
}
148152

149153
/* Create virtual uart */
150154
vm->vuart = vuart_init(vm);
@@ -166,8 +170,9 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
166170
vm->sw.io_shared_page = NULL;
167171

168172
status = set_vcpuid_entries(vm);
169-
if (status != 0)
173+
if (status != 0) {
170174
goto err4;
175+
}
171176

172177
vm->state = VM_CREATED;
173178

@@ -190,14 +195,16 @@ int shutdown_vm(struct vm *vm)
190195
uint16_t i;
191196
struct vcpu *vcpu = NULL;
192197

193-
if (vm == NULL)
198+
if (vm == NULL) {
194199
return -EINVAL;
200+
}
195201

196202
pause_vm(vm);
197203

198204
/* Only allow shutdown paused vm */
199-
if (vm->state != VM_PAUSED)
205+
if (vm->state != VM_PAUSED) {
200206
return -EINVAL;
207+
}
201208

202209
foreach_vcpu(i, vm, vcpu) {
203210
reset_vcpu(vcpu);
@@ -226,13 +233,15 @@ int shutdown_vm(struct vm *vm)
226233
free_io_emulation_resource(vm);
227234

228235
/* Free iommu_domain */
229-
if (vm->iommu_domain != NULL)
236+
if (vm->iommu_domain != NULL) {
230237
destroy_iommu_domain(vm->iommu_domain);
238+
}
231239

232240
bitmap_clear(vm->attr.id, &vmid_bitmap);
233241

234-
if (vm->vpic != NULL)
242+
if (vm->vpic != NULL) {
235243
vpic_cleanup(vm);
244+
}
236245

237246
free(vm->hw.vcpu_array);
238247

@@ -267,8 +276,9 @@ void pause_vm(struct vm *vm)
267276
uint16_t i;
268277
struct vcpu *vcpu = NULL;
269278

270-
if (vm->state == VM_PAUSED)
279+
if (vm->state == VM_PAUSED) {
271280
return;
281+
}
272282

273283
vm->state = VM_PAUSED;
274284

@@ -320,14 +330,16 @@ int prepare_vm0(void)
320330
struct vm_description *vm_desc = &vm0_desc;
321331

322332
err = create_vm(vm_desc, &vm);
323-
if (err != 0)
333+
if (err != 0) {
324334
return err;
335+
}
325336

326337
/* Allocate all cpus to vm0 at the beginning */
327338
for (i = 0U; i < phys_cpu_num; i++) {
328339
err = prepare_vcpu(vm, i);
329-
if (err != 0)
340+
if (err != 0) {
330341
return err;
342+
}
331343
}
332344

333345
/* start vm0 BSP automatically */
@@ -344,8 +356,9 @@ static inline bool vcpu_in_vm_desc(struct vcpu *vcpu,
344356
int i;
345357

346358
for (i = 0; i < vm_desc->vm_hw_num_cores; i++) {
347-
if (vcpu->pcpu_id == vm_desc->vm_hw_logical_core_ids[i])
359+
if (vcpu->pcpu_id == vm_desc->vm_hw_logical_core_ids[i]) {
348360
return true;
361+
}
349362
}
350363

351364
return false;

hypervisor/arch/x86/guest/vmsr.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,10 @@ void init_msr_emulation(struct vcpu *vcpu)
131131
exec_vmwrite64(VMX_MSR_BITMAP_FULL, value64);
132132
pr_dbg("VMX_MSR_BITMAP: 0x%016llx ", value64);
133133

134-
if (!vcpu->guest_msrs)
134+
if (!vcpu->guest_msrs) {
135135
vcpu->guest_msrs =
136136
(uint64_t *)calloc(msrs_count, sizeof(uint64_t));
137+
}
137138

138139
ASSERT(vcpu->guest_msrs != NULL, "");
139140
(void)memset(vcpu->guest_msrs, 0U, msrs_count * sizeof(uint64_t));
@@ -313,8 +314,9 @@ int wrmsr_vmexit_handler(struct vcpu *vcpu)
313314
case MSR_IA32_BIOS_UPDT_TRIG:
314315
{
315316
/* We only allow SOS to do uCode update */
316-
if (is_vm0(vcpu->vm))
317+
if (is_vm0(vcpu->vm)) {
317318
acrn_update_ucode(vcpu, v);
319+
}
318320
break;
319321
}
320322
case MSR_IA32_PERF_CTL:

0 commit comments

Comments
 (0)