Skip to content

Commit

Permalink
HV: add the missing brackets to loop body
Browse files Browse the repository at this point in the history
MISRA-C requires the use of brackets, even when there is only one
statement in the loop body.

Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
  • Loading branch information
ying2liu authored and jren1 committed Jul 12, 2018
1 parent fd81655 commit 8c43ad5
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 15 deletions.
6 changes: 4 additions & 2 deletions hypervisor/boot/sbl/multiboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 6 additions & 3 deletions hypervisor/debug/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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++) {
Expand Down
3 changes: 2 additions & 1 deletion hypervisor/debug/logmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...)
Expand Down
3 changes: 2 additions & 1 deletion hypervisor/debug/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions hypervisor/debug/shell_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand All @@ -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++;
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion hypervisor/debug/vuart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion hypervisor/include/debug/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion hypervisor/lib/sprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion hypervisor/lib/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions hypervisor/lib/udelay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}
}

0 comments on commit 8c43ad5

Please sign in to comment.