fix(console): typecast expressions to match data type
This corrects the MISRA violation C2012-10.4:
Both operands of an operator in which the usual arithmetic conversions
are performed shall have the same essential type category.
The condition is explicitly checked against 0U, appending 'U' and
typecasting for unsigned comparison.
Change-Id: I4276035b3e7a223e80712e023457662689a011a1
Signed-off-by: Nithin G <nithing@amd.com>
Signed-off-by: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com>
diff --git a/drivers/console/multi_console.c b/drivers/console/multi_console.c
index 5ecbaed..59a4a86 100644
--- a/drivers/console/multi_console.c
+++ b/drivers/console/multi_console.c
@@ -79,8 +79,8 @@
{
int ret;
- if ((c == '\n') &&
- ((console->flags & CONSOLE_FLAG_TRANSLATE_CRLF) != 0)) {
+ if ((c == (int)'\n') &&
+ ((console->flags & CONSOLE_FLAG_TRANSLATE_CRLF) != 0U)) {
ret = console->putc('\r', console);
if (ret < 0)
return ret;
diff --git a/include/drivers/console.h b/include/drivers/console.h
index fa4eb94..0de2c99 100644
--- a/include/drivers/console.h
+++ b/include/drivers/console.h
@@ -27,7 +27,7 @@
#define CONSOLE_FLAG_RUNTIME (U(1) << 1)
#define CONSOLE_FLAG_CRASH (U(1) << 2)
/* Bits 3 to 7 reserved for additional scopes in future expansion. */
-#define CONSOLE_FLAG_SCOPE_MASK ((U(1) << 8) - 1)
+#define CONSOLE_FLAG_SCOPE_MASK GENMASK(7, 0)
/* Bits 8 to 31 for non-scope use. */
#define CONSOLE_FLAG_TRANSLATE_CRLF (U(1) << 8)