From 9ded5e8d8be4a5f1f3219742c3790c13156378d8 Mon Sep 17 00:00:00 2001 From: Maheedhar Bollapalli Date: Thu, 25 Apr 2024 11:14:22 +0530 Subject: [PATCH] fix(console): add missing curly braces This corrects the MISRA violation C2012-15.6: The body of an iteration-statement or a selection-statement shall be a compound-statement. Enclosed statement body within the curly braces. Change-Id: If8e77b291380fa7d9d95cab5836235790404b620 Signed-off-by: Nithin G Signed-off-by: Maheedhar Bollapalli --- drivers/console/multi_console.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/console/multi_console.c b/drivers/console/multi_console.c index e962fff37..5ecbaed1d 100644 --- a/drivers/console/multi_console.c +++ b/drivers/console/multi_console.c @@ -22,8 +22,9 @@ int console_register(console_t *console) assert((console < stacks_start) || (console >= stacks_end)); /* Check that we won't make a circle in the list. */ - if (console_is_registered(console) == 1) + if (console_is_registered(console) == 1) { return 1; + } console->next = console_list; console_list = console; @@ -53,9 +54,11 @@ int console_is_registered(console_t *to_find) assert(to_find != NULL); - for (console = console_list; console != NULL; console = console->next) - if (console == to_find) + for (console = console_list; console != NULL; console = console->next) { + if (console == to_find) { return 1; + } + } return 0; } @@ -91,21 +94,24 @@ int console_putc(int c) int err = ERROR_NO_VALID_CONSOLE; console_t *console; - for (console = console_list; console != NULL; console = console->next) + for (console = console_list; console != NULL; console = console->next) { if ((console->flags & console_state) && (console->putc != NULL)) { int ret = do_putc(c, console); - if ((err == ERROR_NO_VALID_CONSOLE) || (ret < err)) + if ((err == ERROR_NO_VALID_CONSOLE) || (ret < err)) { err = ret; + } } + } return err; } int putchar(int c) { - if (console_putc(c) == 0) + if (console_putc(c) == 0) { return c; - else + } else { return EOF; + } } #if ENABLE_CONSOLE_GETC @@ -119,10 +125,12 @@ int console_getc(void) console = console->next) if ((console->flags & console_state) && (console->getc != NULL)) { int ret = console->getc(console); - if (ret >= 0) + if (ret >= 0) { return ret; - if (err != ERROR_NO_PENDING_CHAR) + } + if (err != ERROR_NO_PENDING_CHAR) { err = ret; + } } } while (err == ERROR_NO_PENDING_CHAR);