From 11e2c589284b9827a54d830d667c2686027a0402 Mon Sep 17 00:00:00 2001 From: ferar alashkar Date: Sat, 17 Jun 2023 18:02:34 -0400 Subject: [PATCH] lib: os: hex: clarify controlling expression add explicit boolean type to 'if' statement controlling expression, thus improving code readability and maintainability, complying with required [misra-c2012-14.4] rule which states; The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially boolean type. Found as a coding guideline violation (Rule 14.4) by static code scanning tool. Note: Tested on STM32L5 Nucleo-144 board (stm32l552xx). Signed-off-by: ferar alashkar --- lib/os/hex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/os/hex.c b/lib/os/hex.c index 58383f9c977b83..f65125e3c6a02d 100644 --- a/lib/os/hex.c +++ b/lib/os/hex.c @@ -65,7 +65,7 @@ size_t hex2bin(const char *hex, size_t hexlen, uint8_t *buf, size_t buflen) } /* if hexlen is uneven, insert leading zero nibble */ - if (hexlen % 2U) { + if ((hexlen % 2U) != 0) { if (char2hex(hex[0], &dec) < 0) { return 0; }