Skip to content

Commit fd81655

Browse files
ying2liujren1
authored andcommitted
HV: add the missing brackets to loop body
MISRA-C requires the use of brackets, even when there is only one statement in the loop body. Signed-off-by: Ying Liu <ying2.liu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent df038fc commit fd81655

File tree

9 files changed

+42
-21
lines changed

9 files changed

+42
-21
lines changed

hypervisor/arch/x86/assign.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,9 @@ void ptdev_remove_msix_remapping(struct vm *vm, uint16_t virt_bdf,
898898
return;
899899
}
900900

901-
for (i = 0; i < vector_count; i++)
901+
for (i = 0; i < vector_count; i++) {
902902
remove_msix_remapping(vm, virt_bdf, i);
903+
}
903904
}
904905

905906
#ifdef HV_DEBUG

hypervisor/arch/x86/guest/vioapic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,9 @@ vioapic_reset(struct vioapic *vioapic)
542542

543543
/* Initialize all redirection entries to mask all interrupts */
544544
pincount = vioapic_pincount(vioapic->vm);
545-
for (pin = 0U; pin < pincount; pin++)
545+
for (pin = 0U; pin < pincount; pin++) {
546546
vioapic->rtbl[pin].reg = MASK_ALL_INTERRUPTS;
547+
}
547548
}
548549

549550
struct vioapic *

hypervisor/arch/x86/guest/vlapic.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,13 @@ dump_isrvec_stk(struct vlapic *vlapic)
679679
struct lapic_reg *isrptr;
680680

681681
isrptr = &vlapic->apic_page->isr[0];
682-
for (i = 0; i < 8; i++)
682+
for (i = 0; i < 8; i++) {
683683
printf("ISR%d 0x%08x\n", i, isrptr[i].val);
684+
}
684685

685-
for (i = 0; i <= vlapic->isrvec_stk_top; i++)
686+
for (i = 0; i <= vlapic->isrvec_stk_top; i++) {
686687
printf("isrvec_stk[%d] = %d\n", i, vlapic->isrvec_stk[i]);
688+
}
687689
}
688690

689691
/*
@@ -1511,11 +1513,13 @@ vlapic_reset(struct vlapic *vlapic)
15111513

15121514
vlapic->svr_last = lapic->svr;
15131515

1514-
for (i = 0; i < VLAPIC_MAXLVT_INDEX + 1; i++)
1516+
for (i = 0; i < VLAPIC_MAXLVT_INDEX + 1; i++) {
15151517
vlapic->lvt_last[i] = 0;
1518+
}
15161519

1517-
for (i = 0; i < ISRVEC_STK_SIZE; i++)
1520+
for (i = 0; i < ISRVEC_STK_SIZE; i++) {
15181521
vlapic->isrvec_stk[i] = 0;
1522+
}
15191523

15201524
vlapic->isrvec_stk_top = 0;
15211525
}
@@ -1555,8 +1559,9 @@ void vlapic_restore(struct vlapic *vlapic, struct lapic_regs *regs)
15551559
lapic->ppr = regs->ppr;
15561560
lapic->ldr = regs->ldr;
15571561
lapic->dfr = regs->dfr;
1558-
for (i = 0; i < 8; i++)
1562+
for (i = 0; i < 8; i++) {
15591563
lapic->tmr[i].val = regs->tmr[i].val;
1564+
}
15601565
lapic->svr = regs->svr;
15611566
vlapic_svr_write_handler(vlapic);
15621567
lapic->lvt[APIC_LVT_TIMER].val = regs->lvt[APIC_LVT_TIMER].val;
@@ -1687,8 +1692,9 @@ vlapic_reset_tmr(struct vlapic *vlapic)
16871692
dev_dbg(ACRN_DBG_LAPIC,
16881693
"vlapic resetting all vectors to edge-triggered");
16891694

1690-
for (vector = 0; vector <= 255; vector++)
1695+
for (vector = 0; vector <= 255; vector++) {
16911696
vlapic_set_tmr(vlapic, vector, false);
1697+
}
16921698

16931699
vcpu_make_request(vlapic->vcpu, ACRN_REQUEST_TMR_UPDATE);
16941700
}

hypervisor/arch/x86/guest/vm.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
9898
goto err1;
9999
}
100100

101-
for (id = 0U; id < (size_t)(sizeof(long) * 8U); id++)
101+
for (id = 0U; id < (size_t)(sizeof(long) * 8U); id++) {
102102
if (!bitmap_test_and_set(id, &vmid_bitmap))
103103
break;
104+
}
104105
vm->attr.id = id;
105106
vm->attr.boot_idx = id;
106107

@@ -271,17 +272,19 @@ void pause_vm(struct vm *vm)
271272

272273
vm->state = VM_PAUSED;
273274

274-
foreach_vcpu(i, vm, vcpu)
275+
foreach_vcpu(i, vm, vcpu) {
275276
pause_vcpu(vcpu, VCPU_ZOMBIE);
277+
}
276278
}
277279

278280
void resume_vm(struct vm *vm)
279281
{
280282
uint16_t i;
281283
struct vcpu *vcpu = NULL;
282284

283-
foreach_vcpu(i, vm, vcpu)
285+
foreach_vcpu(i, vm, vcpu) {
284286
resume_vcpu(vcpu);
287+
}
285288

286289
vm->state = VM_STARTED;
287290
}

hypervisor/arch/x86/guest/vmsr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ void init_msr_emulation(struct vcpu *vcpu)
9696

9797
msr_bitmap = vcpu->vm->arch_vm.msr_bitmap;
9898

99-
for (i = 0U; i < msrs_count; i++)
99+
for (i = 0U; i < msrs_count; i++) {
100100
enable_msr_interception(msr_bitmap, emulated_msrs[i]);
101+
}
101102

102103
enable_msr_interception(msr_bitmap, MSR_IA32_PERF_CTL);
103104

hypervisor/arch/x86/ioapic.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,10 @@ void suspend_ioapic(void)
421421

422422
addr = map_ioapic(get_ioapic_base(ioapic_id));
423423
nr_pins = ioapic_nr_pins(addr);
424-
for (ioapic_pin = 0U; ioapic_pin < nr_pins; ioapic_pin++)
424+
for (ioapic_pin = 0U; ioapic_pin < nr_pins; ioapic_pin++) {
425425
ioapic_get_rte_entry(addr, ioapic_pin,
426426
&saved_rte[ioapic_id][ioapic_pin]);
427+
}
427428
}
428429
}
429430

@@ -437,9 +438,10 @@ void resume_ioapic(void)
437438

438439
addr = map_ioapic(get_ioapic_base(ioapic_id));
439440
nr_pins = ioapic_nr_pins(addr);
440-
for (ioapic_pin = 0U; ioapic_pin < nr_pins; ioapic_pin++)
441+
for (ioapic_pin = 0U; ioapic_pin < nr_pins; ioapic_pin++) {
441442
ioapic_set_rte_entry(addr, ioapic_pin,
442443
&saved_rte[ioapic_id][ioapic_pin]);
444+
}
443445
}
444446
}
445447

hypervisor/arch/x86/irq.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ static void init_irq_desc(void)
3131
spinlock_init(&irq_desc_base[i].irq_lock);
3232
}
3333

34-
for (i = 0U; i <= NR_MAX_VECTOR; i++)
34+
for (i = 0U; i <= NR_MAX_VECTOR; i++) {
3535
vector_to_irq[i] = IRQ_INVALID;
36+
}
3637

3738
}
3839

@@ -151,8 +152,9 @@ static void _irq_desc_free_vector(uint32_t irq)
151152
if (vector_to_irq[vr] == irq)
152153
vector_to_irq[vr] = IRQ_INVALID;
153154

154-
for (pcpu_id = 0U; pcpu_id < phys_cpu_num; pcpu_id++)
155+
for (pcpu_id = 0U; pcpu_id < phys_cpu_num; pcpu_id++) {
155156
per_cpu(irq_count, pcpu_id)[irq] = 0UL;
157+
}
156158
}
157159

158160
static void disable_pic_irq(void)
@@ -188,8 +190,9 @@ irq_desc_append_dev(struct irq_desc *desc, void *node, bool share)
188190
added = false;
189191
} else {
190192
/* dev_list point to last valid node */
191-
while (dev_list->next != NULL)
193+
while (dev_list->next != NULL) {
192194
dev_list = dev_list->next;
195+
}
193196
/* add node */
194197
dev_list->next = node;
195198
}

hypervisor/arch/x86/vtd.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,9 @@ static void iommu_flush_cache(struct dmar_drhd_rt *dmar_uint,
235235
if (iommu_ecap_c(dmar_uint->ecap) != 0U)
236236
return;
237237

238-
for (i = 0U; i < size; i += CACHE_LINE_SIZE)
238+
for (i = 0U; i < size; i += CACHE_LINE_SIZE) {
239239
clflush((char *)p + i);
240+
}
240241
}
241242

242243
#if DBG_IOMMU
@@ -1157,10 +1158,11 @@ void suspend_iommu(void)
11571158
dmar_invalid_iotlb_global(dmar_unit);
11581159

11591160
/* save IOMMU fault register state */
1160-
for (i = 0U; i < IOMMU_FAULT_REGISTER_STATE_NUM; i++)
1161+
for (i = 0U; i < IOMMU_FAULT_REGISTER_STATE_NUM; i++) {
11611162
iommu_fault_state[iommu_idx][i] =
11621163
iommu_read32(dmar_unit, DMAR_FECTL_REG +
11631164
i * IOMMU_FAULT_REGISTER_STATE_NUM);
1165+
}
11641166
/* disable translation */
11651167
dmar_disable_translation(dmar_unit);
11661168

@@ -1197,10 +1199,11 @@ void resume_iommu(void)
11971199
dmar_invalid_iotlb_global(dmar_unit);
11981200

11991201
/* restore IOMMU fault register state */
1200-
for (i = 0U; i < IOMMU_FAULT_REGISTER_STATE_NUM; i++)
1202+
for (i = 0U; i < IOMMU_FAULT_REGISTER_STATE_NUM; i++) {
12011203
iommu_write32(dmar_unit, DMAR_FECTL_REG +
12021204
i * IOMMU_FAULT_REGISTER_STATE_NUM,
12031205
iommu_fault_state[iommu_idx][i]);
1206+
}
12041207
/* enable translation */
12051208
dmar_enable_translation(dmar_unit);
12061209

hypervisor/boot/acpi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ biosacpi_search_rsdp(char *base, int length)
118118
strnlen_s(ACPI_SIG_RSDP, 8)) == 0) {
119119
cp = (uint8_t *)rsdp;
120120
sum = NULL;
121-
for (idx = 0; idx < RSDP_CHECKSUM_LENGTH; idx++)
121+
for (idx = 0; idx < RSDP_CHECKSUM_LENGTH; idx++) {
122122
sum += *(cp + idx);
123+
}
123124

124125
if (sum != NULL)
125126
continue;

0 commit comments

Comments
 (0)