HV: Fix missing brackets for MISRA C Violations

Patch 6 of 7.
Added changes to make sure Misra C violations are fixed
for rules 11S and 12S.

Signed-off-by: Arindam Roy <arindam.roy@intel.com>
This commit is contained in:
Arindam Roy 2018-07-12 15:02:55 -07:00 committed by wenlingz
parent 4aa6cdacf7
commit af806a93bd
17 changed files with 200 additions and 111 deletions

View File

@ -64,8 +64,9 @@ int32_t acrn_insert_request_wait(struct vcpu *vcpu, struct vhm_request *req)
"vhm_request page broken!");
if (vcpu == NULL || req == NULL || vcpu->vm->sw.io_shared_page == NULL)
if (vcpu == NULL || req == NULL || vcpu->vm->sw.io_shared_page == NULL) {
return -EINVAL;
}
req_buf = (union vhm_request_buffer *)(vcpu->vm->sw.io_shared_page);
@ -108,20 +109,22 @@ static void _get_req_info_(struct vhm_request *req, int *id, char *type,
switch (req->type) {
case REQ_PORTIO:
(void)strcpy_s(type, 16, "PORTIO");
if (req->reqs.pio_request.direction == REQUEST_READ)
if (req->reqs.pio_request.direction == REQUEST_READ) {
(void)strcpy_s(dir, 16, "READ");
else
} else {
(void)strcpy_s(dir, 16, "WRITE");
}
*addr = req->reqs.pio_request.address;
*val = req->reqs.pio_request.value;
break;
case REQ_MMIO:
case REQ_WP:
(void)strcpy_s(type, 16, "MMIO/WP");
if (req->reqs.mmio_request.direction == REQUEST_READ)
if (req->reqs.mmio_request.direction == REQUEST_READ) {
(void)strcpy_s(dir, 16, "READ");
else
} else {
(void)strcpy_s(dir, 16, "WRITE");
}
*addr = req->reqs.mmio_request.address;
*val = req->reqs.mmio_request.value;
break;

View File

@ -37,8 +37,9 @@ uint16_t allocate_pcpu(void)
uint16_t i;
for (i = 0U; i < phys_cpu_num; i++) {
if (bitmap_test_and_set(i, &pcpu_used_bitmap) == 0)
if (bitmap_test_and_set(i, &pcpu_used_bitmap) == 0) {
return i;
}
}
return INVALID_CPU_ID;
@ -59,9 +60,10 @@ void add_vcpu_to_runqueue(struct vcpu *vcpu)
int pcpu_id = vcpu->pcpu_id;
spinlock_obtain(&per_cpu(sched_ctx, pcpu_id).runqueue_lock);
if (list_empty(&vcpu->run_list))
if (list_empty(&vcpu->run_list)) {
list_add_tail(&vcpu->run_list,
&per_cpu(sched_ctx, pcpu_id).runqueue);
}
spinlock_release(&per_cpu(sched_ctx, pcpu_id).runqueue_lock);
}
@ -104,8 +106,9 @@ int need_reschedule(uint16_t pcpu_id)
static void context_switch_out(struct vcpu *vcpu)
{
/* if it's idle thread, no action for switch out */
if (vcpu == NULL)
if (vcpu == NULL) {
return;
}
/* cancel event(int, gp, nmi and exception) injection */
cancel_event_injection(vcpu);
@ -124,8 +127,9 @@ static void context_switch_in(struct vcpu *vcpu)
get_cpu_var(sched_ctx).curr_vcpu = vcpu;
/* if it's idle thread, no action for switch out */
if (vcpu == NULL)
if (vcpu == NULL) {
return;
}
atomic_store(&vcpu->running, 1);
/* FIXME:
@ -154,12 +158,13 @@ void default_idle(void)
uint16_t pcpu_id = get_cpu_id();
while (1) {
if (need_reschedule(pcpu_id) != 0)
if (need_reschedule(pcpu_id) != 0) {
schedule();
else if (need_offline(pcpu_id) != 0)
} else if (need_offline(pcpu_id) != 0) {
cpu_dead(pcpu_id);
else
} else {
__asm __volatile("pause" ::: "memory");
}
}
}

View File

@ -55,8 +55,9 @@ int64_t hcall_initialize_trusty(struct vcpu *vcpu, uint64_t param)
return -EPERM;
}
if (!initialize_trusty(vcpu, param))
if (!initialize_trusty(vcpu, param)) {
return -ENODEV;
}
return 0;
}

View File

@ -23,8 +23,9 @@ static void print_char(char x)
{
serial_puts(serial_handle, &x, 1);
if (x == '\n')
if (x == '\n') {
serial_puts(serial_handle, "\r", 1);
}
}
int console_init(void)
@ -154,10 +155,12 @@ void console_dump_bytes(const void *p, unsigned int len)
/* print one row as ASCII characters (if possible) */
for (i = 0; i < 16; i++) {
if ((x[i] < ' ') || (x[i] >= 127))
if ((x[i] < ' ') || (x[i] >= 127)) {
console_putc('.');
else
}
else {
console_putc(x[i]);
}
}
/* continue with next row */
console_putc('\n');
@ -217,6 +220,7 @@ void console_setup_timer(void)
fire_tsc, TICK_MODE_PERIODIC, period_in_cycle);
/* Start an periodic timer */
if (add_timer(&console_timer) != 0)
if (add_timer(&console_timer) != 0) {
pr_err("Failed to add console kick timer");
}
}

View File

@ -27,14 +27,16 @@ static inline void alloc_earlylog_sbuf(uint16_t pcpu_id)
- SBUF_HEAD_SIZE) / ele_size;
per_cpu(earlylog_sbuf, pcpu_id) = sbuf_allocate(ele_num, ele_size);
if (per_cpu(earlylog_sbuf, pcpu_id) == NULL)
if (per_cpu(earlylog_sbuf, pcpu_id) == NULL) {
printf("failed to allcate sbuf for hvlog - %hu\n", pcpu_id);
}
}
static inline void free_earlylog_sbuf(uint16_t pcpu_id)
{
if (per_cpu(earlylog_sbuf, pcpu_id) == NULL)
if (per_cpu(earlylog_sbuf, pcpu_id) == NULL) {
return;
}
free(per_cpu(earlylog_sbuf, pcpu_id));
per_cpu(earlylog_sbuf, pcpu_id) = NULL;
@ -61,9 +63,10 @@ static int do_copy_earlylog(struct shared_buf *dst_sbuf,
(void)memcpy_s((void *)dst_sbuf, buf_size,
(void *)src_sbuf, valid_size);
if (dst_sbuf->tail != cur_tail)
if (dst_sbuf->tail != cur_tail) {
/* there is chance to lose new log from certain pcpu */
dst_sbuf->tail = cur_tail;
}
return 0;
}
@ -96,8 +99,9 @@ void do_logmsg(uint32_t severity, const char *fmt, ...)
do_mem_log = ((logmsg.flags & LOG_FLAG_MEMORY) != 0U &&
(severity <= mem_loglevel));
if (!do_console_log && !do_mem_log)
if (!do_console_log && !do_mem_log) {
return;
}
/* Get time-stamp value */
timestamp = rdtsc();
@ -170,34 +174,39 @@ void print_logmsg_buffer(uint16_t pcpu_id)
struct shared_buf **sbuf;
int is_earlylog = 0;
if (pcpu_id >= phys_cpu_num)
if (pcpu_id >= phys_cpu_num) {
return;
}
if (per_cpu(earlylog_sbuf, pcpu_id) != NULL) {
sbuf = &per_cpu(earlylog_sbuf, pcpu_id);
is_earlylog = 1;
} else
} else {
sbuf = (struct shared_buf **)
&per_cpu(sbuf, pcpu_id)[ACRN_HVLOG];
}
spinlock_irqsave_obtain(&(logmsg.lock));
if ((*sbuf) != NULL)
if ((*sbuf) != NULL) {
printf("CPU%hu: head: 0x%x, tail: 0x%x %s\n\r",
pcpu_id, (*sbuf)->head, (*sbuf)->tail,
(is_earlylog != 0) ? "[earlylog]" : "");
}
spinlock_irqrestore_release(&(logmsg.lock));
do {
uint32_t idx;
(void)memset(buffer, 0, LOG_ENTRY_SIZE + 1);
if (*sbuf == NULL)
if (*sbuf == NULL) {
return;
}
read_cnt = sbuf_get(*sbuf, (uint8_t *)buffer);
if (read_cnt <= 0)
if (read_cnt <= 0) {
return;
}
idx = (read_cnt < LOG_ENTRY_SIZE) ? read_cnt : LOG_ENTRY_SIZE;
buffer[idx] = '\0';

View File

@ -16,18 +16,16 @@ static int charout(int cmd, const char *s, int sz, void *hnd)
/* copy mode ? */
if (cmd == PRINT_CMD_COPY) {
/* copy all characters until NUL is found */
if (sz < 0)
if (sz < 0) {
s += console_puts(s);
/* copy 'sz' characters */
else
} else { /* copy 'sz' characters */
s += console_write(s, sz);
}
*nchars += (s - p);
return *nchars;
}
} else {
/* fill mode */
else {
*nchars += sz;
while (sz != 0) {
console_putc(*s);

View File

@ -51,8 +51,9 @@ struct shared_buf *sbuf_allocate(uint32_t ele_num, uint32_t ele_size)
}
sbuf_allocate_size = sbuf_calculate_allocate_size(ele_num, ele_size);
if (sbuf_allocate_size == 0U)
if (sbuf_allocate_size == 0U) {
return NULL;
}
sbuf = calloc(1, sbuf_allocate_size);
if (sbuf == NULL) {
@ -84,8 +85,9 @@ int sbuf_get(struct shared_buf *sbuf, uint8_t *data)
{
const void *from;
if ((sbuf == NULL) || (data == NULL))
if ((sbuf == NULL) || (data == NULL)) {
return -EINVAL;
}
if (sbuf_is_empty(sbuf)) {
/* no data available */
@ -125,8 +127,9 @@ int sbuf_put(struct shared_buf *sbuf, uint8_t *data)
uint32_t next_tail;
bool trigger_overwrite = false;
if ((sbuf == NULL) || (data == NULL))
if ((sbuf == NULL) || (data == NULL)) {
return -EINVAL;
}
next_tail = sbuf_next_ptr(sbuf->tail, sbuf->ele_size, sbuf->size);
/* if this write would trigger overrun */
@ -156,8 +159,9 @@ 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)
sbuf_id >= ACRN_SBUF_ID_MAX) {
return -EINVAL;
}
per_cpu(sbuf, pcpu_id)[sbuf_id] = hva;
pr_info("%s share sbuf for pCPU[%u] with sbuf_id[%u] setup successfully",

View File

@ -18,13 +18,15 @@ static struct uart *get_uart_by_id(const char *uart_id, uint32_t *index)
while (sio_ports[*index] != NULL) {
if (strncmp(sio_ports[*index]->tgt_uart->uart_id, uart_id,
strnlen_s(sio_ports[*index]->tgt_uart->uart_id,
SERIAL_ID_MAX_LENGTH)) == 0)
SERIAL_ID_MAX_LENGTH)) == 0) {
break;
}
/* No device is found if index reaches end of array. */
(*index)++;
if (*index == SERIAL_MAX_DEVS)
if (*index == SERIAL_MAX_DEVS) {
return NULL;
}
}
return sio_ports[*index];
@ -66,8 +68,9 @@ int serial_init(void)
status = sio_ports[index]->tgt_uart->
init(sio_ports[index]->tgt_uart);
if (status == 0)
if (status == 0) {
sio_initialized[index] = true;
}
} else {
status = -ENOMEM;
break;
@ -105,8 +108,9 @@ uint32_t serial_open(const char *uart_id)
/* Open the UART hardware with default configuration. */
status = uart->tgt_uart->open(uart->tgt_uart, &(uart->config));
if (status == 0)
if (status == 0) {
uart->open_flag = true;
}
}
/* Already open serial device */
@ -135,12 +139,14 @@ uint32_t serial_get_rx_data(uint32_t uart_handle)
return 0U;
index = SERIAL_DECODE_INDEX(uart_handle);
if (index >= SERIAL_MAX_DEVS)
if (index >= SERIAL_MAX_DEVS) {
return 0U;
}
uart = sio_ports[index];
if (uart == NULL)
if (uart == NULL) {
return 0U;
}
/* Place all the data available in RX FIFO, in circular buffer */
data_avail = uart->tgt_uart->rx_data_is_avail(
@ -192,18 +198,21 @@ int serial_getc(uint32_t uart_handle)
uint32_t index;
int status = SERIAL_DEV_NOT_FOUND;
if (!SERIAL_VALIDATE_HANDLE(uart_handle))
if (!SERIAL_VALIDATE_HANDLE(uart_handle)) {
goto exit;
}
index = SERIAL_DECODE_INDEX(uart_handle);
if (index >= SERIAL_MAX_DEVS)
if (index >= SERIAL_MAX_DEVS) {
goto exit;
}
port = sio_ports[index];
if (port == NULL)
if (port == NULL) {
goto exit;
}
/* First read a character from the circular buffer regardless of the
* read mode of UART port. If status is not CBUFFER_EMPTY, character
@ -235,15 +244,18 @@ int serial_gets(uint32_t uart_handle, char *buffer, uint32_t length)
uint32_t index;
int status = 0;
if ((buffer == NULL) || (length == 0U))
if ((buffer == NULL) || (length == 0U)) {
return 0;
}
if (!SERIAL_VALIDATE_HANDLE(uart_handle))
if (!SERIAL_VALIDATE_HANDLE(uart_handle)) {
return 0;
}
index = SERIAL_DECODE_INDEX(uart_handle);
if (index >= SERIAL_MAX_DEVS)
if (index >= SERIAL_MAX_DEVS) {
return 0;
}
port = sio_ports[index];
if ((port != NULL) && (port->open_flag == true)) {
@ -256,8 +268,9 @@ int serial_gets(uint32_t uart_handle, char *buffer, uint32_t length)
/* Restore interrupts to original level. */
spinlock_release(&port->buffer_lock);
if (status <= 0)
if (status <= 0) {
break;
}
/* Save character in buffer */
*data_read = (char) c;
@ -274,18 +287,21 @@ static int serial_putc(uint32_t uart_handle, int c)
struct uart *uart;
int busy;
if (!SERIAL_VALIDATE_HANDLE(uart_handle))
if (!SERIAL_VALIDATE_HANDLE(uart_handle)) {
return SERIAL_EOF;
}
index = SERIAL_DECODE_INDEX(uart_handle);
if (index >= SERIAL_MAX_DEVS)
if (index >= SERIAL_MAX_DEVS) {
return SERIAL_EOF;
}
uart = sio_ports[index];
if (uart == NULL)
if (uart == NULL) {
return SERIAL_EOF;
}
/* Wait for TX hardware to be ready */
do {
@ -306,21 +322,25 @@ int serial_puts(uint32_t uart_handle, const char *s, uint32_t length)
struct uart *port;
int retval = 0;
if ((s == NULL) || (length == 0U))
if ((s == NULL) || (length == 0U)) {
return 0;
}
if (!SERIAL_VALIDATE_HANDLE(uart_handle))
if (!SERIAL_VALIDATE_HANDLE(uart_handle)) {
return 0;
}
index = SERIAL_DECODE_INDEX(uart_handle);
if (index >= SERIAL_MAX_DEVS)
if (index >= SERIAL_MAX_DEVS) {
return 0;
}
port = sio_ports[index];
if (port == NULL)
if (port == NULL) {
return 0;
}
/*
* Grab the semaphore so that strings between threads do not

View File

@ -240,13 +240,15 @@ struct shell_cmd *shell_find_cmd(struct shell *p_shell, const char *cmd_str)
uint32_t i;
struct shell_cmd *p_cmd = NULL;
if (p_shell->cmd_count <= 0U)
if (p_shell->cmd_count <= 0U) {
return NULL;
}
for (i = 0U; i < p_shell->cmd_count; i++) {
p_cmd = &p_shell->shell_cmd[i];
if (strcmp(p_cmd->str, cmd_str) == 0)
if (strcmp(p_cmd->str, cmd_str) == 0) {
break;
}
}
if (i == p_shell->cmd_count) {
@ -274,9 +276,10 @@ void kick_shell(struct shell *p_shell)
if (vuart_console_active() == NULL) {
/* Prompt the user for a selection. */
if ((is_cmd_cmplt != 0U) &&
(p_shell->session_io.io_puts != NULL))
(p_shell->session_io.io_puts != NULL)) {
p_shell->session_io.io_puts(p_shell,
SHELL_PROMPT_STR);
}
/* Get user's input */
is_cmd_cmplt = shell_input_line(p_shell);
@ -284,9 +287,10 @@ void kick_shell(struct shell *p_shell)
/* If user has pressed the ENTER then process
* the command
*/
if (is_cmd_cmplt != 0U)
if (is_cmd_cmplt != 0U) {
/* Process current input line. */
status = shell_process(p_shell);
}
}
} else {
/* Serial port handle couldn't be obtained. Stop the shell
@ -795,8 +799,9 @@ int shell_vcpu_dumpmem(struct shell *p_shell,
gva = strtoul_hex(argv[3]);
if (argc == 5)
if (argc == 5) {
length = atoi(argv[4]);
}
if (length > MAX_MEMDUMP_LEN) {
shell_puts(p_shell, "over max length, round back\r\n");
@ -884,8 +889,9 @@ int shell_show_cpu_int(struct shell *p_shell,
{
char *temp_str = alloc_page();
if (temp_str == NULL)
if (temp_str == NULL) {
return -ENOMEM;
}
get_cpu_interrupt_info(temp_str, CPU_PAGE_SIZE);
shell_puts(p_shell, temp_str);
@ -900,8 +906,9 @@ int shell_show_ptdev_info(struct shell *p_shell,
{
char *temp_str = alloc_page();
if (temp_str == NULL)
if (temp_str == NULL) {
return -ENOMEM;
}
get_ptdev_info(temp_str, CPU_PAGE_SIZE);
shell_puts(p_shell, temp_str);
@ -922,8 +929,9 @@ int shell_show_req_info(struct shell *p_shell,
{
char *temp_str = alloc_page();
if (temp_str == NULL)
if (temp_str == NULL) {
return -ENOMEM;
}
get_req_info(temp_str, CPU_PAGE_SIZE);
shell_puts(p_shell, temp_str);
@ -938,15 +946,17 @@ int shell_show_vioapic_info(struct shell *p_shell, int argc, char **argv)
char *temp_str = alloc_page();
uint32_t vmid;
if (temp_str == NULL)
if (temp_str == NULL) {
return -ENOMEM;
}
/* User input invalidation */
if (argc != 2) {
snprintf(temp_str, CPU_PAGE_SIZE, "\r\nvmid param needed\r\n");
goto END;
} else
} else {
vmid = atoi(argv[1]);
}
get_vioapic_info(temp_str, CPU_PAGE_SIZE, vmid);
END:
@ -961,8 +971,9 @@ int shell_show_ioapic_info(struct shell *p_shell,
{
char *temp_str = alloc_pages(2);
if (temp_str == NULL)
if (temp_str == NULL) {
return -ENOMEM;
}
get_ioapic_info(temp_str, 2 * CPU_PAGE_SIZE);
shell_puts(p_shell, temp_str);
@ -977,8 +988,9 @@ int shell_show_vmexit_profile(struct shell *p_shell,
{
char *temp_str = alloc_pages(2);
if (temp_str == NULL)
if (temp_str == NULL) {
return -ENOMEM;
}
get_vmexit_profile(temp_str, 2*CPU_PAGE_SIZE);
shell_puts(p_shell, temp_str);
@ -997,8 +1009,9 @@ int shell_dump_logbuf(__unused struct shell *p_shell,
if (argc == 2) {
val = atoi(argv[1]);
if (val < 0)
if (val < 0) {
return status;
}
pcpu_id = (uint16_t)val;
print_logmsg_buffer(pcpu_id);
return 0;

View File

@ -138,8 +138,9 @@ int shell_init(void)
int status;
status = shell_construct(&serial_session);
if (status != 0)
if (status != 0) {
return status;
}
/* Set the function pointers for the shell i/p and o/p functions */
serial_session->session_io.io_init = shell_init_serial;
@ -201,8 +202,9 @@ int shell_switch_console(void)
struct vuart *vuart;
vuart = vuart_console_active();
if (vuart == NULL)
if (vuart == NULL) {
return -EINVAL;
}
vuart->active = false;
/* Output that switching to ACRN shell */

View File

@ -89,8 +89,9 @@ static int uart16550_calc_baud_div(__unused struct tgt_uart *tgt_uart,
{
uint32_t baud_multiplier = baud_rate < BAUD_460800 ? 16 : 13;
if (baud_rate == 0)
if (baud_rate == 0) {
baud_rate = BAUD_115200;
}
*baud_div_ptr = ref_freq / (baud_multiplier * baud_rate);
return 0;
@ -154,8 +155,9 @@ static int uart16550_open(struct tgt_uart *tgt_uart,
int status = 0;
if (strcmp(tgt_uart->uart_id, "STDIO") == 0) {
if (atomic_cmpxchg(&tgt_uart->open_count, 0, 1) != 0)
if (atomic_cmpxchg(&tgt_uart->open_count, 0, 1) != 0) {
return -EBUSY;
}
/* Call UART setup function */
/* Enable TX and RX FIFOs */
@ -221,16 +223,19 @@ static uint32_t uart16550_get_rx_err(uint32_t rx_data)
uint32_t rx_status = SD_RX_NO_ERROR;
/* Check for RX overrun error */
if ((rx_data & LSR_OE) != 0U)
if ((rx_data & LSR_OE) != 0U) {
rx_status |= SD_RX_OVERRUN_ERROR;
}
/* Check for RX parity error */
if ((rx_data & LSR_PE) != 0U)
if ((rx_data & LSR_PE) != 0U) {
rx_status |= SD_RX_PARITY_ERROR;
}
/* Check for RX frame error */
if ((rx_data & LSR_FE) != 0U)
if ((rx_data & LSR_FE) != 0U) {
rx_status |= SD_RX_FRAME_ERROR;
}
/* Return the rx status */
return rx_status;
@ -274,8 +279,9 @@ static void uart16550_write(struct tgt_uart *tgt_uart,
uart16550_write_reg(tgt_uart->base_address,
*(uint8_t *)buffer, THR_IDX);
if (bytes_written != NULL)
if (bytes_written != NULL) {
*bytes_written = 1;
}
}
static bool uart16550_tx_is_busy(struct tgt_uart *tgt_uart)

View File

@ -82,8 +82,9 @@ static char fifo_getchar(struct fifo *fifo)
fifo->rindex = (fifo->rindex + 1) % fifo->size;
fifo->num--;
return c;
} else
} else {
return -1;
}
}
static int fifo_numchars(struct fifo *fifo)
@ -100,14 +101,15 @@ static int fifo_numchars(struct fifo *fifo)
*/
static uint8_t uart_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
} else {
return IIR_NOPEND;
}
}
static void uart_init(struct vuart *vu)
@ -136,12 +138,14 @@ static void uart_toggle_intr(struct vuart *vu)
intr_reason = uart_intr_reason(vu);
if (intr_reason != IIR_NOPEND) {
if (vu->vm->vpic != NULL)
if (vu->vm->vpic != NULL) {
vpic_assert_irq(vu->vm, COM1_IRQ);
}
vioapic_assert_irq(vu->vm, COM1_IRQ);
if (vu->vm->vpic != NULL)
if (vu->vm->vpic != NULL) {
vpic_deassert_irq(vu->vm, COM1_IRQ);
}
vioapic_deassert_irq(vu->vm, COM1_IRQ);
}
@ -189,8 +193,9 @@ static void uart_write(__unused struct vm_io_handler *hdlr,
if ((value & FCR_FIFOE) == 0) {
vu->fcr = 0;
} else {
if ((value & FCR_RFR) != 0)
if ((value & FCR_RFR) != 0) {
fifo_reset(&vu->rxfifo);
}
vu->fcr = value &
(FCR_FIFOE | FCR_DMA | FCR_RX_MASK);
@ -262,8 +267,9 @@ static uint32_t uart_read(__unused struct vm_io_handler *hdlr,
/*
* Deal with side effects of reading the IIR register
*/
if (intr_reason == IIR_TXRDY)
if (intr_reason == IIR_TXRDY) {
vu->thre_int_pending = false;
}
iir |= intr_reason;
reg = iir;
break;
@ -277,10 +283,11 @@ static uint32_t uart_read(__unused struct vm_io_handler *hdlr,
/* Transmitter is always ready for more data */
vu->lsr |= LSR_TEMT | LSR_THRE;
/* Check for new receive data */
if (fifo_numchars(&vu->rxfifo) > 0)
if (fifo_numchars(&vu->rxfifo) > 0) {
vu->lsr |= LSR_DR;
else
} else {
vu->lsr &= ~LSR_DR;
}
reg = vu->lsr;
/* The LSR_OE bit is cleared on LSR read */
vu->lsr &= ~LSR_OE;
@ -318,8 +325,9 @@ void vuart_console_tx_chars(void)
struct vuart *vu;
vu = vuart_console_active();
if (vu == NULL)
if (vu == NULL) {
return;
}
vuart_lock(vu);
while (fifo_numchars(&vu->txfifo) > 0) {
@ -342,8 +350,9 @@ void vuart_console_rx_chars(uint32_t serial_handle)
}
vu = vuart_console_active();
if (vu == NULL)
if (vu == NULL) {
return;
}
vuart_lock(vu);
/* Get data from serial */
@ -377,8 +386,9 @@ struct vuart *vuart_console_active(void)
if ((vm != NULL) && (vm->vuart != NULL)) {
struct vuart *vu = vm->vuart;
if (vu->active)
if (vu->active) {
return vm->vuart;
}
}
return NULL;
}

View File

@ -63,20 +63,23 @@ static inline uint32_t io_read_long(uint16_t port)
static inline void io_write(uint32_t v, uint16_t addr, size_t sz)
{
if (sz == 1U)
if (sz == 1U) {
io_write_byte((uint8_t)v, addr);
else if (sz == 2U)
} else if (sz == 2U) {
io_write_word((uint16_t)v, addr);
else
} else {
io_write_long(v, addr);
}
}
static inline uint32_t io_read(uint16_t addr, size_t sz)
{
if (sz == 1U)
if (sz == 1U) {
return io_read_byte(addr);
if (sz == 2U)
}
if (sz == 2U) {
return io_read_word(addr);
}
return io_read_long(addr);
}

View File

@ -78,11 +78,13 @@ struct trace_entry {
static inline bool
trace_check(uint16_t cpu_id, __unused uint32_t evid)
{
if (cpu_id >= phys_cpu_num)
if (cpu_id >= phys_cpu_num) {
return false;
}
if (per_cpu(sbuf, cpu_id)[ACRN_TRACE] == NULL)
if (per_cpu(sbuf, cpu_id)[ACRN_TRACE] == NULL) {
return false;
}
return true;
}
@ -107,8 +109,9 @@ TRACE_2L(uint32_t evid, uint64_t e, uint64_t f)
struct trace_entry entry;
uint16_t cpu_id = get_cpu_id();
if (!trace_check(cpu_id, evid))
if (!trace_check(cpu_id, evid)) {
return;
}
entry.payload.fields_64.e = e;
entry.payload.fields_64.f = f;
@ -122,8 +125,9 @@ TRACE_4I(uint32_t evid, uint32_t a, uint32_t b, uint32_t c,
struct trace_entry entry;
uint16_t cpu_id = get_cpu_id();
if (!trace_check(cpu_id, evid))
if (!trace_check(cpu_id, evid)) {
return;
}
entry.payload.fields_32.a = a;
entry.payload.fields_32.b = b;
@ -139,8 +143,9 @@ TRACE_6C(uint32_t evid, uint8_t a1, uint8_t a2, uint8_t a3,
struct trace_entry entry;
uint16_t cpu_id = get_cpu_id();
if (!trace_check(cpu_id, evid))
if (!trace_check(cpu_id, evid)) {
return;
}
entry.payload.fields_8.a1 = a1;
entry.payload.fields_8.a2 = a2;
@ -162,8 +167,9 @@ TRACE_16STR(uint32_t evid, const char name[])
uint16_t cpu_id = get_cpu_id();
size_t len, i;
if (!trace_check(cpu_id, evid))
if (!trace_check(cpu_id, evid)) {
return;
}
entry.payload.fields_64.e = 0UL;
entry.payload.fields_64.f = 0UL;

View File

@ -66,8 +66,9 @@
static inline uint16_t fls32(uint32_t value)
{
uint32_t ret = 0U;
if (value == 0U)
if (value == 0U) {
return (INVALID_BIT_INDEX);
}
asm volatile("bsrl %1,%0"
: "=r" (ret)
: "rm" (value));
@ -77,8 +78,9 @@ static inline uint16_t fls32(uint32_t value)
static inline uint16_t fls64(uint64_t value)
{
uint64_t ret = 0UL;
if (value == 0UL)
if (value == 0UL) {
return (INVALID_BIT_INDEX);
}
asm volatile("bsrq %1,%0"
: "=r" (ret)
: "rm" (value));
@ -113,8 +115,9 @@ static inline uint16_t fls64(uint64_t value)
static inline uint16_t ffs64(uint64_t value)
{
uint64_t ret = 0UL;
if (value == 0UL)
if (value == 0UL) {
return (INVALID_BIT_INDEX);
}
asm volatile("bsfq %1,%0"
: "=r" (ret)
: "rm" (value));
@ -144,9 +147,9 @@ static inline uint16_t ffz64(uint64_t value)
*/
static inline uint16_t clz(uint32_t value)
{
if (value == 0U)
if (value == 0U) {
return 32U;
else{
} else {
return (31U - fls32(value));
}
}
@ -160,9 +163,9 @@ static inline uint16_t clz(uint32_t value)
*/
static inline uint16_t clz64(uint64_t value)
{
if (value == 0UL)
if (value == 0UL) {
return 64U;
else{
} else {
return (63U - fls64(value));
}
}

View File

@ -94,8 +94,9 @@ static inline void __list_splice(struct list_head *list,
static inline void list_splice(struct list_head *list, struct list_head *head)
{
if (!list_empty(list))
if (!list_empty(list)) {
__list_splice(list, head);
}
}
static inline void list_splice_init(struct list_head *list,

View File

@ -88,8 +88,9 @@ int udiv64(uint64_t dividend, uint64_t divisor, struct udiv_result *res)
/* simplified case: only 32 bit operands Note that the preconditions
* for do_udiv32() are fulfilled, since the tests were made above.
*/
if (((divisor >> 32UL) == 0UL) && ((dividend >> 32UL) == 0UL))
if (((divisor >> 32UL) == 0UL) && ((dividend >> 32UL) == 0UL)) {
return do_udiv32((uint32_t) dividend, (uint32_t) divisor, res);
}
/* dividend is always greater than or equal to the divisor. Neither
* divisor nor dividend are 0. Thus: * clz(dividend) and clz(divisor)