[PATCH] malloc_simple: Remove usage of unsupported %zx format string

Pali Rohár pali at kernel.org
Fri Feb 4 11:48:51 CET 2022


On Thursday 03 February 2022 14:19:41 Simon Glass wrote:
> Hi Pali,
> 
> On Thu, 3 Feb 2022 at 11:51, Pali Rohár <pali at kernel.org> wrote:
> >
> > Replace %zx by %lx and cast size_t to ulong.
> >
> > U-Boot currently prints garbage debug output:
> > size=x, ptr=18, limit=18: 4002a000
> 
> Do you mean in SPL?

Yes, this is printed in 32-bit mvebu SPL.

> >
> > With this change it prints correct debug data:
> > size=18, ptr=18, limit=2000: 4002a000
> >
> > Signed-off-by: Pali Rohár <pali at kernel.org>
> > ---
> >  common/malloc_simple.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> 
> Reviewed-by: Simon Glass <sjg at chromium.org>
> 
> > diff --git a/common/malloc_simple.c b/common/malloc_simple.c
> > index 0267fb6bec87..67ee623850e0 100644
> > --- a/common/malloc_simple.c
> > +++ b/common/malloc_simple.c
> > @@ -23,7 +23,7 @@ static void *alloc_simple(size_t bytes, int align)
> >
> >         addr = ALIGN(gd->malloc_base + gd->malloc_ptr, align);
> >         new_ptr = addr + bytes - gd->malloc_base;
> > -       log_debug("size=%zx, ptr=%lx, limit=%lx: ", bytes, new_ptr,
> > +       log_debug("size=%lx, ptr=%lx, limit=%lx: ", (ulong)bytes, new_ptr,
> >                   gd->malloc_limit);
> >         if (new_ptr > gd->malloc_limit) {
> >                 log_err("alloc space exhausted\n");
> > --
> > 2.20.1
> >
> 
> Regards,
> Simon


More information about the U-Boot mailing list