public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Siddharth Vadapalli <s-vadapalli@ti.com>
To: Ravi Gunasekaran <r-gunasekaran@ti.com>
Cc: <trini@konsulko.com>, <joe.hershberger@ni.com>,
	<rfried.dev@gmail.com>, <sjg@chromium.org>,
	<u-boot@lists.denx.de>, <s-vadapalli@ti.com>
Subject: Re: [PATCH] net: Fix the displayed value of bytes transferred
Date: Fri, 11 Aug 2023 10:49:23 +0530	[thread overview]
Message-ID: <00c8bbca-28c8-4d22-4cc8-16f40146d252@ti.com> (raw)
In-Reply-To: <133136bd-c721-1014-0b06-f57f7cc18d50@ti.com>

Ravi,

On 10/08/23 17:00, Ravi Gunasekaran wrote:
> 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@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.

The issue here isn't the size of the variable itself, but the format specifier.
For large file sizes, the hex value printed for the variable is correct, but the
decimal value is negative.

> 
> [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,
Siddharth.

  reply	other threads:[~2023-08-11  5:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-10  9:15 [PATCH] net: Fix the displayed value of bytes transferred Siddharth Vadapalli
2023-08-10 11:30 ` Ravi Gunasekaran
2023-08-11  5:19   ` Siddharth Vadapalli [this message]
2023-08-11 16:15     ` Tom Rini
2023-08-14  4:36       ` Siddharth Vadapalli
2023-08-14  4:59         ` Siddharth Vadapalli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=00c8bbca-28c8-4d22-4cc8-16f40146d252@ti.com \
    --to=s-vadapalli@ti.com \
    --cc=joe.hershberger@ni.com \
    --cc=r-gunasekaran@ti.com \
    --cc=rfried.dev@gmail.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox