diff mbox series

[1/2] bootm: adjust the print format

Message ID 20240825122617.3708982-1-dario.binacchi@amarulasolutions.com
State New
Delegated to: Tom Rini
Headers show
Series [1/2] bootm: adjust the print format | expand

Commit Message

Dario Binacchi Aug. 25, 2024, 12:26 p.m. UTC
All three addresses printed are in hexadecimal format, but only the
first two have the "0x" prefix. The patch aligns the format of the
"end" address with the other two by adding the "0x" prefix.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---

 boot/bootm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

E Shattow Aug. 25, 2024, 6:36 p.m. UTC | #1
On Sun, Aug 25, 2024 at 5:26 AM Dario Binacchi
<dario.binacchi@amarulasolutions.com> wrote:
>
> All three addresses printed are in hexadecimal format, but only the
> first two have the "0x" prefix. The patch aligns the format of the
> "end" address with the other two by adding the "0x" prefix.
>
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> ---
>
>  boot/bootm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/boot/bootm.c b/boot/bootm.c
> index 480f8e6a0e6e..951e549f19ff 100644
> --- a/boot/bootm.c
> +++ b/boot/bootm.c
> @@ -703,7 +703,7 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress)
>
>                 /* Handle BOOTM_STATE_LOADOS */
>                 if (relocated_addr != load) {
> -                       printf("Moving Image from 0x%lx to 0x%lx, end=%lx\n",
> +                       printf("Moving Image from 0x%lx to 0x%lx, end=0x%lx\n",
>                                load, relocated_addr,
>                                relocated_addr + image_size);
>                         memmove((void *)relocated_addr, load_buf, image_size);
> --
> 2.43.0
>

From U-Boot documentation, alpha-numeric input is assumed to be
hexadecimal except when it is not, and generally does not accept "0x"
prefix on input. So the correct action would be to make this
consistent over the whole U-Boot code base, or remove the "0x"
prefixes (not add more of them) ?

-E
Mattijs Korpershoek Aug. 26, 2024, 6:34 a.m. UTC | #2
Hi Dario,

Thank you for the patch.

On dim., août 25, 2024 at 14:26, Dario Binacchi <dario.binacchi@amarulasolutions.com> wrote:

> All three addresses printed are in hexadecimal format, but only the
> first two have the "0x" prefix. The patch aligns the format of the
> "end" address with the other two by adding the "0x" prefix.
>
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

> ---
>
>  boot/bootm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/boot/bootm.c b/boot/bootm.c
> index 480f8e6a0e6e..951e549f19ff 100644
> --- a/boot/bootm.c
> +++ b/boot/bootm.c
> @@ -703,7 +703,7 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress)
>  
>  		/* Handle BOOTM_STATE_LOADOS */
>  		if (relocated_addr != load) {
> -			printf("Moving Image from 0x%lx to 0x%lx, end=%lx\n",
> +			printf("Moving Image from 0x%lx to 0x%lx, end=0x%lx\n",
>  			       load, relocated_addr,
>  			       relocated_addr + image_size);
>  			memmove((void *)relocated_addr, load_buf, image_size);
> -- 
> 2.43.0
Caleb Connolly Aug. 26, 2024, 1:26 p.m. UTC | #3
On 25/08/2024 19:36, E Shattow wrote:
> On Sun, Aug 25, 2024 at 5:26 AM Dario Binacchi
> <dario.binacchi@amarulasolutions.com> wrote:
>>
>> All three addresses printed are in hexadecimal format, but only the
>> first two have the "0x" prefix. The patch aligns the format of the
>> "end" address with the other two by adding the "0x" prefix.
>>
>> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
>> ---
>>
>>   boot/bootm.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/boot/bootm.c b/boot/bootm.c
>> index 480f8e6a0e6e..951e549f19ff 100644
>> --- a/boot/bootm.c
>> +++ b/boot/bootm.c
>> @@ -703,7 +703,7 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress)
>>
>>                  /* Handle BOOTM_STATE_LOADOS */
>>                  if (relocated_addr != load) {
>> -                       printf("Moving Image from 0x%lx to 0x%lx, end=%lx\n",
>> +                       printf("Moving Image from 0x%lx to 0x%lx, end=0x%lx\n",
>>                                 load, relocated_addr,
>>                                 relocated_addr + image_size);
>>                          memmove((void *)relocated_addr, load_buf, image_size);
>> --
>> 2.43.0
>>
> 
>  From U-Boot documentation, alpha-numeric input is assumed to be
> hexadecimal except when it is not, and generally does not accept "0x"
> prefix on input. So the correct action would be to make this
> consistent over the whole U-Boot code base, or remove the "0x"
> prefixes (not add more of them) ?

Most(?) U-Boot commands accept the 0x prefix. I don't think stripping it 
is sensible, I myself have gotten confused many times over hex values 
that lack the leading 0x in U-Boot output.

Maybe unavailable in SPL (not sure) but I prefer the "%#lx" format which 
prepends the 0x automatically.
> 
> -E
Tom Rini Aug. 26, 2024, 3:01 p.m. UTC | #4
On Mon, Aug 26, 2024 at 02:26:10PM +0100, Caleb Connolly wrote:
> 
> 
> On 25/08/2024 19:36, E Shattow wrote:
> > On Sun, Aug 25, 2024 at 5:26 AM Dario Binacchi
> > <dario.binacchi@amarulasolutions.com> wrote:
> > > 
> > > All three addresses printed are in hexadecimal format, but only the
> > > first two have the "0x" prefix. The patch aligns the format of the
> > > "end" address with the other two by adding the "0x" prefix.
> > > 
> > > Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> > > ---
> > > 
> > >   boot/bootm.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/boot/bootm.c b/boot/bootm.c
> > > index 480f8e6a0e6e..951e549f19ff 100644
> > > --- a/boot/bootm.c
> > > +++ b/boot/bootm.c
> > > @@ -703,7 +703,7 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress)
> > > 
> > >                  /* Handle BOOTM_STATE_LOADOS */
> > >                  if (relocated_addr != load) {
> > > -                       printf("Moving Image from 0x%lx to 0x%lx, end=%lx\n",
> > > +                       printf("Moving Image from 0x%lx to 0x%lx, end=0x%lx\n",
> > >                                 load, relocated_addr,
> > >                                 relocated_addr + image_size);
> > >                          memmove((void *)relocated_addr, load_buf, image_size);
> > > --
> > > 2.43.0
> > > 
> > 
> >  From U-Boot documentation, alpha-numeric input is assumed to be
> > hexadecimal except when it is not, and generally does not accept "0x"
> > prefix on input. So the correct action would be to make this

While there was some point in history where I'm sure we got confused by
"0x" input I don't think that's true anymore (and everything should be
using some strto function that works as expected, not a custom parser).
So the docs should be updated there.

> > consistent over the whole U-Boot code base, or remove the "0x"
> > prefixes (not add more of them) ?
> 
> Most(?) U-Boot commands accept the 0x prefix. I don't think stripping it is
> sensible, I myself have gotten confused many times over hex values that lack
> the leading 0x in U-Boot output.
> 
> Maybe unavailable in SPL (not sure) but I prefer the "%#lx" format which
> prepends the 0x automatically.

That we assume input is hex is just what it is these days. Output really
ought to be prefixed with 0x because that's just common convention (and
whatever we assumed people would Just Know 25+ years ago may not be true
today). Since updating this output really shouldn't change our ABI, it's
conceptually fine with me but we don't use "%#lx" a lot and so I don't
know if tiny-printf handles it and so that might not be the right call
for SPL code and so lets not change this patch.

Reviewed-by: Tom Rini <trini@konsulko.com>
Simon Glass Aug. 26, 2024, 5:49 p.m. UTC | #5
Hi,

On Sun, 25 Aug 2024 at 12:36, E Shattow <lucent@gmail.com> wrote:
>
> On Sun, Aug 25, 2024 at 5:26 AM Dario Binacchi
> <dario.binacchi@amarulasolutions.com> wrote:
> >
> > All three addresses printed are in hexadecimal format, but only the
> > first two have the "0x" prefix. The patch aligns the format of the
> > "end" address with the other two by adding the "0x" prefix.
> >
> > Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> > ---
> >
> >  boot/bootm.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/boot/bootm.c b/boot/bootm.c
> > index 480f8e6a0e6e..951e549f19ff 100644
> > --- a/boot/bootm.c
> > +++ b/boot/bootm.c
> > @@ -703,7 +703,7 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress)
> >
> >                 /* Handle BOOTM_STATE_LOADOS */
> >                 if (relocated_addr != load) {
> > -                       printf("Moving Image from 0x%lx to 0x%lx, end=%lx\n",
> > +                       printf("Moving Image from 0x%lx to 0x%lx, end=0x%lx\n",
> >                                load, relocated_addr,
> >                                relocated_addr + image_size);
> >                         memmove((void *)relocated_addr, load_buf, image_size);
> > --
> > 2.43.0
> >
>
> From U-Boot documentation, alpha-numeric input is assumed to be
> hexadecimal except when it is not, and generally does not accept "0x"
> prefix on input. So the correct action would be to make this
> consistent over the whole U-Boot code base, or remove the "0x"
> prefixes (not add more of them) ?

Yes, we should avoid these prefixes as they can confuse people into
thinking that hex is not the default.

In other cases where this is needed, for 0x you can use %#x

Regards,
Simon
diff mbox series

Patch

diff --git a/boot/bootm.c b/boot/bootm.c
index 480f8e6a0e6e..951e549f19ff 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -703,7 +703,7 @@  static int bootm_load_os(struct bootm_headers *images, int boot_progress)
 
 		/* Handle BOOTM_STATE_LOADOS */
 		if (relocated_addr != load) {
-			printf("Moving Image from 0x%lx to 0x%lx, end=%lx\n",
+			printf("Moving Image from 0x%lx to 0x%lx, end=0x%lx\n",
 			       load, relocated_addr,
 			       relocated_addr + image_size);
 			memmove((void *)relocated_addr, load_buf, image_size);