From: Christoph Niedermaier <cniedermaier@dh-electronics.com>
To: Marek Vasut <marek.vasut@mailbox.org>,
"u-boot@lists.denx.de" <u-boot@lists.denx.de>
Cc: Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>
Subject: RE: [PATCH 2/2] board: dhelectronics: Use isascii() before isprint() in dh_read_eeprom_id_page()
Date: Wed, 10 Sep 2025 13:20:52 +0000 [thread overview]
Message-ID: <581a80daec794054907b009ab249c3d1@dh-electronics.com> (raw)
In-Reply-To: <20250907010103.667681-2-marek.vasut@mailbox.org>
From: Marek Vasut <marek.vasut@mailbox.org>
Sent: Sunday, September 7, 2025 3:01 AM
> 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 <marek.vasut@mailbox.org>
> ---
> Cc: Christoph Niedermaier <cniedermaier@dh-electronics.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
> board/dhelectronics/common/dh_common.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/board/dhelectronics/common/dh_common.c
> b/board/dhelectronics/common/dh_common.c
> index aeabd617374..e7ee23aa8ce 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;
> }
Reviewed-by: Christoph Niedermaier <cniedermaier@dh-electronics.com>
next prev parent reply other threads:[~2025-09-10 13:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-07 1:00 [PATCH 1/2] board: dhelectronics: Check pointer before access in dh_get_value_from_eeprom_buffer() Marek Vasut
2025-09-07 1:00 ` [PATCH 2/2] board: dhelectronics: Use isascii() before isprint() in dh_read_eeprom_id_page() Marek Vasut
2025-09-10 13:20 ` Christoph Niedermaier [this message]
2025-09-10 13:18 ` [PATCH 1/2] board: dhelectronics: Check pointer before access in dh_get_value_from_eeprom_buffer() Christoph Niedermaier
2025-09-17 13:47 ` Tom Rini
2025-09-17 13:54 ` Marek Vasut
2025-09-17 15:07 ` Tom Rini
2025-09-17 15:08 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=581a80daec794054907b009ab249c3d1@dh-electronics.com \
--to=cniedermaier@dh-electronics.com \
--cc=marek.vasut@mailbox.org \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.