From: Tom Rini Date: Mon, 13 Apr 2020 23:03:54 -0400 Subject: [PATCH] tiny-printf: Support %i In-Reply-To: <340bb660-e59f-5d06-974d-7f4ae3fae9d3@denx.de> References: <20200410185449.152564-1-marex@denx.de> <20200413232711.GD27851@bill-the-cat> <340bb660-e59f-5d06-974d-7f4ae3fae9d3@denx.de> Message-ID: <20200414030354.GE27851@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tue, Apr 14, 2020 at 03:17:16AM +0200, Marek Vasut wrote: > On 4/14/20 1:27 AM, Tom Rini wrote: > > On Fri, Apr 10, 2020 at 08:54:49PM +0200, Marek Vasut wrote: > > > >> The most basic printf("%i", value) formating string was missing, > >> add it for the sake of convenience. > >> > >> Signed-off-by: Marek Vasut > >> Cc: Simon Glass > >> Cc: Stefan Roese > >> --- > >> lib/tiny-printf.c | 3 ++- > >> 1 file changed, 2 insertions(+), 1 deletion(-) > >> > >> diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c > >> index 1138c7012a..8fc7e48d99 100644 > >> --- a/lib/tiny-printf.c > >> +++ b/lib/tiny-printf.c > >> @@ -242,6 +242,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va) > >> goto abort; > >> case 'u': > >> case 'd': > >> + case 'i': > >> div = 1000000000; > >> if (islong) { > >> num = va_arg(va, unsigned long); > >> @@ -251,7 +252,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va) > >> num = va_arg(va, unsigned int); > >> } > >> > >> - if (ch == 'd') { > >> + if (ch != 'u') { > >> if (islong && (long)num < 0) { > >> num = -(long)num; > >> out(info, '-'); > > > > How much does the size change and where do we see this as a problem? > > Any code which uses %i in SPL just misbehaves, e.g. > printf("%s[%i] value=%x", __func__, __LINE__, val); > prints function name and then incorrect value, because %i is ignored. > This is also documented in the commit message. > > U-Boot grows in size massively due to all the DM/DT bloat which is being > forced upon everyone, but there the uncontrolled growth is apparently OK > even if it brings no obvious improvement, rather the opposite. And yet > here, size increase suddenly matters? Sorry, that's not right. > > The code grows by 6 bytes. Yes, it matters for _tiny-printf_ as that's where we have little to no room for growth. So it's just debug prints you were doing that ran in to a problem? Thanks! -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: