Skip to content

Commit

Permalink
lib: os: hex: clarify controlling expression
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
feraralashkar authored and fabiobaltieri committed Aug 23, 2023
1 parent 1f2495d commit 11e2c58
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/os/hex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 11e2c58

Please sign in to comment.