Skip to content

Commit dddc034

Browse files
feraralashkarcarlescufi
authored andcommitted
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 <[email protected]>
1 parent bba6a1d commit dddc034

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/os/hex.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ int char2hex(char c, uint8_t *x)
2727
int hex2char(uint8_t x, char *c)
2828
{
2929
if (x <= 9) {
30-
*c = x + '0';
30+
*c = x + (char)'0';
3131
} else if (x <= 15) {
32-
*c = x - 10 + 'a';
32+
*c = x - 10 + (char)'a';
3333
} else {
3434
return -EINVAL;
3535
}

0 commit comments

Comments
 (0)