Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D6C3C04A6A for ; Mon, 14 Aug 2023 04:36:16 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7502986297; Mon, 14 Aug 2023 06:36:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="aK/BPggF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 63A8286297; Mon, 14 Aug 2023 06:36:13 +0200 (CEST) Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5D2E886233 for ; Mon, 14 Aug 2023 06:36:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=s-vadapalli@ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 37E4a7kM125835; Sun, 13 Aug 2023 23:36:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1691987767; bh=uzRDp7ybgK2ILMg5o+T1crxrMBLJmYoHTPayb/wr21U=; h=Date:CC:Subject:To:References:From:In-Reply-To; b=aK/BPggFn4dIIEiffvvgl4EBqql7yTzPHJogf1SqnwI72CCibsDwYDwUrchlvt8yF eytFz6aEmZbxlTMA78X2gDkEhL4tBqEB8vFjGOCFbI7/1Ypp7NsD9mxXDlE6578Xo+ 87/zxlmnYnHbkAtrCO1FwawYROLFHjUvqa7Ze8Og= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 37E4a7Mm028195 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 13 Aug 2023 23:36:07 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Sun, 13 Aug 2023 23:36:07 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Sun, 13 Aug 2023 23:36:07 -0500 Received: from [172.24.227.9] (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 37E4a4Ir010723; Sun, 13 Aug 2023 23:36:05 -0500 Message-ID: <8a2cb2a1-dc23-44d3-b046-008807060810@ti.com> Date: Mon, 14 Aug 2023 10:06:04 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 CC: Ravi Gunasekaran , , , , , Subject: Re: [PATCH] net: Fix the displayed value of bytes transferred To: Tom Rini References: <20230810091523.3168975-1-s-vadapalli@ti.com> <133136bd-c721-1014-0b06-f57f7cc18d50@ti.com> <00c8bbca-28c8-4d22-4cc8-16f40146d252@ti.com> <20230811161539.GF3630934@bill-the-cat> Content-Language: en-US From: Siddharth Vadapalli In-Reply-To: <20230811161539.GF3630934@bill-the-cat> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Hello Tom, On 11/08/23 21:45, Tom Rini wrote: > On Fri, Aug 11, 2023 at 10:49:23AM +0530, Siddharth Vadapalli wrote: >> 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 >>>> --- >>>> 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 > > Uh, maybe I'm just missing something, but I think there's two things. > First, this should be "%u" for "unsigned decimal". Second, > doc/develop/printf.rst needs to be fixed since: > int %d, %x > unsigned int %d, %x > > Should is wrong and should say %u, %x, because, well, that's what would > be correct, yes? Thank you for reviewing the patch. Yes, %u works well and can print u32 variable accurately. I tested it for 0xffffffff. %d prints -1 for the same. So, %lu isn't necessary and %u is sufficient. I will replace %lu with %u and post the v2 patch. Additionally, I will include a patch in the v2 series to update the Documentation as pointed out by you. > -- Regards, Siddharth.