From 8c43ad54bfdb0d845535d7cd9985c9797206db60 Mon Sep 17 00:00:00 2001 From: Ying Liu Date: Tue, 10 Jul 2018 19:59:31 -0700 Subject: [PATCH] HV: add the missing brackets to loop body MISRA-C requires the use of brackets, even when there is only one statement in the loop body. Signed-off-by: Ying Liu Acked-by: Eddie Dong --- hypervisor/boot/sbl/multiboot.c | 6 ++++-- hypervisor/debug/console.c | 9 ++++++--- hypervisor/debug/logmsg.c | 3 ++- hypervisor/debug/serial.c | 3 ++- hypervisor/debug/shell_internal.c | 6 ++++-- hypervisor/debug/vuart.c | 3 ++- hypervisor/include/debug/trace.h | 3 ++- hypervisor/lib/sprintf.c | 3 ++- hypervisor/lib/string.c | 3 ++- hypervisor/lib/udelay.c | 4 ++-- 10 files changed, 28 insertions(+), 15 deletions(-) diff --git a/hypervisor/boot/sbl/multiboot.c b/hypervisor/boot/sbl/multiboot.c index d961cfac8..96d366445 100644 --- a/hypervisor/boot/sbl/multiboot.c +++ b/hypervisor/boot/sbl/multiboot.c @@ -38,12 +38,14 @@ static void parse_other_modules(struct vm *vm, dev_dbg(ACRN_DBG_BOOT, "cmd addr=0x%x, str=%s", mods[i].mm_string, start); - while (*start == ' ') + while (*start == ' ') { start++; + } end = start; - while (*end != ' ' && (*end) != 0) + while (*end != ' ' && (*end) != 0) { end++; + } type_len = end - start; if (strncmp("FIRMWARE", start, type_len) == 0) { diff --git a/hypervisor/debug/console.c b/hypervisor/debug/console.c index 3ecb4ada5..81689276a 100644 --- a/hypervisor/debug/console.c +++ b/hypervisor/debug/console.c @@ -67,8 +67,9 @@ int console_puts(const char *s) */ p = s; - while ((*p != 0) && *p != '\n') + while ((*p != 0) && *p != '\n') { ++p; + } /* write all characters up to p */ serial_puts(serial_handle, s, p - s); @@ -109,8 +110,9 @@ int console_write(const char *s, size_t len) /* search for '\n' or the end of the string */ p = s; - while ((p != e) && (*p != '\n')) + while ((p != e) && (*p != '\n')) { ++p; + } /* write all characters processed so far */ serial_puts(serial_handle, s, p - s); @@ -146,8 +148,9 @@ void console_dump_bytes(const void *p, unsigned int len) /* write the address of the first byte in the row */ printf("%08x: ", (uint64_t) x); /* print one row (16 bytes) as hexadecimal values */ - for (i = 0; i < 16; i++) + for (i = 0; i < 16; i++) { printf("%02x ", x[i]); + } /* print one row as ASCII characters (if possible) */ for (i = 0; i < 16; i++) { diff --git a/hypervisor/debug/logmsg.c b/hypervisor/debug/logmsg.c index 6796117a0..79ebbb9cb 100644 --- a/hypervisor/debug/logmsg.c +++ b/hypervisor/debug/logmsg.c @@ -76,8 +76,9 @@ void init_logmsg(__unused uint32_t mem_size, uint32_t flags) logmsg.seq = 0; /* allocate sbuf for log before sos booting */ - for (pcpu_id = 0U; pcpu_id < phys_cpu_num; pcpu_id++) + for (pcpu_id = 0U; pcpu_id < phys_cpu_num; pcpu_id++) { alloc_earlylog_sbuf(pcpu_id); + } } void do_logmsg(uint32_t severity, const char *fmt, ...) diff --git a/hypervisor/debug/serial.c b/hypervisor/debug/serial.c index b71e4cd3a..3b0c30d2d 100644 --- a/hypervisor/debug/serial.c +++ b/hypervisor/debug/serial.c @@ -332,8 +332,9 @@ int serial_puts(uint32_t uart_handle, const char *s, uint32_t length) * Loop through the string until desired length of bytes have * been written or SERIAL_EOF is returned. */ - for (; length > 0U && retval != SERIAL_EOF; s++, length--) + for (; length > 0U && retval != SERIAL_EOF; s++, length--) { retval = serial_putc(uart_handle, (int) *s); + } /* Allow other threads to use this service. */ spinlock_release(&port->tx_lock); diff --git a/hypervisor/debug/shell_internal.c b/hypervisor/debug/shell_internal.c index 7b4f954d8..765e72b2d 100644 --- a/hypervisor/debug/shell_internal.c +++ b/hypervisor/debug/shell_internal.c @@ -66,8 +66,9 @@ static int string_to_argv(char *argv_str, void *p_argv_mem, /* Move past the vector entry argument string (in the * argument string). */ - while ((*p_ch != ' ') && (*p_ch != ',') && (*p_ch != 0)) + while ((*p_ch != ' ') && (*p_ch != ',') && (*p_ch != 0)) { p_ch++; + } /* Count the argument just processed. */ argc++; @@ -80,8 +81,9 @@ static int string_to_argv(char *argv_str, void *p_argv_mem, *p_ch = 0; /* Remove all space in middile of cmdline */ p_ch++; - while (*p_ch == ' ') + while (*p_ch == ' ') { p_ch++; + } } } diff --git a/hypervisor/debug/vuart.c b/hypervisor/debug/vuart.c index 8299e4780..b32e3ea7e 100644 --- a/hypervisor/debug/vuart.c +++ b/hypervisor/debug/vuart.c @@ -322,8 +322,9 @@ void vuart_console_tx_chars(void) return; vuart_lock(vu); - while (fifo_numchars(&vu->txfifo) > 0) + while (fifo_numchars(&vu->txfifo) > 0) { printf("%c", fifo_getchar(&vu->txfifo)); + } vuart_unlock(vu); } diff --git a/hypervisor/include/debug/trace.h b/hypervisor/include/debug/trace.h index 7fb986744..580376ace 100644 --- a/hypervisor/include/debug/trace.h +++ b/hypervisor/include/debug/trace.h @@ -170,8 +170,9 @@ TRACE_16STR(uint32_t evid, const char name[]) len = strnlen_s(name, 20U); len = (len > 16U) ? 16U : len; - for (i = 0U; i < len; i++) + for (i = 0U; i < len; i++) { entry.payload.str[i] = name[i]; + } entry.payload.str[15] = 0; _trace_put(cpu_id, evid, 16U, &entry); diff --git a/hypervisor/lib/sprintf.c b/hypervisor/lib/sprintf.c index 3c087d07d..6aca43a34 100644 --- a/hypervisor/lib/sprintf.c +++ b/hypervisor/lib/sprintf.c @@ -469,8 +469,9 @@ int do_print(const char *fmt, struct print_param *param, /* mark the current position and search the next '%' */ start = fmt; - while (((*fmt) != 0) && (*fmt != '%')) + while (((*fmt) != 0) && (*fmt != '%')) { fmt++; + } /* * pass all characters until the next '%' to the emit function. diff --git a/hypervisor/lib/string.c b/hypervisor/lib/string.c index 140d74b01..93fa4adc3 100644 --- a/hypervisor/lib/string.c +++ b/hypervisor/lib/string.c @@ -150,8 +150,9 @@ int atoi(const char *str) char *strchr(const char *s, int ch) { - while ((*s != 0) && (*s != ch)) + while ((*s != 0) && (*s != ch)) { ++s; + } return ((*s) != 0) ? ((char *)s) : 0; } diff --git a/hypervisor/lib/udelay.c b/hypervisor/lib/udelay.c index 9ba1fa062..1f9214130 100644 --- a/hypervisor/lib/udelay.c +++ b/hypervisor/lib/udelay.c @@ -15,6 +15,6 @@ void udelay(uint32_t us) dest_tsc = rdtsc() + delta_tsc; /* Loop until time expired */ - while - (rdtsc() < dest_tsc); + while (rdtsc() < dest_tsc) { + } }