cmd: part: number: remove inconsistent 0x from returned value
PATCH 1/1 cmd: part: number: remove inconsistent 0x from returned value
From: Stefan Herbrechtsmeier <[email protected]>
The part number sub-command returns the hexadecimal value with a leading 0x. This is inconsistent with other values in the command and U-Boot uses hexadecimal values generally.
---
cmd/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/part.c +1 -1
@@ -152,7 +152,7 @@ static int do_part_info(int argc, char *const argv[], enum cmd_part_info param)snprintf (buf,sizeof (buf),LBAF , info.size);break ;case CMD_PART_INFO_NUMBER : -snprintf (buf,sizeof (buf),"0x%x" , part); +snprintf (buf,sizeof (buf),"%x" , part);break ;default :printf ("** Unknown cmd_part_info value: %d\n" , param);
Signature · 1 line
2.20.1
PATCH 1/1 cmd: part: number: remove inconsistent 0x from returned value
Hello Stefan,
Quoted 4 lines · Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier <[email protected]>
The part number sub-command returns the hexadecimal value with a leading 0x.
That's to make sure that:
- users have clear and unequivocal feedback that '10' returned by the command is really HEX 10, not DEC 10.
- other U-Boot commands which need to take '0x10' as input will interpret it correctly, regardless of the way these other commands implement ascii-to-integer conversion.
Quoted 1 line
This is inconsistent with other values in the command
It could be, but it is then better to fix the inconsistency in those commands/sub-commands which add the ambiguity.
Quoted 1 line
and U-Boot uses hexadecimal values generally.
The key word is "generally", but not always. Some U-Boot commands will process '10' as HEX 10 and some will process 10 as DEC 10. So, in order to avoid these games, I vote for leaving the 0x in place.
Quoted 18 lines
Signed-off-by Stefan Herbrechtsmeier <[email protected]>---
cmd/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)cmd/part.c +1
-1@@ -152,7 +152,7 @@ static int do_part_info(int argc, char *const argv[], enum cmd_part_info param)snprintf (buf,sizeof (buf),LBAF , info.size);break ;case CMD_PART_INFO_NUMBER : -snprintf (buf,sizeof (buf),"0x%x" , part); +snprintf (buf,sizeof (buf),"%x" , part);
Signature · 2 lines
Best regards, Eugeniu Rosca
PATCH 1/1 cmd: part: number: remove inconsistent 0x from returned value
Hi Eugeniu,
Am 05.03.2021 um 12:52 schrieb Eugeniu Rosca:
Quoted 8 lines
Hello Stefan,
Quoted 4 lines · Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier <[email protected]>
The part number sub-command returns the hexadecimal value with a leading 0x.
Quoted 6 lines
That's to make sure that:
- users have clear and unequivocal feedback that '10' returned by the command is really HEX 10, not DEC 10.
- other U-Boot commands which need to take '0x10' as input will interpret it correctly, regardless of the way these other commands implement ascii-to-integer conversion.
'Almost all U-Boot commands expect numbers to be entered in hexadecimal input format.' [1]
The filesystem commands use simple_strtoul(.., 16) and interpret the value as hexadecimal value.
The 0x suggests that a 10 will be interpreted as decimal value and this isn't true.
Quoted 4 lines
Quoted 1 line
This is inconsistent with other values in the command
It could be, but it is then better to fix the inconsistency in those commands/sub-commands which add the ambiguity.
Normally you are right but U-Boot by design use hexadecimal values without 0x. The env_set_hex functions doesn't use 0x.
Quoted 5 lines
Quoted 1 line
and U-Boot uses hexadecimal values generally.
The key word is "generally", but not always. Some U-Boot commands will process '10' as HEX 10 and some will process 10 as DEC 10. So, in order to avoid these games, I vote for leaving the 0x in place.
You can avoid it only if you could mark decimal numbers and that is impossible.
@Tom: Does U-Boot still expect numbers to be hexadecimal values?
[1] https://www.denx.de/wiki/DULG/UBootCommandLineInterface
Quoted 19 lines
Quoted 18 lines
Signed-off-by Stefan Herbrechtsmeier <[email protected]>---
cmd/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)cmd/part.c +1
-1@@ -152,7 +152,7 @@ static int do_part_info(int argc, char *const argv[], enum cmd_part_info param)snprintf (buf,sizeof (buf),LBAF , info.size);break ;case CMD_PART_INFO_NUMBER : -snprintf (buf,sizeof (buf),"0x%x" , part); +snprintf (buf,sizeof (buf),"%x" , part);
PATCH 1/1 cmd: part: number: remove inconsistent 0x from returned value
Hi,
Quoted 28 lines · Stefan Herbrechtsmeier
Hi Eugeniu,
Am 05.03.2021 um 12:52 schrieb Eugeniu Rosca:
Quoted 8 lines
Hello Stefan,
Quoted 4 lines · Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier <[email protected]>
The part number sub-command returns the hexadecimal value with a leading 0x.
Quoted 6 lines
That's to make sure that:
- users have clear and unequivocal feedback that '10' returned by the command is really HEX 10, not DEC 10.
- other U-Boot commands which need to take '0x10' as input will interpret it correctly, regardless of the way these other commands implement ascii-to-integer conversion.'Almost all U-Boot commands expect numbers to be entered in hexadecimal input format.' [1]
The filesystem commands use
simple_strtoul(.., 16)and interpret the value as hexadecimal value.The 0x suggests that a 10 will be interpreted as decimal value and this isn't true.
Quoted 13 lines
Quoted 4 lines
Quoted 1 line
This is inconsistent with other values in the command
It could be, but it is then better to fix the inconsistency in those commands/sub-commands which add the ambiguity.
Normally you are right but U-Boot by design use hexadecimal values without 0x. The
env_set_hexfunctions doesn't use 0x.Quoted 5 lines
Quoted 1 line
and U-Boot uses hexadecimal values generally.
The key word is "generally", but not always. Some U-Boot commands will process '10' as HEX 10 and some will process 10 as DEC 10. So, in order to avoid these games, I vote for leaving the 0x in place.
I would be very surprised if 10 means 0d10 in a partition number. I agree that putting a 0x in these values is a dangerous precedent and will just cause confusion. U-Boot uses hex for addresses and most arguments
Quoted 3 lines
You can avoid it only if you could mark decimal numbers and that is impossible.
0d10 is available. People are not used to it though.
Quoted 24 lines
@Tom: Does U-Boot still expect numbers to be hexadecimal values?
[1] https://www.denx.de/wiki/DULG/UBootCommandLineInterface
Quoted 19 lines
Quoted 18 lines
Signed-off-by Stefan Herbrechtsmeier <[email protected]>---
cmd/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)cmd/part.c +1
-1@@ -152,7 +152,7 @@ static int do_part_info(int argc, char *const argv[], enum cmd_part_info param)snprintf (buf,sizeof (buf),LBAF , info.size);break ;case CMD_PART_INFO_NUMBER : -snprintf (buf,sizeof (buf),"0x%x" , part); +snprintf (buf,sizeof (buf),"%x" , part);
PATCH 1/1 cmd: part: number: remove inconsistent 0x from returned value
Quoted 52 lines · Simon Glass
Hi,
Quoted 28 lines · Stefan Herbrechtsmeier
Hi Eugeniu,
Am 05.03.2021 um 12:52 schrieb Eugeniu Rosca:
Quoted 8 lines
Hello Stefan,
Quoted 4 lines · Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier <[email protected]>
The part number sub-command returns the hexadecimal value with a leading 0x.
Quoted 6 lines
That's to make sure that:
- users have clear and unequivocal feedback that '10' returned by the command is really HEX 10, not DEC 10.
- other U-Boot commands which need to take '0x10' as input will interpret it correctly, regardless of the way these other commands implement ascii-to-integer conversion.'Almost all U-Boot commands expect numbers to be entered in hexadecimal input format.' [1]
The filesystem commands use
simple_strtoul(.., 16)and interpret the value as hexadecimal value.The 0x suggests that a 10 will be interpreted as decimal value and this isn't true.
Quoted 13 lines
Quoted 4 lines
Quoted 1 line
This is inconsistent with other values in the command
It could be, but it is then better to fix the inconsistency in those commands/sub-commands which add the ambiguity.
Normally you are right but U-Boot by design use hexadecimal values without 0x. The
env_set_hexfunctions doesn't use 0x.Quoted 5 lines
Quoted 1 line
and U-Boot uses hexadecimal values generally.
The key word is "generally", but not always. Some U-Boot commands will process '10' as HEX 10 and some will process 10 as DEC 10. So, in order to avoid these games, I vote for leaving the 0x in place.
I would be very surprised if 10 means 0d10 in a partition number. I agree that putting a 0x in these values is a dangerous precedent and will just cause confusion. U-Boot uses hex for addresses and most arguments
Quoted 1 line
Quoted 31 lines
Quoted 2 lines
You can avoid it only if you could mark decimal numbers and that is impossible.
0d10 is available. People are not used to it though.
Reviewed-by Simon Glass <[email protected]>Quoted 24 lines
@Tom: Does U-Boot still expect numbers to be hexadecimal values?
[1] https://www.denx.de/wiki/DULG/UBootCommandLineInterface
Quoted 19 lines
Quoted 18 lines
Signed-off-by Stefan Herbrechtsmeier <[email protected]>---
cmd/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)cmd/part.c +1
-1@@ -152,7 +152,7 @@ static int do_part_info(int argc, char *const argv[], enum cmd_part_info param)snprintf (buf,sizeof (buf),LBAF , info.size);break ;case CMD_PART_INFO_NUMBER : -snprintf (buf,sizeof (buf),"0x%x" , part); +snprintf (buf,sizeof (buf),"%x" , part);
I am not a fan of this change as well, especially having spent time on some platforms that have literally 20+ partition entries. Being clear here that this is a hex value is important.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210306/a796e20d/attachment.sig>
PATCH 1/1 cmd: part: number: remove inconsistent 0x from returned value
Hi,
Am 06.03.2021 um 21:12 schrieb Tom Rini:
Quoted 85 lines · Simon Glass
Quoted 52 lines
Hi,
Quoted 28 lines · Stefan Herbrechtsmeier
Hi Eugeniu,
Am 05.03.2021 um 12:52 schrieb Eugeniu Rosca:
Quoted 8 lines
Hello Stefan,
Quoted 4 lines · Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier <[email protected]>
The part number sub-command returns the hexadecimal value with a leading 0x.
Quoted 6 lines
That's to make sure that:
- users have clear and unequivocal feedback that '10' returned by the command is really HEX 10, not DEC 10.
- other U-Boot commands which need to take '0x10' as input will interpret it correctly, regardless of the way these other commands implement ascii-to-integer conversion.'Almost all U-Boot commands expect numbers to be entered in hexadecimal input format.' [1]
The filesystem commands use
simple_strtoul(.., 16)and interpret the value as hexadecimal value.The 0x suggests that a 10 will be interpreted as decimal value and this isn't true.
Quoted 13 lines
Quoted 4 lines
Quoted 1 line
This is inconsistent with other values in the command
It could be, but it is then better to fix the inconsistency in those commands/sub-commands which add the ambiguity.
Normally you are right but U-Boot by design use hexadecimal values without 0x. The
env_set_hexfunctions doesn't use 0x.Quoted 5 lines
Quoted 1 line
and U-Boot uses hexadecimal values generally.
The key word is "generally", but not always. Some U-Boot commands will process '10' as HEX 10 and some will process 10 as DEC 10. So, in order to avoid these games, I vote for leaving the 0x in place.
I would be very surprised if 10 means 0d10 in a partition number. I agree that putting a 0x in these values is a dangerous precedent and will just cause confusion. U-Boot uses hex for addresses and most arguments
Quoted 1 line
Quoted 31 lines
Quoted 2 lines
You can avoid it only if you could mark decimal numbers and that is impossible.
0d10 is available. People are not used to it though.
Reviewed-by Simon Glass <[email protected]>Quoted 24 lines
@Tom: Does U-Boot still expect numbers to be hexadecimal values?
[1] https://www.denx.de/wiki/DULG/UBootCommandLineInterface
Quoted 19 lines
Quoted 18 lines
Signed-off-by Stefan Herbrechtsmeier <[email protected]>---
cmd/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)cmd/part.c +1
-1@@ -152,7 +152,7 @@ static int do_part_info(int argc, char *const argv[], enum cmd_part_info param)snprintf (buf,sizeof (buf),LBAF , info.size);break ;case CMD_PART_INFO_NUMBER : -snprintf (buf,sizeof (buf),"0x%x" , part); +snprintf (buf,sizeof (buf),"%x" , part);
Quoted 3 lines
I am not a fan of this change as well, especially having spent time on some platforms that have literally 20+ partition entries. Being clear here that this is a hex value is important.
But isn't it confusing to use a 0x for a value which is treated as hexadecimal value by the commands independent of the 0x. The 0x results in the assumption that the partition is a decimal value without the 0x.
What is the correct way to convert a hexadecimal value into a decimal value on the shell? I need a value without prefix (decimal value) to pass it to the root parameter of the bootargs.
At the moment the different default numeral systems of common functions like load and test are very irritating. The load command uses hexadecimal value and doesn't support decimal value. The test command uses decimal value by default but supports hexadecimal values with a prefix. This means that the returned variable filesize of the command load couldn't be checked by test and the user have to use the itest command.
Regards
Stefan
PATCH 1/1 cmd: part: number: remove inconsistent 0x from returned value
Hi Stefan,
Quoted 101 lines · Stefan Herbrechtsmeier
Hi,
Am 06.03.2021 um 21:12 schrieb Tom Rini:
Quoted 85 lines · Simon Glass
Quoted 52 lines
Hi,
Quoted 28 lines · Stefan Herbrechtsmeier
Hi Eugeniu,
Am 05.03.2021 um 12:52 schrieb Eugeniu Rosca:
Quoted 8 lines
Hello Stefan,
Quoted 4 lines · Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier <[email protected]>
The part number sub-command returns the hexadecimal value with a leading 0x.
Quoted 6 lines
That's to make sure that:
- users have clear and unequivocal feedback that '10' returned by the command is really HEX 10, not DEC 10.
- other U-Boot commands which need to take '0x10' as input will interpret it correctly, regardless of the way these other commands implement ascii-to-integer conversion.'Almost all U-Boot commands expect numbers to be entered in hexadecimal input format.' [1]
The filesystem commands use
simple_strtoul(.., 16)and interpret the value as hexadecimal value.The 0x suggests that a 10 will be interpreted as decimal value and this isn't true.
Quoted 13 lines
Quoted 4 lines
Quoted 1 line
This is inconsistent with other values in the command
It could be, but it is then better to fix the inconsistency in those commands/sub-commands which add the ambiguity.
Normally you are right but U-Boot by design use hexadecimal values without 0x. The
env_set_hexfunctions doesn't use 0x.Quoted 5 lines
Quoted 1 line
and U-Boot uses hexadecimal values generally.
The key word is "generally", but not always. Some U-Boot commands will process '10' as HEX 10 and some will process 10 as DEC 10. So, in order to avoid these games, I vote for leaving the 0x in place.
I would be very surprised if 10 means 0d10 in a partition number. I agree that putting a 0x in these values is a dangerous precedent and will just cause confusion. U-Boot uses hex for addresses and most arguments
Quoted 1 line
Quoted 31 lines
Quoted 2 lines
You can avoid it only if you could mark decimal numbers and that is impossible.
0d10 is available. People are not used to it though.
Reviewed-by Simon Glass <[email protected]>Quoted 24 lines
@Tom: Does U-Boot still expect numbers to be hexadecimal values?
[1] https://www.denx.de/wiki/DULG/UBootCommandLineInterface
Quoted 19 lines
Quoted 18 lines
Signed-off-by Stefan Herbrechtsmeier <[email protected]>---
cmd/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)cmd/part.c +1
-1@@ -152,7 +152,7 @@ static int do_part_info(int argc, char *const argv[], enum cmd_part_info param)snprintf (buf,sizeof (buf),LBAF , info.size);break ;case CMD_PART_INFO_NUMBER : -snprintf (buf,sizeof (buf),"0x%x" , part); +snprintf (buf,sizeof (buf),"%x" , part);Quoted 3 lines
I am not a fan of this change as well, especially having spent time on some platforms that have literally 20+ partition entries. Being clear here that this is a hex value is important.
But isn't it confusing to use a 0x for a value which is treated as hexadecimal value by the commands independent of the 0x. The 0x results in the assumption that the partition is a decimal value without the 0x.
What is the correct way to convert a hexadecimal value into a decimal value on the shell? I need a value without prefix (decimal value) to pass it to the root parameter of the bootargs.
Quoted 6 lines
At the moment the different default numeral systems of common functions like load and test are very irritating. The load command uses hexadecimal value and doesn't support decimal value. The test command uses decimal value by default but supports hexadecimal values with a prefix. This means that the returned variable filesize of the command load couldn't be checked by test and the user have to use the itest command.
Let's use hex where possible. I am not sure what to do with the test command, nor how often we use 'test' with addresses, but I think adding an option to 'test' to make it use hex or dec would be good. Then one day we could change the default to hex.
Regards,
Simon
PATCH 1/1 cmd: part: number: remove inconsistent 0x from returned value
Hi Simon,
Am 12.03.2021 um 05:45 schrieb Simon Glass:
Quoted 112 lines
Hi Stefan,
Quoted 101 lines · Stefan Herbrechtsmeier
Hi,
Am 06.03.2021 um 21:12 schrieb Tom Rini:
Quoted 85 lines · Simon Glass
Quoted 52 lines
Hi,
Quoted 28 lines · Stefan Herbrechtsmeier
Hi Eugeniu,
Am 05.03.2021 um 12:52 schrieb Eugeniu Rosca:
Quoted 8 lines
Hello Stefan,
Quoted 4 lines · Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier <[email protected]>
The part number sub-command returns the hexadecimal value with a leading 0x.
Quoted 6 lines
That's to make sure that:
- users have clear and unequivocal feedback that '10' returned by the command is really HEX 10, not DEC 10.
- other U-Boot commands which need to take '0x10' as input will interpret it correctly, regardless of the way these other commands implement ascii-to-integer conversion.'Almost all U-Boot commands expect numbers to be entered in hexadecimal input format.' [1]
The filesystem commands use
simple_strtoul(.., 16)and interpret the value as hexadecimal value.The 0x suggests that a 10 will be interpreted as decimal value and this isn't true.
Quoted 13 lines
Quoted 4 lines
Quoted 1 line
This is inconsistent with other values in the command
It could be, but it is then better to fix the inconsistency in those commands/sub-commands which add the ambiguity.
Normally you are right but U-Boot by design use hexadecimal values without 0x. The
env_set_hexfunctions doesn't use 0x.Quoted 5 lines
Quoted 1 line
and U-Boot uses hexadecimal values generally.
The key word is "generally", but not always. Some U-Boot commands will process '10' as HEX 10 and some will process 10 as DEC 10. So, in order to avoid these games, I vote for leaving the 0x in place.
I would be very surprised if 10 means 0d10 in a partition number. I agree that putting a 0x in these values is a dangerous precedent and will just cause confusion. U-Boot uses hex for addresses and most arguments
Quoted 1 line
Quoted 31 lines
Quoted 2 lines
You can avoid it only if you could mark decimal numbers and that is impossible.
0d10 is available. People are not used to it though.
Reviewed-by Simon Glass <[email protected]>Quoted 24 lines
@Tom: Does U-Boot still expect numbers to be hexadecimal values?
[1] https://www.denx.de/wiki/DULG/UBootCommandLineInterface
Quoted 19 lines
Quoted 18 lines
Signed-off-by Stefan Herbrechtsmeier <[email protected]>---
cmd/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)cmd/part.c +1
-1@@ -152,7 +152,7 @@ static int do_part_info(int argc, char *const argv[], enum cmd_part_info param)snprintf (buf,sizeof (buf),LBAF , info.size);break ;case CMD_PART_INFO_NUMBER : -snprintf (buf,sizeof (buf),"0x%x" , part); +snprintf (buf,sizeof (buf),"%x" , part);Quoted 3 lines
I am not a fan of this change as well, especially having spent time on some platforms that have literally 20+ partition entries. Being clear here that this is a hex value is important.
But isn't it confusing to use a 0x for a value which is treated as hexadecimal value by the commands independent of the 0x. The 0x results in the assumption that the partition is a decimal value without the 0x.
What is the correct way to convert a hexadecimal value into a decimal value on the shell? I need a value without prefix (decimal value) to pass it to the root parameter of the bootargs.
Quoted 6 lines
At the moment the different default numeral systems of common functions like load and test are very irritating. The load command uses hexadecimal value and doesn't support decimal value. The test command uses decimal value by default but supports hexadecimal values with a prefix. This means that the returned variable filesize of the command load couldn't be checked by test and the user have to use the itest command.
Quoted 3 lines
Let's use hex where possible. I am not sure what to do with the test command, nor how often we use 'test' with addresses, but I think adding an option to 'test' to make it use hex or dec would be good.
But what is the difference to test vs itest?
Quoted 1 line
Then one day we could change the default to hex.
Is this possible? This would be a breaking change.
I think the main problem is the unclear default numeral system. It would be much easy if every number without a prefix have the same numeral system. This would mean that a simple_strtoul(.., 0) would fall back to the default numeral system if the value hasn't any prefix (0x or 0d). At the moment simple_strtoul(.., 0) fall back to decimal and many commands use different numeral systems (simple_strtoul(.., 10) or simple_strtoul(.., 16)).
Independent of this problem I need a command to convert a value to decimal without any prefix. Can you recommend any command or should I add a printf command?
Regards
Stefan
PATCH 1/1 cmd: part: number: remove inconsistent 0x from returned value
Hi Stefan,
Quoted 116 lines · Stefan Herbrechtsmeier
Hi Simon,
Am 12.03.2021 um 05:45 schrieb Simon Glass:
Quoted 112 lines
Hi Stefan,
Quoted 107 lines · Stefan Herbrechtsmeier
Hi,
Am 06.03.2021 um 21:12 schrieb Tom Rini:
Quoted 85 lines · Simon Glass
Quoted 52 lines
Hi,
Quoted 28 lines · Stefan Herbrechtsmeier
Hi Eugeniu,
Am 05.03.2021 um 12:52 schrieb Eugeniu Rosca:
Quoted 8 lines
Hello Stefan,
Quoted 4 lines · Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier <[email protected]>
The part number sub-command returns the hexadecimal value with a leading 0x.
Quoted 6 lines
That's to make sure that:
- users have clear and unequivocal feedback that '10' returned by the command is really HEX 10, not DEC 10.
- other U-Boot commands which need to take '0x10' as input will interpret it correctly, regardless of the way these other commands implement ascii-to-integer conversion.'Almost all U-Boot commands expect numbers to be entered in hexadecimal input format.' [1]
The filesystem commands use
simple_strtoul(.., 16)and interpret the value as hexadecimal value.The 0x suggests that a 10 will be interpreted as decimal value and this isn't true.
Quoted 13 lines
Quoted 4 lines
Quoted 1 line
This is inconsistent with other values in the command
It could be, but it is then better to fix the inconsistency in those commands/sub-commands which add the ambiguity.
Normally you are right but U-Boot by design use hexadecimal values without 0x. The
env_set_hexfunctions doesn't use 0x.Quoted 5 lines
Quoted 1 line
and U-Boot uses hexadecimal values generally.
The key word is "generally", but not always. Some U-Boot commands will process '10' as HEX 10 and some will process 10 as DEC 10. So, in order to avoid these games, I vote for leaving the 0x in place.
I would be very surprised if 10 means 0d10 in a partition number. I agree that putting a 0x in these values is a dangerous precedent and will just cause confusion. U-Boot uses hex for addresses and most arguments
Quoted 1 line
Quoted 31 lines
Quoted 2 lines
You can avoid it only if you could mark decimal numbers and that is impossible.
0d10 is available. People are not used to it though.
Reviewed-by Simon Glass <[email protected]>Quoted 24 lines
@Tom: Does U-Boot still expect numbers to be hexadecimal values?
[1] https://www.denx.de/wiki/DULG/UBootCommandLineInterface
Quoted 19 lines
Quoted 18 lines
Signed-off-by Stefan Herbrechtsmeier <[email protected]>---
cmd/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)cmd/part.c +1
-1@@ -152,7 +152,7 @@ static int do_part_info(int argc, char *const argv[], enum cmd_part_info param)snprintf (buf,sizeof (buf),LBAF , info.size);break ;case CMD_PART_INFO_NUMBER : -snprintf (buf,sizeof (buf),"0x%x" , part); +snprintf (buf,sizeof (buf),"%x" , part);Quoted 3 lines
I am not a fan of this change as well, especially having spent time on some platforms that have literally 20+ partition entries. Being clear here that this is a hex value is important.
But isn't it confusing to use a 0x for a value which is treated as hexadecimal value by the commands independent of the 0x. The 0x results in the assumption that the partition is a decimal value without the 0x.
What is the correct way to convert a hexadecimal value into a decimal value on the shell? I need a value without prefix (decimal value) to pass it to the root parameter of the bootargs.
At the moment the different default numeral systems of common functions like load and test are very irritating. The load command uses hexadecimal value and doesn't support decimal value. The test command uses decimal value by default but supports hexadecimal values with a prefix. This means that the returned variable filesize of the command load couldn't be checked by test and the user have to use the itest command.
Quoted 5 lines
Quoted 3 lines
Let's use hex where possible. I am not sure what to do with the test command, nor how often we use 'test' with addresses, but I think adding an option to 'test' to make it use hex or dec would be good.
But what is the difference to test vs itest?
Well at present test uses decimal by default, unfortunately.
Quoted 4 lines
Quoted 2 lines
Then one day we could change the default to hex.
Is this possible? This would be a breaking change.
I'll see if I can do a patch.
Quoted 8 lines
I think the main problem is the unclear default numeral system. It would be much easy if every number without a prefix have the same numeral system. This would mean that a
simple_strtoul(.., 0)would fall back to the default numeral system if the value hasn't any prefix (0x or 0d). At the momentsimple_strtoul(.., 0)fall back to decimal and many commands use different numeral systems (simple_strtoul(.., 10)orsimple_strtoul(.., 16)).
Yes, that seems right to me. The '0' should default to hex.
Quoted 4 lines
Independent of this problem I need a command to convert a value to decimal without any prefix. Can you recommend any command or should I add a printf command?
I don't know of any, so a way to snprintf into an env var seems useful.
Regards,
Simon