From dddc034923fab5e6ce6f97eb8122ea417ae6fc79 Mon Sep 17 00:00:00 2001 From: ferar alashkar Date: Sat, 17 Jun 2023 17:16:08 -0400 Subject: [PATCH] lib: os: hex: correct explicit cast type change explicit type cast of essential character type, complying with required [misra-c2012-10.2] rule which states; Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations. Found as a coding guideline violation (Rule 10.2) by static code scanning tool. Note: Tested on STM32L5 Nucleo-144 board (stm32l552xx). Signed-off-by: ferar alashkar --- lib/os/hex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/os/hex.c b/lib/os/hex.c index 26bba541fbe..58383f9c977 100644 --- a/lib/os/hex.c +++ b/lib/os/hex.c @@ -27,9 +27,9 @@ int char2hex(char c, uint8_t *x) int hex2char(uint8_t x, char *c) { if (x <= 9) { - *c = x + '0'; + *c = x + (char)'0'; } else if (x <= 15) { - *c = x - 10 + 'a'; + *c = x - 10 + (char)'a'; } else { return -EINVAL; }