[PATCH] net: Fix the displayed value of bytes transferred
    Ravi Gunasekaran 
    r-gunasekaran at ti.com
       
    Thu Aug 10 13:30:02 CEST 2023
    
    
  
Siddharth,
On 8/10/23 2:45 PM, Siddharth Vadapalli wrote:
> 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 "%lu" 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 <s-vadapalli at ti.com>
> ---
>  net/net.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/net.c b/net/net.c
> index 43abbac7c3..7aaeafc247 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -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 = %lu (%x hex)\n",
'net_boot_file_size' is of type u32. Using "%lu" will throw a warning for this.
As per [0], format specifier for 'unsigned int' is "%d, %x'.
You could perhaps change the data type of 'net_boot_file_size' to 'ulong' as well.
[0] - https://u-boot.readthedocs.io/en/latest/develop/printf.html
>  				       net_boot_file_size, net_boot_file_size);
>  				env_set_hex("filesize", net_boot_file_size);
>  				env_set_hex("fileaddr", image_load_addr);
-- 
Regards,
Ravi
    
    
More information about the U-Boot
mailing list