Skip to contentSkip to conversation

Fix format specifier for net_boot_file_size

PATCH In review Siddharth Vadapalli 2 participants 6 messages Aug 14, 2023 – Aug 23, 2023 Networking

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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.

Fixes 1411157d8578 ("net: cosmetic: Fixup var names related to boot file")
---
 net/net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/net.c +1 -1
index 43abbac7c3..e6f61f0f8f 100644
@@ -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
Reviewed-by on v2 1/2
#2 lore raw

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")
Signature · 1 line
Tom
#3 lore raw

Re: [PATCH v2 1/2] net: Fix the displayed value of bytes transferred

In reply to Siddharth Vadapalli
Quoted 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")

Applied to u-boot/next, thanks!

Signature · 1 line
Tom
#4 lore raw

PATCH v2 2/2 doc: printf() codes: Fix format specifier for unsigned int

In reply to 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")
---
 doc/develop/printf.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
doc/develop/printf.rst +1 -1
index 7b9aea0687..05909a1f22 100644
@@ -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