From: Christoph Niedermaier <cniedermaier@dh-electronics.com>
To: Michael Walle <mwalle@kernel.org>,
Quentin Schulz <quentin.schulz@cherry.de>,
Marek Vasut <marex@denx.de>,
"u-boot@lists.denx.de" <u-boot@lists.denx.de>
Cc: Tom Rini <trini@konsulko.com>,
Benedikt Spranger <b.spranger@linutronix.de>,
Simon Glass <sjg@chromium.org>,
John Ogness <john.ogness@linutronix.de>,
Jerome Forissier <jerome.forissier@linaro.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>
Subject: RE: [PATCH] tiny-printf: Add support for upper case hex values
Date: Tue, 1 Apr 2025 14:08:03 +0000 [thread overview]
Message-ID: <052e98f6480b4490bd9338eb2f9ed5d2@dh-electronics.com> (raw)
In-Reply-To: <D8V6D9S6CBRH.3LRHNU4XCVF14@kernel.org>
From: Michael Walle <mwalle@kernel.org>
Sent: Tuesday, April 1, 2025 10:56 AM
>
> Hi,
>
>> The issue is that disabling TINY_PRINTF may not be possible (size
>> constraints) and some code is compiled for different stages and people
>> typically don't check whether the format used in printf is valid with
>> tiny_printf. I've had this issue already in the past, I vaguely recall
>> "complaining" about it on IRC.
>
> Yes, I've stumbled on "%pa" with tiny printf (i.e. in
> drivers/pinctrl/pinctrl-single.c) which is printing the very wrong
> value, actually :) So printing anything unknown as '?' would really
> help here.
Something like that would help:
diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index 48db7b1f78f..b918d6d7386 100644
--- a/lib/tiny-printf.c
+++ b/lib/tiny-printf.c
@@ -280,6 +280,12 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
while (isalnum(fmt[0]))
fmt++;
break;
+ } else {
+ if (fmt[0] != '\0' && (fmt[0] == 'a' || fmt[0] == 'm' ||
+ fmt[0] == 'M' || fmt[0] == 'I')) {
+ fmt++;
+ goto unsupported;
+ }
}
islong = true;
/* no break */
@@ -308,6 +314,8 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
case '%':
out(info, '%');
default:
+unsupported:
+ out(info, '?');
break;
}
But maybe it is too much for tiny printf, because tiny means
tiny. It's a question of either gain or small code size.
Regards
Christoph
next prev parent reply other threads:[~2025-04-01 14:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-20 10:23 [PATCH] tiny-printf: Add support for upper case hex values Christoph Niedermaier
2025-03-20 11:49 ` Marek Vasut
2025-03-20 13:53 ` Tom Rini
2025-03-20 14:00 ` Quentin Schulz
2025-03-20 14:14 ` Marek Vasut
2025-03-20 14:18 ` Tom Rini
2025-03-20 17:58 ` Christoph Niedermaier
2025-03-20 18:28 ` Tom Rini
2025-03-20 18:41 ` Christoph Niedermaier
2025-04-01 8:55 ` Michael Walle
2025-04-01 14:08 ` Christoph Niedermaier [this message]
2025-04-02 7:01 ` Michael Walle
2025-04-02 9:03 ` Christoph Niedermaier
2025-04-04 8:33 ` Michael Walle
2025-04-04 14:58 ` Tom Rini
2025-04-07 5:27 ` Michael Walle
2025-04-07 6:55 ` Christoph Niedermaier
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=052e98f6480b4490bd9338eb2f9ed5d2@dh-electronics.com \
--to=cniedermaier@dh-electronics.com \
--cc=b.spranger@linutronix.de \
--cc=ilias.apalodimas@linaro.org \
--cc=jerome.forissier@linaro.org \
--cc=john.ogness@linutronix.de \
--cc=marex@denx.de \
--cc=mwalle@kernel.org \
--cc=quentin.schulz@cherry.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox