summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Vasut <[email protected]>2025-09-07 03:00:47 +0200
committerTom Rini <[email protected]>2025-09-16 16:14:18 -0600
commitfd396316432ad4a0f2998ea9eee9720be0e5d5f8 (patch)
tree7e37ee66622ce0e1cfa8dd4643e6b12f32d1f0c8
parent1c735620e19e2ae07705cc38da1552ee6a696ff0 (diff)
board: dhelectronics: Use isascii() before isprint() in dh_read_eeprom_id_page()
The isprint() checks printability across all 256 characters, some of the upper 128 characters are printable and produce artifacts on UART. Call isascii() first to only consider the bottom 7bit ASCII characters as printable, and then check their printability using isprint(). This fixes a rare misprint in case the ID page content is uninitialized or corrupted. Signed-off-by: Marek Vasut <[email protected]> Reviewed-by: Christoph Niedermaier <[email protected]>
-rw-r--r--board/dhelectronics/common/dh_common.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/board/dhelectronics/common/dh_common.c b/board/dhelectronics/common/dh_common.c
index d3a3f0ff11f..6101ecc7ebc 100644
--- a/board/dhelectronics/common/dh_common.c
+++ b/board/dhelectronics/common/dh_common.c
@@ -88,9 +88,9 @@ int dh_read_eeprom_id_page(u8 *eeprom_buffer, const char *alias)
/* Validate header ID */
if (eip->hdr.id[0] != 'D' || eip->hdr.id[1] != 'H' || eip->hdr.id[2] != 'E') {
printf("%s: Error validating header ID! (got %c%c%c (0x%02x 0x%02x 0x%02x) != expected DHE)\n",
- __func__, isprint(eip->hdr.id[0]) ? eip->hdr.id[0] : '.',
- isprint(eip->hdr.id[1]) ? eip->hdr.id[1] : '.',
- isprint(eip->hdr.id[2]) ? eip->hdr.id[2] : '.',
+ __func__, (isascii(eip->hdr.id[0]) && isprint(eip->hdr.id[0])) ? eip->hdr.id[0] : '.',
+ (isascii(eip->hdr.id[1]) && isprint(eip->hdr.id[1])) ? eip->hdr.id[1] : '.',
+ (isascii(eip->hdr.id[2]) && isprint(eip->hdr.id[2])) ? eip->hdr.id[2] : '.',
eip->hdr.id[0], eip->hdr.id[1], eip->hdr.id[2]);
return -EINVAL;
}