Skip to content

Commit e7aa00b

Browse files
yuchuyanglijinxia
authored andcommitted
HV: Avoiding the chained assignment
To follow the Misra C standard, doing one assignment per line to make code is clearly readable and reduces the confusion of its intetion or typo. Signed-off-by: Yang, Yu-chu <yu-chu.yang@intel.com>
1 parent cfca49d commit e7aa00b

File tree

6 files changed

+23
-11
lines changed

6 files changed

+23
-11
lines changed

hypervisor/arch/x86/cpuid.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ int set_vcpuid_entries(struct vm *vm)
164164
result = set_vcpuid_entry(vm, &entry);
165165
if (result != 0)
166166
return result;
167-
vm->vcpuid_level = limit = entry.eax;
167+
limit = entry.eax;
168+
vm->vcpuid_level = limit;
168169

169170
for (i = 1U; i <= limit; i++) {
170171
/* cpuid 1/0xb is percpu related */
@@ -235,7 +236,8 @@ int set_vcpuid_entries(struct vm *vm)
235236
if (result != 0)
236237
return result;
237238

238-
vm->vcpuid_xlevel = limit = entry.eax;
239+
limit = entry.eax;
240+
vm->vcpuid_xlevel = limit;
239241
for (i = 0x80000001U; i <= limit; i++) {
240242
init_vcpuid_entry(vm, i, 0U, 0U, &entry);
241243
result = set_vcpuid_entry(vm, &entry);

hypervisor/arch/x86/guest/ucode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ void acrn_update_ucode(struct vcpu *vcpu, uint64_t v)
4949
data_page_num =
5050
(data_size + CPU_PAGE_SIZE - 1) >> CPU_PAGE_SHIFT;
5151

52-
ptr = ucode_ptr = alloc_pages(data_page_num);
53-
if (ptr == NULL)
52+
ucode_ptr = alloc_pages(data_page_num);
53+
if (ucode_ptr == NULL)
5454
return;
5555

5656
err_code = 0U;
@@ -62,7 +62,7 @@ void acrn_update_ucode(struct vcpu *vcpu, uint64_t v)
6262
return;
6363

6464
msr_write(MSR_IA32_BIOS_UPDT_TRIG,
65-
(uint64_t)ptr + sizeof(struct ucode_header));
65+
(uint64_t)ucode_ptr + sizeof(struct ucode_header));
6666
get_microcode_version();
6767

6868
free(ucode_ptr);

hypervisor/arch/x86/guest/vioapic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,11 @@ vioapic_write(struct vioapic *vioapic, uint32_t addr, uint32_t data)
327327
else
328328
lshift = 0;
329329

330-
last = new = vioapic->rtbl[pin].reg;
330+
last = vioapic->rtbl[pin].reg;
331331

332332
data64 = (uint64_t)data << lshift;
333333
mask64 = (uint64_t)0xffffffff << lshift;
334-
new &= ~mask64 | RTBL_RO_BITS;
334+
new = last & (~mask64 | RTBL_RO_BITS);
335335
new |= data64 & ~RTBL_RO_BITS;
336336

337337
changed = last ^ new;

hypervisor/arch/x86/guest/vm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
101101
for (id = 0U; id < (size_t)(sizeof(long) * 8U); id++)
102102
if (!bitmap_test_and_set(id, &vmid_bitmap))
103103
break;
104-
vm->attr.id = vm->attr.boot_idx = id;
104+
vm->attr.id = id;
105+
vm->attr.boot_idx = id;
105106

106107
atomic_store(&vm->hw.created_vcpus, 0);
107108

hypervisor/arch/x86/vmx.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,12 +772,20 @@ static void init_guest_state(struct vcpu *vcpu)
772772
/***************************************************/
773773
data32_idx = 0x10;
774774
if (vcpu_mode == CPU_MODE_REAL) {
775-
es = ss = ds = fs = gs = data32_idx;
775+
es = data32_idx;
776+
ss = data32_idx;
777+
ds = data32_idx;
778+
fs = data32_idx;
779+
gs = data32_idx;
776780
limit = 0xffff;
777781

778782
} else if (vcpu_mode == CPU_MODE_PROTECTED) {
779783
/* Linear data segment in guest init gdt */
780-
es = ss = ds = fs = gs = 0x18;
784+
es = 0x18;
785+
ss = 0x18;
786+
ds = 0x18;
787+
fs = 0x18;
788+
gs = 0x18;
781789
limit = 0xffffffffU;
782790
} else if (vcpu_mode == CPU_MODE_64BIT) {
783791
asm volatile ("movw %%es, %%ax":"=a" (es));

hypervisor/common/io_request.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ static void _get_req_info_(struct vhm_request *req, int *id, char *type,
101101
char *state, char *dir, long *addr, long *val)
102102
{
103103
(void)strcpy_s(dir, 16, "NONE");
104-
*addr = *val = 0;
104+
*addr = 0;
105+
*val = 0;
105106
*id = req->client;
106107

107108
switch (req->type) {

0 commit comments

Comments
 (0)