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>
This commit is contained in:
Yang, Yu-chu 2018-07-25 14:55:25 -07:00 committed by wenlingz
parent 6f1c5fa007
commit 2fbf70780e
22 changed files with 72 additions and 72 deletions

View File

@ -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) 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 */ /* 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; return true;
} else { } else {
return false; return false;
@ -210,7 +210,7 @@ static void ptdev_build_physical_msi(struct vm *vm, struct ptdev_msi_info *info,
/* get physical delivery mode */ /* get physical delivery mode */
delmode = info->vmsi_data & APIC_DELMODE_MASK; 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; delmode = APIC_DELMODE_LOWPRIO;
} }
@ -659,7 +659,7 @@ int ptdev_msix_remap(struct vm *vm, uint16_t virt_bdf,
} }
/* handle destroy case */ /* 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; info->pmsi_data = 0U;
ptdev_deactivate_entry(entry); ptdev_deactivate_entry(entry);
goto END; goto END;

View File

@ -87,7 +87,7 @@ static inline bool get_monitor_cap(void)
* in hypervisor, but still expose it to the guests and * in hypervisor, but still expose it to the guests and
* let them handle it correctly * 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; return true;
} }
} }

View File

@ -28,7 +28,7 @@ static inline struct vcpuid_entry *find_vcpuid_entry(struct vcpu *vcpu,
if (tmp->leaf < leaf) { if (tmp->leaf < leaf) {
continue; continue;
} else if (tmp->leaf == leaf) { } else if (tmp->leaf == leaf) {
if ((tmp->flags & CPUID_CHECK_SUBLEAF) != 0U && if (((tmp->flags & CPUID_CHECK_SUBLEAF) != 0U) &&
(tmp->subleaf != subleaf)) { (tmp->subleaf != subleaf)) {
continue; continue;
} }
@ -182,7 +182,7 @@ int set_vcpuid_entries(struct vm *vm)
for (i = 1U; i <= limit; i++) { for (i = 1U; i <= limit; i++) {
/* cpuid 1/0xb is percpu related */ /* cpuid 1/0xb is percpu related */
if (i == 1U || i == 0xbU) { if ((i == 1U) || (i == 0xbU)) {
continue; continue;
} }
@ -213,16 +213,16 @@ int set_vcpuid_entries(struct vm *vm)
case 0x04U: case 0x04U:
case 0x0dU: case 0x0dU:
for (j = 0U; ; j++) { for (j = 0U; ; j++) {
if (i == 0x0dU && j == 64U) { if ((i == 0x0dU) && (j == 64U)) {
break; break;
} }
init_vcpuid_entry(vm, i, j, init_vcpuid_entry(vm, i, j,
CPUID_CHECK_SUBLEAF, &entry); CPUID_CHECK_SUBLEAF, &entry);
if (i == 0x04U && entry.eax == 0U) { if ((i == 0x04U) && (entry.eax == 0U)) {
break; break;
} }
if (i == 0x0dU && entry.eax == 0U) { if ((i == 0x0dU) && (entry.eax == 0U)) {
continue; continue;
} }
result = set_vcpuid_entry(vm, &entry); result = set_vcpuid_entry(vm, &entry);
@ -281,7 +281,7 @@ void guest_cpuid(struct vcpu *vcpu,
uint32_t subleaf = *ecx; uint32_t subleaf = *ecx;
/* vm related */ /* vm related */
if (leaf != 0x1U && leaf != 0xbU && leaf != 0xdU) { if ((leaf != 0x1U) && (leaf != 0xbU) && (leaf != 0xdU)) {
struct vcpuid_entry *entry = struct vcpuid_entry *entry =
find_vcpuid_entry(vcpu, leaf, subleaf); find_vcpuid_entry(vcpu, leaf, subleaf);

View File

@ -21,8 +21,8 @@ static uint64_t find_next_table(uint32_t table_offset, void *table_base)
+ (table_offset * IA32E_COMM_ENTRY_SIZE)); + (table_offset * IA32E_COMM_ENTRY_SIZE));
/* If bit 7 is set, entry is not a subtable. */ /* If bit 7 is set, entry is not a subtable. */
if ((table_entry & IA32E_PDPTE_PS_BIT) != 0U if (((table_entry & IA32E_PDPTE_PS_BIT) != 0U)
|| (table_entry & IA32E_PDE_PS_BIT) != 0U) { || ((table_entry & IA32E_PDE_PS_BIT) != 0U)) {
return sub_table_addr; return sub_table_addr;
} }

View File

@ -490,7 +490,7 @@ void register_io_emulation_handler(struct vm *vm, struct vm_io_range *range,
{ {
struct vm_io_handler *handler = NULL; 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."); pr_err("Invalid IO handler.");
return; return;
} }
@ -512,7 +512,7 @@ int register_mmio_emulation_handler(struct vm *vm,
int status = -EINVAL; int status = -EINVAL;
struct mem_io_node *mmio_node; 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"); ASSERT(false, "register mmio handler after vm launched");
return status; return status;
} }

View File

@ -174,7 +174,7 @@ irq_desc_append_dev(struct irq_desc *desc, void *node, bool share)
if (desc->irq_handler == NULL) { if (desc->irq_handler == NULL) {
desc->irq_handler = common_handler_edge; 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 */ /* dev node added failed */
added = false; added = false;
} else { } else {
@ -259,8 +259,8 @@ common_register_handler(uint32_t irq_arg,
OUT: OUT:
if (added) { if (added) {
/* it is safe to call irq_desc_alloc_vector multiple times*/ /* it is safe to call irq_desc_alloc_vector multiple times*/
if (info->vector >= VECTOR_FIXED_START && if ((info->vector >= VECTOR_FIXED_START) &&
info->vector <= VECTOR_FIXED_END) { (info->vector <= VECTOR_FIXED_END)) {
irq_desc_set_vector(irq, info->vector); irq_desc_set_vector(irq, info->vector);
} else if (info->vector > NR_MAX_VECTOR) { } else if (info->vector > NR_MAX_VECTOR) {
irq_desc_alloc_vector(irq); irq_desc_alloc_vector(irq);
@ -324,7 +324,7 @@ void irq_desc_try_free_vector(uint32_t irq)
spinlock_rflags; spinlock_rflags;
/* legacy irq's vector is reserved and should not be freed */ /* 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; return;
} }
@ -419,7 +419,7 @@ void dispatch_interrupt(struct intr_excp_ctx *ctx)
goto ERR; 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 */ /* mask irq if possible */
goto ERR; goto ERR;
} }
@ -681,7 +681,7 @@ pri_register_handler(uint32_t irq,
{ {
struct irq_request_info info; 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; return NULL;
} }
@ -718,8 +718,8 @@ void get_cpu_interrupt_info(char *str_arg, int str_max)
for (irq = 0U; irq < NR_IRQS; irq++) { for (irq = 0U; irq < NR_IRQS; irq++) {
desc = &irq_desc_array[irq]; desc = &irq_desc_array[irq];
vector = irq_to_vector(irq); vector = irq_to_vector(irq);
if (desc->used != IRQ_NOT_ASSIGNED && if ((desc->used != IRQ_NOT_ASSIGNED) &&
vector != VECTOR_INVALID) { (vector != VECTOR_INVALID)) {
len = snprintf(str, size, "\r\n%d\t0x%X", irq, vector); len = snprintf(str, size, "\r\n%d\t0x%X", irq, vector);
size -= len; size -= len;
str += len; str += len;

View File

@ -235,7 +235,7 @@ static uint32_t map_mem_region(void *vaddr, void *paddr,
uint32_t table_offset; uint32_t table_offset;
uint32_t mapped_size; uint32_t mapped_size;
if (table_base == NULL || table_level >= IA32E_UNKNOWN) { if ((table_base == NULL) || (table_level >= IA32E_UNKNOWN)) {
/* Shouldn't go here */ /* Shouldn't go here */
ASSERT(false, "Incorrect Arguments. Failed to map region"); ASSERT(false, "Incorrect Arguments. Failed to map region");
return 0; 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 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 /* The PAT bit is set; Clear it and set the page table
* PAT bit instead * PAT bit instead
*/ */
@ -409,7 +409,7 @@ static int get_table_entry(void *addr, void *table_base,
{ {
uint32_t table_offset; uint32_t table_offset;
if (table_base == NULL || table_level >= IA32E_UNKNOWN) { if ((table_base == NULL) || (table_level >= IA32E_UNKNOWN)) {
ASSERT(false, "Incorrect Arguments"); ASSERT(false, "Incorrect Arguments");
return -EINVAL; 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; void *sub_table_addr = (table_level == IA32E_PT) ? table_base : NULL;
if (table_base == NULL || table_level >= IA32E_UNKNOWN if ((table_base == NULL) || (table_level >= IA32E_UNKNOWN)
|| map_params == NULL) { || (map_params == NULL)) {
ASSERT(false, "Incorrect Arguments"); ASSERT(false, "Incorrect Arguments");
return NULL; 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 /* Maybe need to recursive breaking in this case
* e.g. 1GB->2MB->4KB * 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(vaddr, page_size))
|| (!MEM_ALIGNED_CHECK(paddr, page_size))) { || (!MEM_ALIGNED_CHECK(paddr, page_size))) {
/* The breaking function return the page size /* The breaking function return the page size

View File

@ -17,7 +17,7 @@ static struct dev_handler_node *timer_node;
static void run_timer(struct hv_timer *timer) static void run_timer(struct hv_timer *timer)
{ {
/* deadline = 0 means stop timer, we should skip */ /* 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); timer->func(timer->priv_data);
} }
@ -78,7 +78,7 @@ int add_timer(struct hv_timer *timer)
uint16_t pcpu_id; uint16_t pcpu_id;
bool need_update; 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; return -EINVAL;
} }
@ -169,7 +169,7 @@ static void timer_softirq(uint16_t pcpu_id)
timer = list_entry(pos, struct hv_timer, node); timer = list_entry(pos, struct hv_timer, node);
/* timer expried */ /* timer expried */
tries--; tries--;
if (timer->fire_tsc <= current_tsc && tries > 0) { if ((timer->fire_tsc <= current_tsc) && (tries > 0)) {
del_timer(timer); del_timer(timer);
run_timer(timer); run_timer(timer);
@ -212,7 +212,7 @@ void timer_cleanup(void)
{ {
uint16_t pcpu_id = get_cpu_id(); 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); unregister_handler_common(timer_node);
timer_node = NULL; timer_node = NULL;
} }
@ -288,7 +288,7 @@ static uint64_t native_calibrate_tsc(void)
cpuid(0x15U, &eax_denominator, &ebx_numerator, cpuid(0x15U, &eax_denominator, &ebx_numerator,
&ecx_hz, &reserved); &ecx_hz, &reserved);
if (eax_denominator != 0U && ebx_numerator != 0U) { if ((eax_denominator != 0U) && (ebx_numerator != 0U)) {
return ((uint64_t) ecx_hz * return ((uint64_t) ecx_hz *
ebx_numerator) / eax_denominator; ebx_numerator) / eax_denominator;
} }

View File

@ -267,7 +267,7 @@ int cr_access_vmexit_handler(struct vcpu *vcpu)
uint64_t reg; uint64_t reg;
int idx = VM_EXIT_CR_ACCESS_REG_IDX(vcpu->arch_vcpu.exit_qualification); 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); reg = vcpu_get_gpreg(vcpu, idx);
switch ((VM_EXIT_CR_ACCESS_ACCESS_TYPE switch ((VM_EXIT_CR_ACCESS_ACCESS_TYPE

View File

@ -314,8 +314,8 @@ int vmx_wrmsr_pat(struct vcpu *vcpu, uint64_t value)
for (i = 0U; i < 8U; i++) { for (i = 0U; i < 8U; i++) {
field = (value >> (i * 8U)) & 0xffUL; field = (value >> (i * 8U)) & 0xffUL;
if ((PAT_MEM_TYPE_INVALID(field) || if (PAT_MEM_TYPE_INVALID(field) ||
(PAT_FIELD_RSV_BITS & field) != 0UL)) { ((PAT_FIELD_RSV_BITS & field) != 0UL)) {
pr_err("invalid guest IA32_PAT: 0x%016llx", value); pr_err("invalid guest IA32_PAT: 0x%016llx", value);
vcpu_inject_gp(vcpu, 0U); vcpu_inject_gp(vcpu, 0U);
return 0; return 0;

View File

@ -183,7 +183,7 @@ static void *get_acpi_tbl(const char *sig)
rsdp = (struct acpi_table_rsdp *)global_rsdp; 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 * AcpiOsGetRootPointer only verifies the checksum for
* the version 1.0 portion of the RSDP. Version 2.0 has * the version 1.0 portion of the RSDP. Version 2.0 has

View File

@ -55,7 +55,7 @@ static void parse_other_modules(struct vm *vm,
} }
end = start; end = start;
while (*end != ' ' && (*end) != '\0') { while (((*end) != ' ') && ((*end) != '\0')) {
end++; end++;
} }

View File

@ -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); struct vm *target_vm = get_vm_from_vmid(vmid);
/* make sure we have set req_buf */ /* 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__); pr_err("%s, invalid parameter\n", __func__);
return -EINVAL; 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.virt_bdf, irq.phys_bdf,
irq.is.intx.virt_pin, irq.is.intx.phys_pin, irq.is.intx.virt_pin, irq.is.intx.phys_pin,
irq.is.intx.pic_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, ret = ptdev_add_msix_remapping(target_vm,
irq.virt_bdf, irq.phys_bdf, irq.virt_bdf, irq.phys_bdf,
irq.is.msix.vector_cnt); 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, ptdev_remove_intx_remapping(target_vm,
irq.is.intx.virt_pin, irq.is.intx.virt_pin,
irq.is.intx.pic_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, ptdev_remove_msix_remapping(target_vm,
irq.virt_bdf, irq.virt_bdf,
irq.is.msix.vector_cnt); irq.is.msix.vector_cnt);

View File

@ -66,8 +66,8 @@ acrn_insert_request_wait(struct vcpu *vcpu, struct io_request *io_req)
"vhm_request page broken!"); "vhm_request page broken!");
if (vcpu == NULL || io_req == NULL || if ((vcpu == NULL) || (io_req == NULL) ||
vcpu->vm->sw.io_shared_page == NULL) { (vcpu->vm->sw.io_shared_page == NULL)) {
return -EINVAL; return -EINVAL;
} }

View File

@ -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("\r\n");
printf("Host Call Trace:\r\n"); printf("Host Call Trace:\r\n");
if (rsp > if ((rsp >
(uint64_t)&per_cpu(stack, pcpu_id)[CONFIG_STACK_SIZE - 1] (uint64_t)&per_cpu(stack, pcpu_id)[CONFIG_STACK_SIZE - 1])
|| rsp < (uint64_t)&per_cpu(stack, pcpu_id)[0]) { || (rsp < (uint64_t)&per_cpu(stack, pcpu_id)[0])) {
return; return;
} }

View File

@ -94,9 +94,9 @@ void do_logmsg(uint32_t severity, const char *fmt, ...)
char *buffer; char *buffer;
spinlock_rflags; spinlock_rflags;
do_console_log = ((logmsg.flags & LOG_FLAG_STDOUT) != 0U && do_console_log = (((logmsg.flags & LOG_FLAG_STDOUT) != 0U) &&
(severity <= console_loglevel)); (severity <= console_loglevel));
do_mem_log = ((logmsg.flags & LOG_FLAG_MEMORY) != 0U && do_mem_log = (((logmsg.flags & LOG_FLAG_MEMORY) != 0U) &&
(severity <= mem_loglevel)); (severity <= mem_loglevel));
if (!do_console_log && !do_mem_log) { if (!do_console_log && !do_mem_log) {

View File

@ -46,7 +46,7 @@ struct shared_buf *sbuf_allocate(uint32_t ele_num, uint32_t ele_size)
struct shared_buf *sbuf; struct shared_buf *sbuf;
uint32_t sbuf_allocate_size; 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__); pr_err("%s invalid parameter!", __func__);
return NULL; 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) 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__); pr_err("%s invalid parameter!", __func__);
return; 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) int sbuf_share_setup(uint16_t pcpu_id, uint32_t sbuf_id, uint64_t *hva)
{ {
if (pcpu_id >= phys_cpu_num || if ((pcpu_id >= phys_cpu_num) ||
sbuf_id >= ACRN_SBUF_ID_MAX) { (sbuf_id >= ACRN_SBUF_ID_MAX)) {
return -EINVAL; return -EINVAL;
} }

View File

@ -710,7 +710,7 @@ int shell_dumpmem(int argc, char **argv)
char temp_str[MAX_STR_SIZE]; char temp_str[MAX_STR_SIZE];
/* User input invalidation */ /* User input invalidation */
if (argc != 2 && argc != 3) { if ((argc != 2) && (argc != 3)) {
return -EINVAL; return -EINVAL;
} }

View File

@ -98,11 +98,11 @@ static int fifo_numchars(struct fifo *fifo)
*/ */
static uint8_t vuart_intr_reason(struct vuart *vu) 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; 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; 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; return IIR_TXRDY;
} else { } else {
return IIR_NOPEND; return IIR_NOPEND;

View File

@ -357,7 +357,7 @@ void *memcpy_s(void *d, size_t dmax, const void *s, size_t slen_arg)
uint8_t *src8; uint8_t *src8;
size_t slen = slen_arg; size_t slen = slen_arg;
if (slen == 0U || dmax == 0U || dmax < slen) { if ((slen == 0U) || (dmax == 0U) || (dmax < slen)) {
ASSERT(false); 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.*/ /*make sure 8bytes-aligned for at least one addr.*/
if ((!MEM_ALIGNED_CHECK(src8, 8)) && (!MEM_ALIGNED_CHECK(dest8, 8))) { 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;
dest8++; dest8++;
src8++; src8++;
@ -432,7 +432,7 @@ void *memset(void *base, uint8_t v, size_t n)
/*do the few bytes to get uint64_t alignment*/ /*do the few bytes to get uint64_t alignment*/
count = n; 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 = v;
dest_p++; dest_p++;
} }

View File

@ -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 /* calculate the number of additional characters to get the required
* width * width
*/ */
if (param->vars.width > 0U && param->vars.width > len) { if ((param->vars.width > 0U) && (param->vars.width > len)) {
w = 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 ? */ /* copy mode ? */
if (cmd == PRINT_CMD_COPY) { if (cmd == PRINT_CMD_COPY) {
if (sz > 0U) { if (sz > 0U) {
while (((*s) != '\0') && n < sz) { while (((*s) != '\0') && (n < sz)) {
if (n < (param->sz - param->wrtn)) { if (n < (param->sz - param->wrtn)) {
*p = *s; *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; int32_t sz = sz_arg;
int res = 0; int res = 0;
if (sz == 0U || (dst == NULL)) { if ((sz == 0U) || (dst == NULL)) {
return -1; return -1;
} }

View File

@ -64,10 +64,10 @@ long strtol_deci(const char *nptr)
acc = 0UL; acc = 0UL;
any = 0; any = 0;
while (c >= '0' && c <= '9') { while ((c >= '0') && (c <= '9')) {
c -= '0'; c -= '0';
if ((acc > cutoff) || if ((acc > cutoff) ||
(acc == cutoff && (uint64_t)c > cutlim)) { ((acc == cutoff) && ((uint64_t)c > cutlim))) {
any = -1; any = -1;
break; break;
} else { } else {
@ -109,7 +109,7 @@ uint64_t strtoul_hex(const char *nptr)
s++; s++;
} while (ISSPACE(c)); } while (ISSPACE(c));
if (c == '0' && (*s == 'x' || *s == 'X')) { if ((c == '0') && ((*s == 'x') || (*s == 'X'))) {
c = s[1]; c = s[1];
s += 2; s += 2;
} }
@ -119,18 +119,18 @@ uint64_t strtoul_hex(const char *nptr)
acc = 0UL; acc = 0UL;
any = 0; any = 0;
do { do {
if (c >= '0' && c <= '9') { if ((c >= '0') && (c <= '9')) {
c -= '0'; c -= '0';
} else if (c >= 'A' && c <= 'F') { } else if ((c >= 'A') && (c <= 'F')) {
c -= 'A' - 10; c -= 'A' - 10;
} else if (c >= 'a' && c <= 'f') { } else if ((c >= 'a') && (c <= 'f')) {
c -= 'a' - 10; c -= 'a' - 10;
} else { } else {
break; break;
} }
if ((acc > cutoff) || if ((acc > cutoff) ||
(acc == cutoff && (uint64_t)c > cutlim)) { ((acc == cutoff) && ((uint64_t)c > cutlim))) {
any = -1; any = -1;
break; break;
} else { } else {
@ -193,7 +193,7 @@ char *strcpy_s(char *d_arg, size_t dmax, const char *s_arg)
size_t dest_avail; size_t dest_avail;
uint64_t overlap_guard; 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__); pr_err("%s: invalid src, dest buffer or length.", __func__);
return NULL; 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; uint64_t overlap_guard;
size_t slen = slen_arg; size_t slen = slen_arg;
if (d == NULL || s == NULL) { if ((d == NULL) || (s == NULL)) {
pr_err("%s: invlaid src or dest buffer", __func__); pr_err("%s: invlaid src or dest buffer", __func__);
return NULL; return NULL;
} }
if (dmax == 0U || slen == 0U) { if ((dmax == 0U) || (slen == 0U)) {
pr_err("%s: invlaid length of src or dest buffer", __func__); pr_err("%s: invlaid length of src or dest buffer", __func__);
return NULL; return NULL;
} }