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>
This commit is contained in:
Nithin G 2024-04-23 17:54:08 +05:30 committed by Maheedhar Bollapalli
parent edecc70331
commit 97eefd9989
2 changed files with 3 additions and 3 deletions

View file

@ -79,8 +79,8 @@ static int do_putc(int c, console_t *console)
{
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;

View file

@ -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)