From 2fbf70780e4ca7851b849fc3f16e98e223ed21e2 Mon Sep 17 00:00:00 2001 From: "Yang, Yu-chu" Date: Wed, 25 Jul 2018 14:55:25 -0700 Subject: [PATCH] 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 Reviewed-by: Junjie Mao Acked-by: Anthony Xu --- hypervisor/arch/x86/assign.c | 6 +++--- hypervisor/arch/x86/cpu.c | 2 +- hypervisor/arch/x86/cpuid.c | 12 ++++++------ hypervisor/arch/x86/ept.c | 4 ++-- hypervisor/arch/x86/io.c | 4 ++-- hypervisor/arch/x86/irq.c | 16 ++++++++-------- hypervisor/arch/x86/mmu.c | 12 ++++++------ hypervisor/arch/x86/timer.c | 10 +++++----- hypervisor/arch/x86/vmexit.c | 2 +- hypervisor/arch/x86/vmx.c | 4 ++-- hypervisor/boot/acpi.c | 2 +- hypervisor/boot/sbl/multiboot.c | 2 +- hypervisor/common/hypercall.c | 6 +++--- hypervisor/common/io_request.c | 4 ++-- hypervisor/debug/dump.c | 6 +++--- hypervisor/debug/logmsg.c | 4 ++-- hypervisor/debug/sbuf.c | 8 ++++---- hypervisor/debug/shell.c | 2 +- hypervisor/debug/vuart.c | 6 +++--- hypervisor/lib/memory.c | 6 +++--- hypervisor/lib/sprintf.c | 6 +++--- hypervisor/lib/string.c | 20 ++++++++++---------- 22 files changed, 72 insertions(+), 72 deletions(-) diff --git a/hypervisor/arch/x86/assign.c b/hypervisor/arch/x86/assign.c index 89760ef1f..f5173f287 100644 --- a/hypervisor/arch/x86/assign.c +++ b/hypervisor/arch/x86/assign.c @@ -187,7 +187,7 @@ ptdev_update_irq_handler(struct vm *vm, struct ptdev_remapping_info *entry) static bool ptdev_hv_owned_intx(struct vm *vm, struct ptdev_intx_info *info) { /* vm0 pin 4 (uart) is owned by hypervisor under debug version */ - if (is_vm0(vm) && (vm->vuart != NULL) && info->virt_pin == 4U) { + if (is_vm0(vm) && (vm->vuart != NULL) && (info->virt_pin == 4U)) { return true; } else { return false; @@ -210,7 +210,7 @@ static void ptdev_build_physical_msi(struct vm *vm, struct ptdev_msi_info *info, /* get physical delivery mode */ delmode = info->vmsi_data & APIC_DELMODE_MASK; - if (delmode != APIC_DELMODE_FIXED && delmode != APIC_DELMODE_LOWPRIO) { + if ((delmode != APIC_DELMODE_FIXED) && (delmode != APIC_DELMODE_LOWPRIO)) { delmode = APIC_DELMODE_LOWPRIO; } @@ -659,7 +659,7 @@ int ptdev_msix_remap(struct vm *vm, uint16_t virt_bdf, } /* handle destroy case */ - if (is_entry_active(entry) && info->vmsi_data == 0U) { + if (is_entry_active(entry) && (info->vmsi_data == 0U)) { info->pmsi_data = 0U; ptdev_deactivate_entry(entry); goto END; diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 191c93974..1f3f22551 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -87,7 +87,7 @@ static inline bool get_monitor_cap(void) * in hypervisor, but still expose it to the guests and * let them handle it correctly */ - if (boot_cpu_data.family != 0x6U || boot_cpu_data.model != 0x5cU) { + if ((boot_cpu_data.family != 0x6U) || (boot_cpu_data.model != 0x5cU)) { return true; } } diff --git a/hypervisor/arch/x86/cpuid.c b/hypervisor/arch/x86/cpuid.c index 18ebfcc72..50be98a52 100644 --- a/hypervisor/arch/x86/cpuid.c +++ b/hypervisor/arch/x86/cpuid.c @@ -28,7 +28,7 @@ static inline struct vcpuid_entry *find_vcpuid_entry(struct vcpu *vcpu, if (tmp->leaf < leaf) { continue; } else if (tmp->leaf == leaf) { - if ((tmp->flags & CPUID_CHECK_SUBLEAF) != 0U && + if (((tmp->flags & CPUID_CHECK_SUBLEAF) != 0U) && (tmp->subleaf != subleaf)) { continue; } @@ -182,7 +182,7 @@ int set_vcpuid_entries(struct vm *vm) for (i = 1U; i <= limit; i++) { /* cpuid 1/0xb is percpu related */ - if (i == 1U || i == 0xbU) { + if ((i == 1U) || (i == 0xbU)) { continue; } @@ -213,16 +213,16 @@ int set_vcpuid_entries(struct vm *vm) case 0x04U: case 0x0dU: for (j = 0U; ; j++) { - if (i == 0x0dU && j == 64U) { + if ((i == 0x0dU) && (j == 64U)) { break; } init_vcpuid_entry(vm, i, j, CPUID_CHECK_SUBLEAF, &entry); - if (i == 0x04U && entry.eax == 0U) { + if ((i == 0x04U) && (entry.eax == 0U)) { break; } - if (i == 0x0dU && entry.eax == 0U) { + if ((i == 0x0dU) && (entry.eax == 0U)) { continue; } result = set_vcpuid_entry(vm, &entry); @@ -281,7 +281,7 @@ void guest_cpuid(struct vcpu *vcpu, uint32_t subleaf = *ecx; /* vm related */ - if (leaf != 0x1U && leaf != 0xbU && leaf != 0xdU) { + if ((leaf != 0x1U) && (leaf != 0xbU) && (leaf != 0xdU)) { struct vcpuid_entry *entry = find_vcpuid_entry(vcpu, leaf, subleaf); diff --git a/hypervisor/arch/x86/ept.c b/hypervisor/arch/x86/ept.c index ed1e2455a..5a8a360cb 100644 --- a/hypervisor/arch/x86/ept.c +++ b/hypervisor/arch/x86/ept.c @@ -21,8 +21,8 @@ static uint64_t find_next_table(uint32_t table_offset, void *table_base) + (table_offset * IA32E_COMM_ENTRY_SIZE)); /* If bit 7 is set, entry is not a subtable. */ - if ((table_entry & IA32E_PDPTE_PS_BIT) != 0U - || (table_entry & IA32E_PDE_PS_BIT) != 0U) { + if (((table_entry & IA32E_PDPTE_PS_BIT) != 0U) + || ((table_entry & IA32E_PDE_PS_BIT) != 0U)) { return sub_table_addr; } diff --git a/hypervisor/arch/x86/io.c b/hypervisor/arch/x86/io.c index f61b77851..e3be74c6d 100644 --- a/hypervisor/arch/x86/io.c +++ b/hypervisor/arch/x86/io.c @@ -490,7 +490,7 @@ void register_io_emulation_handler(struct vm *vm, struct vm_io_range *range, { struct vm_io_handler *handler = NULL; - if (io_read_fn_ptr == NULL || io_write_fn_ptr == NULL) { + if ((io_read_fn_ptr == NULL) || (io_write_fn_ptr == NULL)) { pr_err("Invalid IO handler."); return; } @@ -512,7 +512,7 @@ int register_mmio_emulation_handler(struct vm *vm, int status = -EINVAL; struct mem_io_node *mmio_node; - if (vm->hw.created_vcpus > 0U && vm->hw.vcpu_array[0]->launched) { + if ((vm->hw.created_vcpus > 0U) && vm->hw.vcpu_array[0]->launched) { ASSERT(false, "register mmio handler after vm launched"); return status; } diff --git a/hypervisor/arch/x86/irq.c b/hypervisor/arch/x86/irq.c index a0f38e89f..e844cc580 100644 --- a/hypervisor/arch/x86/irq.c +++ b/hypervisor/arch/x86/irq.c @@ -174,7 +174,7 @@ irq_desc_append_dev(struct irq_desc *desc, void *node, bool share) if (desc->irq_handler == NULL) { desc->irq_handler = common_handler_edge; } - } else if (!share || desc->used == IRQ_ASSIGNED_NOSHARE) { + } else if (!share || (desc->used == IRQ_ASSIGNED_NOSHARE)) { /* dev node added failed */ added = false; } else { @@ -259,8 +259,8 @@ common_register_handler(uint32_t irq_arg, OUT: if (added) { /* it is safe to call irq_desc_alloc_vector multiple times*/ - if (info->vector >= VECTOR_FIXED_START && - info->vector <= VECTOR_FIXED_END) { + if ((info->vector >= VECTOR_FIXED_START) && + (info->vector <= VECTOR_FIXED_END)) { irq_desc_set_vector(irq, info->vector); } else if (info->vector > NR_MAX_VECTOR) { irq_desc_alloc_vector(irq); @@ -324,7 +324,7 @@ void irq_desc_try_free_vector(uint32_t irq) spinlock_rflags; /* legacy irq's vector is reserved and should not be freed */ - if (irq >= NR_IRQS || irq < NR_LEGACY_IRQ) { + if ((irq >= NR_IRQS) || (irq < NR_LEGACY_IRQ)) { return; } @@ -419,7 +419,7 @@ void dispatch_interrupt(struct intr_excp_ctx *ctx) goto ERR; } - if (desc->used == IRQ_NOT_ASSIGNED || desc->irq_handler == NULL) { + if ((desc->used == IRQ_NOT_ASSIGNED) || (desc->irq_handler == NULL)) { /* mask irq if possible */ goto ERR; } @@ -681,7 +681,7 @@ pri_register_handler(uint32_t irq, { struct irq_request_info info; - if (vector < VECTOR_FIXED_START || vector > VECTOR_FIXED_END) { + if ((vector < VECTOR_FIXED_START) || (vector > VECTOR_FIXED_END)) { return NULL; } @@ -718,8 +718,8 @@ void get_cpu_interrupt_info(char *str_arg, int str_max) for (irq = 0U; irq < NR_IRQS; irq++) { desc = &irq_desc_array[irq]; vector = irq_to_vector(irq); - if (desc->used != IRQ_NOT_ASSIGNED && - vector != VECTOR_INVALID) { + if ((desc->used != IRQ_NOT_ASSIGNED) && + (vector != VECTOR_INVALID)) { len = snprintf(str, size, "\r\n%d\t0x%X", irq, vector); size -= len; str += len; diff --git a/hypervisor/arch/x86/mmu.c b/hypervisor/arch/x86/mmu.c index 957439557..41ac617fc 100644 --- a/hypervisor/arch/x86/mmu.c +++ b/hypervisor/arch/x86/mmu.c @@ -235,7 +235,7 @@ static uint32_t map_mem_region(void *vaddr, void *paddr, uint32_t table_offset; uint32_t mapped_size; - if (table_base == NULL || table_level >= IA32E_UNKNOWN) { + if ((table_base == NULL) || (table_level >= IA32E_UNKNOWN)) { /* Shouldn't go here */ ASSERT(false, "Incorrect Arguments. Failed to map region"); return 0; @@ -281,7 +281,7 @@ static uint32_t map_mem_region(void *vaddr, void *paddr, /* If not a EPT entry, see if the PAT bit is set for PDPT entry */ - if ((table_type == PTT_HOST) && (attr & IA32E_PDPTE_PAT_BIT) != 0U) { + if ((table_type == PTT_HOST) && ((attr & IA32E_PDPTE_PAT_BIT) != 0U)) { /* The PAT bit is set; Clear it and set the page table * PAT bit instead */ @@ -409,7 +409,7 @@ static int get_table_entry(void *addr, void *table_base, { uint32_t table_offset; - if (table_base == NULL || table_level >= IA32E_UNKNOWN) { + if ((table_base == NULL) || (table_level >= IA32E_UNKNOWN)) { ASSERT(false, "Incorrect Arguments"); return -EINVAL; } @@ -434,8 +434,8 @@ static void *walk_paging_struct(void *addr, void *table_base, */ void *sub_table_addr = (table_level == IA32E_PT) ? table_base : NULL; - if (table_base == NULL || table_level >= IA32E_UNKNOWN - || map_params == NULL) { + if ((table_base == NULL) || (table_level >= IA32E_UNKNOWN) + || (map_params == NULL)) { ASSERT(false, "Incorrect Arguments"); return NULL; } @@ -947,7 +947,7 @@ static int modify_paging(struct mem_map_params *map_params, void *paddr_arg, /* Maybe need to recursive breaking in this case * e.g. 1GB->2MB->4KB */ - while ((uint64_t)remaining_size < page_size + while (((uint64_t)remaining_size < page_size) || (!MEM_ALIGNED_CHECK(vaddr, page_size)) || (!MEM_ALIGNED_CHECK(paddr, page_size))) { /* The breaking function return the page size diff --git a/hypervisor/arch/x86/timer.c b/hypervisor/arch/x86/timer.c index cd88df754..fe15d7300 100644 --- a/hypervisor/arch/x86/timer.c +++ b/hypervisor/arch/x86/timer.c @@ -17,7 +17,7 @@ static struct dev_handler_node *timer_node; static void run_timer(struct hv_timer *timer) { /* deadline = 0 means stop timer, we should skip */ - if ((timer->func != NULL) && timer->fire_tsc != 0UL) { + if ((timer->func != NULL) && (timer->fire_tsc != 0UL)) { timer->func(timer->priv_data); } @@ -78,7 +78,7 @@ int add_timer(struct hv_timer *timer) uint16_t pcpu_id; bool need_update; - if (timer == NULL || timer->func == NULL || timer->fire_tsc == 0UL) { + if ((timer == NULL) || (timer->func == NULL) || (timer->fire_tsc == 0UL)) { return -EINVAL; } @@ -169,7 +169,7 @@ static void timer_softirq(uint16_t pcpu_id) timer = list_entry(pos, struct hv_timer, node); /* timer expried */ tries--; - if (timer->fire_tsc <= current_tsc && tries > 0) { + if ((timer->fire_tsc <= current_tsc) && (tries > 0)) { del_timer(timer); run_timer(timer); @@ -212,7 +212,7 @@ void timer_cleanup(void) { uint16_t pcpu_id = get_cpu_id(); - if (pcpu_id == BOOT_CPU_ID && timer_node != NULL) { + if ((pcpu_id == BOOT_CPU_ID) && (timer_node != NULL)) { unregister_handler_common(timer_node); timer_node = NULL; } @@ -288,7 +288,7 @@ static uint64_t native_calibrate_tsc(void) cpuid(0x15U, &eax_denominator, &ebx_numerator, &ecx_hz, &reserved); - if (eax_denominator != 0U && ebx_numerator != 0U) { + if ((eax_denominator != 0U) && (ebx_numerator != 0U)) { return ((uint64_t) ecx_hz * ebx_numerator) / eax_denominator; } diff --git a/hypervisor/arch/x86/vmexit.c b/hypervisor/arch/x86/vmexit.c index ac908d11e..d7c8e1ffc 100644 --- a/hypervisor/arch/x86/vmexit.c +++ b/hypervisor/arch/x86/vmexit.c @@ -267,7 +267,7 @@ int cr_access_vmexit_handler(struct vcpu *vcpu) uint64_t reg; int idx = VM_EXIT_CR_ACCESS_REG_IDX(vcpu->arch_vcpu.exit_qualification); - ASSERT(idx>=0 && idx<=15, "index out of range"); + ASSERT((idx>=0) && (idx<=15), "index out of range"); reg = vcpu_get_gpreg(vcpu, idx); switch ((VM_EXIT_CR_ACCESS_ACCESS_TYPE diff --git a/hypervisor/arch/x86/vmx.c b/hypervisor/arch/x86/vmx.c index 183d36065..35cf549f5 100644 --- a/hypervisor/arch/x86/vmx.c +++ b/hypervisor/arch/x86/vmx.c @@ -314,8 +314,8 @@ int vmx_wrmsr_pat(struct vcpu *vcpu, uint64_t value) for (i = 0U; i < 8U; i++) { field = (value >> (i * 8U)) & 0xffUL; - if ((PAT_MEM_TYPE_INVALID(field) || - (PAT_FIELD_RSV_BITS & field) != 0UL)) { + if (PAT_MEM_TYPE_INVALID(field) || + ((PAT_FIELD_RSV_BITS & field) != 0UL)) { pr_err("invalid guest IA32_PAT: 0x%016llx", value); vcpu_inject_gp(vcpu, 0U); return 0; diff --git a/hypervisor/boot/acpi.c b/hypervisor/boot/acpi.c index 389410eb9..ed2b3f907 100644 --- a/hypervisor/boot/acpi.c +++ b/hypervisor/boot/acpi.c @@ -183,7 +183,7 @@ static void *get_acpi_tbl(const char *sig) rsdp = (struct acpi_table_rsdp *)global_rsdp; - if (rsdp->revision >= 2 && (rsdp->xsdt_physical_address != 0U)) { + if ((rsdp->revision >= 2) && (rsdp->xsdt_physical_address != 0U)) { /* * AcpiOsGetRootPointer only verifies the checksum for * the version 1.0 portion of the RSDP. Version 2.0 has diff --git a/hypervisor/boot/sbl/multiboot.c b/hypervisor/boot/sbl/multiboot.c index 70c0258ba..63b3e4953 100644 --- a/hypervisor/boot/sbl/multiboot.c +++ b/hypervisor/boot/sbl/multiboot.c @@ -55,7 +55,7 @@ static void parse_other_modules(struct vm *vm, } end = start; - while (*end != ' ' && (*end) != '\0') { + while (((*end) != ' ') && ((*end) != '\0')) { end++; } diff --git a/hypervisor/common/hypercall.c b/hypervisor/common/hypercall.c index f8efb35cc..fd4bc2992 100644 --- a/hypervisor/common/hypercall.c +++ b/hypervisor/common/hypercall.c @@ -392,7 +392,7 @@ int32_t hcall_notify_ioreq_finish(uint16_t vmid, uint16_t vcpu_id) struct vm *target_vm = get_vm_from_vmid(vmid); /* make sure we have set req_buf */ - if ((target_vm == NULL) || target_vm->sw.io_shared_page == NULL) { + if ((target_vm == NULL) || (target_vm->sw.io_shared_page == NULL)) { pr_err("%s, invalid parameter\n", __func__); return -EINVAL; } @@ -742,7 +742,7 @@ int32_t hcall_set_ptdev_intr_info(struct vm *vm, uint16_t vmid, uint64_t param) irq.virt_bdf, irq.phys_bdf, irq.is.intx.virt_pin, irq.is.intx.phys_pin, irq.is.intx.pic_pin); - } else if (irq.type == IRQ_MSI || irq.type == IRQ_MSIX) { + } else if ((irq.type == IRQ_MSI) || (irq.type == IRQ_MSIX)) { ret = ptdev_add_msix_remapping(target_vm, irq.virt_bdf, irq.phys_bdf, irq.is.msix.vector_cnt); @@ -776,7 +776,7 @@ hcall_reset_ptdev_intr_info(struct vm *vm, uint16_t vmid, uint64_t param) ptdev_remove_intx_remapping(target_vm, irq.is.intx.virt_pin, irq.is.intx.pic_pin); - } else if (irq.type == IRQ_MSI || irq.type == IRQ_MSIX) { + } else if ((irq.type == IRQ_MSI) || (irq.type == IRQ_MSIX)) { ptdev_remove_msix_remapping(target_vm, irq.virt_bdf, irq.is.msix.vector_cnt); diff --git a/hypervisor/common/io_request.c b/hypervisor/common/io_request.c index 7897d6c43..fc02e52a4 100644 --- a/hypervisor/common/io_request.c +++ b/hypervisor/common/io_request.c @@ -66,8 +66,8 @@ acrn_insert_request_wait(struct vcpu *vcpu, struct io_request *io_req) "vhm_request page broken!"); - if (vcpu == NULL || io_req == NULL || - vcpu->vm->sw.io_shared_page == NULL) { + if ((vcpu == NULL) || (io_req == NULL) || + (vcpu->vm->sw.io_shared_page == NULL)) { return -EINVAL; } diff --git a/hypervisor/debug/dump.c b/hypervisor/debug/dump.c index 9a1a770f8..57114036e 100644 --- a/hypervisor/debug/dump.c +++ b/hypervisor/debug/dump.c @@ -189,9 +189,9 @@ static void show_host_call_trace(uint64_t rsp, uint64_t rbp_arg, uint16_t pcpu_i printf("\r\n"); printf("Host Call Trace:\r\n"); - if (rsp > - (uint64_t)&per_cpu(stack, pcpu_id)[CONFIG_STACK_SIZE - 1] - || rsp < (uint64_t)&per_cpu(stack, pcpu_id)[0]) { + if ((rsp > + (uint64_t)&per_cpu(stack, pcpu_id)[CONFIG_STACK_SIZE - 1]) + || (rsp < (uint64_t)&per_cpu(stack, pcpu_id)[0])) { return; } diff --git a/hypervisor/debug/logmsg.c b/hypervisor/debug/logmsg.c index 029171e90..eb43c5a15 100644 --- a/hypervisor/debug/logmsg.c +++ b/hypervisor/debug/logmsg.c @@ -94,9 +94,9 @@ void do_logmsg(uint32_t severity, const char *fmt, ...) char *buffer; spinlock_rflags; - do_console_log = ((logmsg.flags & LOG_FLAG_STDOUT) != 0U && + do_console_log = (((logmsg.flags & LOG_FLAG_STDOUT) != 0U) && (severity <= console_loglevel)); - do_mem_log = ((logmsg.flags & LOG_FLAG_MEMORY) != 0U && + do_mem_log = (((logmsg.flags & LOG_FLAG_MEMORY) != 0U) && (severity <= mem_loglevel)); if (!do_console_log && !do_mem_log) { diff --git a/hypervisor/debug/sbuf.c b/hypervisor/debug/sbuf.c index 08ac7769a..b33fc8f88 100644 --- a/hypervisor/debug/sbuf.c +++ b/hypervisor/debug/sbuf.c @@ -46,7 +46,7 @@ struct shared_buf *sbuf_allocate(uint32_t ele_num, uint32_t ele_size) struct shared_buf *sbuf; uint32_t sbuf_allocate_size; - if (ele_num == 0U || ele_size == 0U) { + if ((ele_num == 0U) || (ele_size == 0U)) { pr_err("%s invalid parameter!", __func__); return NULL; } @@ -73,7 +73,7 @@ struct shared_buf *sbuf_allocate(uint32_t ele_num, uint32_t ele_size) void sbuf_free(struct shared_buf *sbuf) { - if ((sbuf == NULL) || sbuf->magic != SBUF_MAGIC) { + if ((sbuf == NULL) || (sbuf->magic != SBUF_MAGIC)) { pr_err("%s invalid parameter!", __func__); return; } @@ -159,8 +159,8 @@ int sbuf_put(struct shared_buf *sbuf, uint8_t *data) int sbuf_share_setup(uint16_t pcpu_id, uint32_t sbuf_id, uint64_t *hva) { - if (pcpu_id >= phys_cpu_num || - sbuf_id >= ACRN_SBUF_ID_MAX) { + if ((pcpu_id >= phys_cpu_num) || + (sbuf_id >= ACRN_SBUF_ID_MAX)) { return -EINVAL; } diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index 5e1dbe6f8..c2a6738f0 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -710,7 +710,7 @@ int shell_dumpmem(int argc, char **argv) char temp_str[MAX_STR_SIZE]; /* User input invalidation */ - if (argc != 2 && argc != 3) { + if ((argc != 2) && (argc != 3)) { return -EINVAL; } diff --git a/hypervisor/debug/vuart.c b/hypervisor/debug/vuart.c index 5864851e8..57e26114c 100644 --- a/hypervisor/debug/vuart.c +++ b/hypervisor/debug/vuart.c @@ -98,11 +98,11 @@ static int fifo_numchars(struct fifo *fifo) */ static uint8_t vuart_intr_reason(struct vuart *vu) { - if ((vu->lsr & LSR_OE) != 0 && (vu->ier & IER_ELSI) != 0) { + if (((vu->lsr & LSR_OE) != 0) && ((vu->ier & IER_ELSI) != 0)) { return IIR_RLS; - } else if (fifo_numchars(&vu->rxfifo) > 0 && (vu->ier & IER_ERBFI) != 0) { + } else if ((fifo_numchars(&vu->rxfifo) > 0) && ((vu->ier & IER_ERBFI) != 0)) { return IIR_RXTOUT; - } else if (vu->thre_int_pending && (vu->ier & IER_ETBEI) != 0) { + } else if (vu->thre_int_pending && ((vu->ier & IER_ETBEI) != 0)) { return IIR_TXRDY; } else { return IIR_NOPEND; diff --git a/hypervisor/lib/memory.c b/hypervisor/lib/memory.c index cca770124..7cd63959f 100644 --- a/hypervisor/lib/memory.c +++ b/hypervisor/lib/memory.c @@ -357,7 +357,7 @@ void *memcpy_s(void *d, size_t dmax, const void *s, size_t slen_arg) uint8_t *src8; size_t slen = slen_arg; - if (slen == 0U || dmax == 0U || dmax < slen) { + if ((slen == 0U) || (dmax == 0U) || (dmax < slen)) { ASSERT(false); } @@ -388,7 +388,7 @@ void *memcpy_s(void *d, size_t dmax, const void *s, size_t slen_arg) /*make sure 8bytes-aligned for at least one addr.*/ if ((!MEM_ALIGNED_CHECK(src8, 8)) && (!MEM_ALIGNED_CHECK(dest8, 8))) { - for (; slen != 0U && (((uint64_t)src8) & 7UL) != 0UL; slen--) { + for (; (slen != 0U) && ((((uint64_t)src8) & 7UL) != 0UL); slen--) { *dest8 = *src8; dest8++; src8++; @@ -432,7 +432,7 @@ void *memset(void *base, uint8_t v, size_t n) /*do the few bytes to get uint64_t alignment*/ count = n; - for (; count != 0U && ((uint64_t)dest_p & 7UL) != 0UL; count--) { + for (; (count != 0U) && (((uint64_t)dest_p & 7UL) != 0UL); count--) { *dest_p = v; dest_p++; } diff --git a/hypervisor/lib/sprintf.c b/hypervisor/lib/sprintf.c index 13ece957c..5ccf7f46a 100644 --- a/hypervisor/lib/sprintf.c +++ b/hypervisor/lib/sprintf.c @@ -432,7 +432,7 @@ static int print_string(struct print_param *param, const char *s) /* calculate the number of additional characters to get the required * width */ - if (param->vars.width > 0U && param->vars.width > len) { + if ((param->vars.width > 0U) && (param->vars.width > len)) { w = param->vars.width - len; } @@ -634,7 +634,7 @@ static int charmem(int cmd, const char *s_arg, uint32_t sz, void *hnd) /* copy mode ? */ if (cmd == PRINT_CMD_COPY) { if (sz > 0U) { - while (((*s) != '\0') && n < sz) { + while (((*s) != '\0') && (n < sz)) { if (n < (param->sz - param->wrtn)) { *p = *s; } @@ -662,7 +662,7 @@ int vsnprintf(char *dst_arg, size_t sz_arg, const char *fmt, va_list args) int32_t sz = sz_arg; int res = 0; - if (sz == 0U || (dst == NULL)) { + if ((sz == 0U) || (dst == NULL)) { return -1; } diff --git a/hypervisor/lib/string.c b/hypervisor/lib/string.c index db4f1453d..13e7e4ec5 100644 --- a/hypervisor/lib/string.c +++ b/hypervisor/lib/string.c @@ -64,10 +64,10 @@ long strtol_deci(const char *nptr) acc = 0UL; any = 0; - while (c >= '0' && c <= '9') { + while ((c >= '0') && (c <= '9')) { c -= '0'; if ((acc > cutoff) || - (acc == cutoff && (uint64_t)c > cutlim)) { + ((acc == cutoff) && ((uint64_t)c > cutlim))) { any = -1; break; } else { @@ -109,7 +109,7 @@ uint64_t strtoul_hex(const char *nptr) s++; } while (ISSPACE(c)); - if (c == '0' && (*s == 'x' || *s == 'X')) { + if ((c == '0') && ((*s == 'x') || (*s == 'X'))) { c = s[1]; s += 2; } @@ -119,18 +119,18 @@ uint64_t strtoul_hex(const char *nptr) acc = 0UL; any = 0; do { - if (c >= '0' && c <= '9') { + if ((c >= '0') && (c <= '9')) { c -= '0'; - } else if (c >= 'A' && c <= 'F') { + } else if ((c >= 'A') && (c <= 'F')) { c -= 'A' - 10; - } else if (c >= 'a' && c <= 'f') { + } else if ((c >= 'a') && (c <= 'f')) { c -= 'a' - 10; } else { break; } if ((acc > cutoff) || - (acc == cutoff && (uint64_t)c > cutlim)) { + ((acc == cutoff) && ((uint64_t)c > cutlim))) { any = -1; break; } else { @@ -193,7 +193,7 @@ char *strcpy_s(char *d_arg, size_t dmax, const char *s_arg) size_t dest_avail; uint64_t overlap_guard; - if (s == NULL || d == NULL || dmax == 0U) { + if ((s == NULL) || (d == NULL) || (dmax == 0U)) { pr_err("%s: invalid src, dest buffer or length.", __func__); return NULL; } @@ -271,12 +271,12 @@ char *strncpy_s(char *d_arg, size_t dmax, const char *s_arg, size_t slen_arg) uint64_t overlap_guard; size_t slen = slen_arg; - if (d == NULL || s == NULL) { + if ((d == NULL) || (s == NULL)) { pr_err("%s: invlaid src or dest buffer", __func__); return NULL; } - if (dmax == 0U || slen == 0U) { + if ((dmax == 0U) || (slen == 0U)) { pr_err("%s: invlaid length of src or dest buffer", __func__); return NULL; }