Fix format specifier for net_boot_file_size
v2 cover Fix format specifier for net_boot_file_size
Hello,
This series fixes the format specifier for printing the decimal value of the variable "net_boot_file_size", changing it from "%d" to "%u". With the format specifier being "%d", for large file sizes, the value displayed is negative. Using "%u" fixes this.
Additionally, as reported by Tom Rini <[email protected]> in the mail thread corresponding to the v1 patch of this series, the documentation for the printf format specifiers needs to be fixed for the "unsigned int" variable. Thus, update the documentation as well.
Regards,
Siddharth.
---
v1:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Changes since v1:
- Use "%u" instead of "%lu" to display the decimal value of the u32 variable "net_boot_file_size", as suggested by Tom Rini.
- Add a new patch to update the documentation for printf format specifiers, changing the format specifier from "%d" to "%u" for the "unsigned int" variable, as reported by Tom Rini.
Siddharth Vadapalli (2):
net: Fix the displayed value of bytes transferred
doc: printf() codes: Fix format specifier for unsigned int
doc/develop/printf.rst | 2 +- net/net.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/2 net: Fix the displayed value of bytes transferred
In the case of NETLOOP_SUCCESS, the decimal value of the u32 variable "net_boot_file_size" is printed using "%d", resulting in negative values being reported for large file sizes. Fix this by using "%u" to print the decimal value corresponding to the bytes transferred.
--- net/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/net.c +1 -1
@@ -716,7 +716,7 @@ restart:case NETLOOP_SUCCESS :net_cleanup_loop ();if (net_boot_file_size >0 ) { -printf ("Bytes transferred = %d (%x hex)\n" , +printf ("Bytes transferred = %u (%x hex)\n" , net_boot_file_size, net_boot_file_size);env_set_hex ("filesize" , net_boot_file_size);env_set_hex ("fileaddr" , image_load_addr);
Signature · 1 line
2.34.1
Re: [PATCH v2 1/2] net: Fix the displayed value of bytes transferred
Quoted 7 lines · Siddharth Vadapalli
In the case of
NETLOOP_SUCCESS, the decimal value of the u32 variable "net_boot_file_size" is printed using "%d", resulting in negative values being reported for large file sizes. Fix this by using "%u" to print the decimal value corresponding to the bytes transferred.Fixes 1411157d8578 ("net: cosmetic: Fixup var names related to boot file")Signed-off-by Siddharth Vadapalli <[email protected]>
Signature · 1 line
Tom
Re: [PATCH v2 1/2] net: Fix the displayed value of bytes transferred
In reply to Siddharth VadapalliQuoted 8 lines · Siddharth Vadapalli
In the case of
NETLOOP_SUCCESS, the decimal value of the u32 variable "net_boot_file_size" is printed using "%d", resulting in negative values being reported for large file sizes. Fix this by using "%u" to print the decimal value corresponding to the bytes transferred.Fixes 1411157d8578 ("net: cosmetic: Fixup var names related to boot file")Signed-off-by Siddharth Vadapalli <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom
PATCH v2 2/2 doc: printf() codes: Fix format specifier for unsigned int
In reply to Siddharth VadapalliThe format specifier for the "unsigned int" variable is documented as "%d". However, it should be "%u". Thus, fix it.
--- doc/develop/printf.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
doc/develop/printf.rst +1 -1
@@ -111,7 +111,7 @@ unsigned char %u, %x short %d, %x unsigned short %u, %x int %d, %x -unsigned int %d, %x +unsigned int %u, %x long %ld, %lx unsigned long %lu, %lx long long %lld, %llx
Signature · 1 line
2.34.1
Re: [PATCH v2 2/2] doc: printf() codes: Fix format specifier for unsigned int
Quoted 6 lines · Siddharth Vadapalli
The format specifier for the "unsigned int" variable is documented as "%d". However, it should be "%u". Thus, fix it.
Fixes f5e9035043fb ("doc: printf() codes")Reported-by Tom Rini <[email protected]>Signed-off-by Siddharth Vadapalli <[email protected]>
Signature · 1 line
Tom