Skip to content

Commit 2fbf707

Browse files
yuchuyangwenlingz
authored andcommitted
HV: Logical conjunction needs brackets
The bracket is required when the level of precedence of the operators is less than 13. Add the bracket to logical conjunctions. The commit applys the rule to the files under Signed-off-by: Yang, Yu-chu <yu-chu.yang@intel.com> Reviewed-by: Junjie Mao <junjie.mao@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent 6f1c5fa commit 2fbf707

File tree

22 files changed

+72
-72
lines changed

22 files changed

+72
-72
lines changed

hypervisor/arch/x86/assign.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ ptdev_update_irq_handler(struct vm *vm, struct ptdev_remapping_info *entry)
187187
static bool ptdev_hv_owned_intx(struct vm *vm, struct ptdev_intx_info *info)
188188
{
189189
/* vm0 pin 4 (uart) is owned by hypervisor under debug version */
190-
if (is_vm0(vm) && (vm->vuart != NULL) && info->virt_pin == 4U) {
190+
if (is_vm0(vm) && (vm->vuart != NULL) && (info->virt_pin == 4U)) {
191191
return true;
192192
} else {
193193
return false;
@@ -210,7 +210,7 @@ static void ptdev_build_physical_msi(struct vm *vm, struct ptdev_msi_info *info,
210210

211211
/* get physical delivery mode */
212212
delmode = info->vmsi_data & APIC_DELMODE_MASK;
213-
if (delmode != APIC_DELMODE_FIXED && delmode != APIC_DELMODE_LOWPRIO) {
213+
if ((delmode != APIC_DELMODE_FIXED) && (delmode != APIC_DELMODE_LOWPRIO)) {
214214
delmode = APIC_DELMODE_LOWPRIO;
215215
}
216216

@@ -659,7 +659,7 @@ int ptdev_msix_remap(struct vm *vm, uint16_t virt_bdf,
659659
}
660660

661661
/* handle destroy case */
662-
if (is_entry_active(entry) && info->vmsi_data == 0U) {
662+
if (is_entry_active(entry) && (info->vmsi_data == 0U)) {
663663
info->pmsi_data = 0U;
664664
ptdev_deactivate_entry(entry);
665665
goto END;

hypervisor/arch/x86/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static inline bool get_monitor_cap(void)
8787
* in hypervisor, but still expose it to the guests and
8888
* let them handle it correctly
8989
*/
90-
if (boot_cpu_data.family != 0x6U || boot_cpu_data.model != 0x5cU) {
90+
if ((boot_cpu_data.family != 0x6U) || (boot_cpu_data.model != 0x5cU)) {
9191
return true;
9292
}
9393
}

hypervisor/arch/x86/cpuid.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static inline struct vcpuid_entry *find_vcpuid_entry(struct vcpu *vcpu,
2828
if (tmp->leaf < leaf) {
2929
continue;
3030
} else if (tmp->leaf == leaf) {
31-
if ((tmp->flags & CPUID_CHECK_SUBLEAF) != 0U &&
31+
if (((tmp->flags & CPUID_CHECK_SUBLEAF) != 0U) &&
3232
(tmp->subleaf != subleaf)) {
3333
continue;
3434
}
@@ -182,7 +182,7 @@ int set_vcpuid_entries(struct vm *vm)
182182

183183
for (i = 1U; i <= limit; i++) {
184184
/* cpuid 1/0xb is percpu related */
185-
if (i == 1U || i == 0xbU) {
185+
if ((i == 1U) || (i == 0xbU)) {
186186
continue;
187187
}
188188

@@ -213,16 +213,16 @@ int set_vcpuid_entries(struct vm *vm)
213213
case 0x04U:
214214
case 0x0dU:
215215
for (j = 0U; ; j++) {
216-
if (i == 0x0dU && j == 64U) {
216+
if ((i == 0x0dU) && (j == 64U)) {
217217
break;
218218
}
219219

220220
init_vcpuid_entry(vm, i, j,
221221
CPUID_CHECK_SUBLEAF, &entry);
222-
if (i == 0x04U && entry.eax == 0U) {
222+
if ((i == 0x04U) && (entry.eax == 0U)) {
223223
break;
224224
}
225-
if (i == 0x0dU && entry.eax == 0U) {
225+
if ((i == 0x0dU) && (entry.eax == 0U)) {
226226
continue;
227227
}
228228
result = set_vcpuid_entry(vm, &entry);
@@ -281,7 +281,7 @@ void guest_cpuid(struct vcpu *vcpu,
281281
uint32_t subleaf = *ecx;
282282

283283
/* vm related */
284-
if (leaf != 0x1U && leaf != 0xbU && leaf != 0xdU) {
284+
if ((leaf != 0x1U) && (leaf != 0xbU) && (leaf != 0xdU)) {
285285
struct vcpuid_entry *entry =
286286
find_vcpuid_entry(vcpu, leaf, subleaf);
287287

hypervisor/arch/x86/ept.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ static uint64_t find_next_table(uint32_t table_offset, void *table_base)
2121
+ (table_offset * IA32E_COMM_ENTRY_SIZE));
2222

2323
/* If bit 7 is set, entry is not a subtable. */
24-
if ((table_entry & IA32E_PDPTE_PS_BIT) != 0U
25-
|| (table_entry & IA32E_PDE_PS_BIT) != 0U) {
24+
if (((table_entry & IA32E_PDPTE_PS_BIT) != 0U)
25+
|| ((table_entry & IA32E_PDE_PS_BIT) != 0U)) {
2626
return sub_table_addr;
2727
}
2828

hypervisor/arch/x86/io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ void register_io_emulation_handler(struct vm *vm, struct vm_io_range *range,
490490
{
491491
struct vm_io_handler *handler = NULL;
492492

493-
if (io_read_fn_ptr == NULL || io_write_fn_ptr == NULL) {
493+
if ((io_read_fn_ptr == NULL) || (io_write_fn_ptr == NULL)) {
494494
pr_err("Invalid IO handler.");
495495
return;
496496
}
@@ -512,7 +512,7 @@ int register_mmio_emulation_handler(struct vm *vm,
512512
int status = -EINVAL;
513513
struct mem_io_node *mmio_node;
514514

515-
if (vm->hw.created_vcpus > 0U && vm->hw.vcpu_array[0]->launched) {
515+
if ((vm->hw.created_vcpus > 0U) && vm->hw.vcpu_array[0]->launched) {
516516
ASSERT(false, "register mmio handler after vm launched");
517517
return status;
518518
}

hypervisor/arch/x86/irq.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ irq_desc_append_dev(struct irq_desc *desc, void *node, bool share)
174174
if (desc->irq_handler == NULL) {
175175
desc->irq_handler = common_handler_edge;
176176
}
177-
} else if (!share || desc->used == IRQ_ASSIGNED_NOSHARE) {
177+
} else if (!share || (desc->used == IRQ_ASSIGNED_NOSHARE)) {
178178
/* dev node added failed */
179179
added = false;
180180
} else {
@@ -259,8 +259,8 @@ common_register_handler(uint32_t irq_arg,
259259
OUT:
260260
if (added) {
261261
/* it is safe to call irq_desc_alloc_vector multiple times*/
262-
if (info->vector >= VECTOR_FIXED_START &&
263-
info->vector <= VECTOR_FIXED_END) {
262+
if ((info->vector >= VECTOR_FIXED_START) &&
263+
(info->vector <= VECTOR_FIXED_END)) {
264264
irq_desc_set_vector(irq, info->vector);
265265
} else if (info->vector > NR_MAX_VECTOR) {
266266
irq_desc_alloc_vector(irq);
@@ -324,7 +324,7 @@ void irq_desc_try_free_vector(uint32_t irq)
324324
spinlock_rflags;
325325

326326
/* legacy irq's vector is reserved and should not be freed */
327-
if (irq >= NR_IRQS || irq < NR_LEGACY_IRQ) {
327+
if ((irq >= NR_IRQS) || (irq < NR_LEGACY_IRQ)) {
328328
return;
329329
}
330330

@@ -419,7 +419,7 @@ void dispatch_interrupt(struct intr_excp_ctx *ctx)
419419
goto ERR;
420420
}
421421

422-
if (desc->used == IRQ_NOT_ASSIGNED || desc->irq_handler == NULL) {
422+
if ((desc->used == IRQ_NOT_ASSIGNED) || (desc->irq_handler == NULL)) {
423423
/* mask irq if possible */
424424
goto ERR;
425425
}
@@ -681,7 +681,7 @@ pri_register_handler(uint32_t irq,
681681
{
682682
struct irq_request_info info;
683683

684-
if (vector < VECTOR_FIXED_START || vector > VECTOR_FIXED_END) {
684+
if ((vector < VECTOR_FIXED_START) || (vector > VECTOR_FIXED_END)) {
685685
return NULL;
686686
}
687687

@@ -718,8 +718,8 @@ void get_cpu_interrupt_info(char *str_arg, int str_max)
718718
for (irq = 0U; irq < NR_IRQS; irq++) {
719719
desc = &irq_desc_array[irq];
720720
vector = irq_to_vector(irq);
721-
if (desc->used != IRQ_NOT_ASSIGNED &&
722-
vector != VECTOR_INVALID) {
721+
if ((desc->used != IRQ_NOT_ASSIGNED) &&
722+
(vector != VECTOR_INVALID)) {
723723
len = snprintf(str, size, "\r\n%d\t0x%X", irq, vector);
724724
size -= len;
725725
str += len;

hypervisor/arch/x86/mmu.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static uint32_t map_mem_region(void *vaddr, void *paddr,
235235
uint32_t table_offset;
236236
uint32_t mapped_size;
237237

238-
if (table_base == NULL || table_level >= IA32E_UNKNOWN) {
238+
if ((table_base == NULL) || (table_level >= IA32E_UNKNOWN)) {
239239
/* Shouldn't go here */
240240
ASSERT(false, "Incorrect Arguments. Failed to map region");
241241
return 0;
@@ -281,7 +281,7 @@ static uint32_t map_mem_region(void *vaddr, void *paddr,
281281

282282
/* If not a EPT entry, see if the PAT bit is set for PDPT entry
283283
*/
284-
if ((table_type == PTT_HOST) && (attr & IA32E_PDPTE_PAT_BIT) != 0U) {
284+
if ((table_type == PTT_HOST) && ((attr & IA32E_PDPTE_PAT_BIT) != 0U)) {
285285
/* The PAT bit is set; Clear it and set the page table
286286
* PAT bit instead
287287
*/
@@ -409,7 +409,7 @@ static int get_table_entry(void *addr, void *table_base,
409409
{
410410
uint32_t table_offset;
411411

412-
if (table_base == NULL || table_level >= IA32E_UNKNOWN) {
412+
if ((table_base == NULL) || (table_level >= IA32E_UNKNOWN)) {
413413
ASSERT(false, "Incorrect Arguments");
414414
return -EINVAL;
415415
}
@@ -434,8 +434,8 @@ static void *walk_paging_struct(void *addr, void *table_base,
434434
*/
435435
void *sub_table_addr = (table_level == IA32E_PT) ? table_base : NULL;
436436

437-
if (table_base == NULL || table_level >= IA32E_UNKNOWN
438-
|| map_params == NULL) {
437+
if ((table_base == NULL) || (table_level >= IA32E_UNKNOWN)
438+
|| (map_params == NULL)) {
439439
ASSERT(false, "Incorrect Arguments");
440440
return NULL;
441441
}
@@ -947,7 +947,7 @@ static int modify_paging(struct mem_map_params *map_params, void *paddr_arg,
947947
/* Maybe need to recursive breaking in this case
948948
* e.g. 1GB->2MB->4KB
949949
*/
950-
while ((uint64_t)remaining_size < page_size
950+
while (((uint64_t)remaining_size < page_size)
951951
|| (!MEM_ALIGNED_CHECK(vaddr, page_size))
952952
|| (!MEM_ALIGNED_CHECK(paddr, page_size))) {
953953
/* The breaking function return the page size

hypervisor/arch/x86/timer.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static struct dev_handler_node *timer_node;
1717
static void run_timer(struct hv_timer *timer)
1818
{
1919
/* deadline = 0 means stop timer, we should skip */
20-
if ((timer->func != NULL) && timer->fire_tsc != 0UL) {
20+
if ((timer->func != NULL) && (timer->fire_tsc != 0UL)) {
2121
timer->func(timer->priv_data);
2222
}
2323

@@ -78,7 +78,7 @@ int add_timer(struct hv_timer *timer)
7878
uint16_t pcpu_id;
7979
bool need_update;
8080

81-
if (timer == NULL || timer->func == NULL || timer->fire_tsc == 0UL) {
81+
if ((timer == NULL) || (timer->func == NULL) || (timer->fire_tsc == 0UL)) {
8282
return -EINVAL;
8383
}
8484

@@ -169,7 +169,7 @@ static void timer_softirq(uint16_t pcpu_id)
169169
timer = list_entry(pos, struct hv_timer, node);
170170
/* timer expried */
171171
tries--;
172-
if (timer->fire_tsc <= current_tsc && tries > 0) {
172+
if ((timer->fire_tsc <= current_tsc) && (tries > 0)) {
173173
del_timer(timer);
174174

175175
run_timer(timer);
@@ -212,7 +212,7 @@ void timer_cleanup(void)
212212
{
213213
uint16_t pcpu_id = get_cpu_id();
214214

215-
if (pcpu_id == BOOT_CPU_ID && timer_node != NULL) {
215+
if ((pcpu_id == BOOT_CPU_ID) && (timer_node != NULL)) {
216216
unregister_handler_common(timer_node);
217217
timer_node = NULL;
218218
}
@@ -288,7 +288,7 @@ static uint64_t native_calibrate_tsc(void)
288288
cpuid(0x15U, &eax_denominator, &ebx_numerator,
289289
&ecx_hz, &reserved);
290290

291-
if (eax_denominator != 0U && ebx_numerator != 0U) {
291+
if ((eax_denominator != 0U) && (ebx_numerator != 0U)) {
292292
return ((uint64_t) ecx_hz *
293293
ebx_numerator) / eax_denominator;
294294
}

hypervisor/arch/x86/vmexit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ int cr_access_vmexit_handler(struct vcpu *vcpu)
267267
uint64_t reg;
268268
int idx = VM_EXIT_CR_ACCESS_REG_IDX(vcpu->arch_vcpu.exit_qualification);
269269

270-
ASSERT(idx>=0 && idx<=15, "index out of range");
270+
ASSERT((idx>=0) && (idx<=15), "index out of range");
271271
reg = vcpu_get_gpreg(vcpu, idx);
272272

273273
switch ((VM_EXIT_CR_ACCESS_ACCESS_TYPE

hypervisor/arch/x86/vmx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ int vmx_wrmsr_pat(struct vcpu *vcpu, uint64_t value)
314314

315315
for (i = 0U; i < 8U; i++) {
316316
field = (value >> (i * 8U)) & 0xffUL;
317-
if ((PAT_MEM_TYPE_INVALID(field) ||
318-
(PAT_FIELD_RSV_BITS & field) != 0UL)) {
317+
if (PAT_MEM_TYPE_INVALID(field) ||
318+
((PAT_FIELD_RSV_BITS & field) != 0UL)) {
319319
pr_err("invalid guest IA32_PAT: 0x%016llx", value);
320320
vcpu_inject_gp(vcpu, 0U);
321321
return 0;

0 commit comments

Comments
 (0)