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 D72CBC001DE for ; Fri, 11 Aug 2023 16:15:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D07C586377; Fri, 11 Aug 2023 18:15:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.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=konsulko.com header.i=@konsulko.com header.b="Ehqa6l4d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D4770863F0; Fri, 11 Aug 2023 18:15:46 +0200 (CEST) Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 86F1D85C98 for ; Fri, 11 Aug 2023 18:15:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qk1-x731.google.com with SMTP id af79cd13be357-76cab6fe9c0so176201385a.0 for ; Fri, 11 Aug 2023 09:15:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1691770543; x=1692375343; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=mXSWYp/msIM8WzN19pQrAXAR/Pm3ouBhngn4EZxxyg4=; b=Ehqa6l4da/2tZjEr0A4O7TK6/qJ/+bYv5+8oueTkB96G12QSN4i3K8k/9y2DLM1x/A 0HO2vynyAJziGcgzTy1yONFAOLjB6OClHiJ5wE0DEfqDcDVm3KNycIYItsJixzNE4+rF H6fPRV31wqUc48BV6Svs4P/dqHMkcFxUzgzew= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691770543; x=1692375343; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mXSWYp/msIM8WzN19pQrAXAR/Pm3ouBhngn4EZxxyg4=; b=LEIX6XAtQLdNk6IDOA5W+CL5d4R23qgtESXwTAmQ0KZSSBffk+9JQQ3qACZbKq6orz Tl7yeVz547MN7Vd/6WSbPB+gKe9HxAz1xE6+0Lxudqw633vzAUw7GfmdxfEzymLM9DV5 8f1EixAKblptwriIM/BD+RymTSSh5VttiH4UMnYsg1dav18rY2VkvPXBnV6NENrSwF/s XAysIDD8Y+DpCYcqds+w4LCF2KjQY2DccdqAJ4GdJguw9KSM3YVDHOCOYO5Zh5AKQ222 m2CD6NHICEOvyu4oj15Us2WtfVGHT8lDzEj1JiBjOWrhlYAmbdOhzgDTbV/u3EkjySJY lV4A== X-Gm-Message-State: AOJu0YwcJc+K0LMNQvcw0WdL5l2tWTo+5DaEmxubSKvTWLyN89Tx7swo 3s9Sd+WH2gXSQAx2bJ1WRw1dzA== X-Google-Smtp-Source: AGHT+IE3l5Jz7eTcKSoJtucP3orZdinWlpxPFuwWBNz1ijP0zXWBYHjmC+YvaLLt4ZUBQLUIQJFyfQ== X-Received: by 2002:ac8:5dd2:0:b0:410:c8e:570f with SMTP id e18-20020ac85dd2000000b004100c8e570fmr2635367qtx.61.1691770543266; Fri, 11 Aug 2023 09:15:43 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b00-6400-b133-f454-a438-5224.res6.spectrum.com. [2603:6081:7b00:6400:b133:f454:a438:5224]) by smtp.gmail.com with ESMTPSA id h10-20020ac8714a000000b003f3937c16c4sm1276481qtp.5.2023.08.11.09.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 09:15:42 -0700 (PDT) Date: Fri, 11 Aug 2023 12:15:39 -0400 From: Tom Rini To: Siddharth Vadapalli Cc: Ravi Gunasekaran , joe.hershberger@ni.com, rfried.dev@gmail.com, sjg@chromium.org, u-boot@lists.denx.de Subject: Re: [PATCH] net: Fix the displayed value of bytes transferred Message-ID: <20230811161539.GF3630934@bill-the-cat> References: <20230810091523.3168975-1-s-vadapalli@ti.com> <133136bd-c721-1014-0b06-f57f7cc18d50@ti.com> <00c8bbca-28c8-4d22-4cc8-16f40146d252@ti.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="JLFku25qYTpOo6wh" Content-Disposition: inline In-Reply-To: <00c8bbca-28c8-4d22-4cc8-16f40146d252@ti.com> X-Clacks-Overhead: GNU Terry Pratchett 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 --JLFku25qYTpOo6wh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 11, 2023 at 10:49:23AM +0530, Siddharth Vadapalli wrote: > Ravi, >=20 > On 10/08/23 17:00, Ravi Gunasekaran wrote: > > Siddharth, > >=20 > > 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 valu= es > >> 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 f= ile") > >> 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 =3D %d (%x hex)\n", > >> + printf("Bytes transferred =3D %lu (%x hex)\n", > >=20 > > 'net_boot_file_size' is of type u32. Using "%lu" will throw a warning f= or this. > > As per [0], format specifier for 'unsigned int' is "%d, %x'. > >=20 > > You could perhaps change the data type of 'net_boot_file_size' to 'ulon= g' as well. >=20 > The issue here isn't the size of the variable itself, but the format spec= ifier. > For large file sizes, the hex value printed for the variable is correct, = but the > decimal value is negative. >=20 > >=20 > > [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? --=20 Tom --JLFku25qYTpOo6wh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmTWXqQACgkQFHw5/5Y0 tyw95gv9EZcQw2UtyFnatqStywho+i20vdFcXYe4lYLvCtybDbzT7OKFBvrygicP SzZ6mvOulxcv5EAq+g4lftJq344ITbLpIIaoI7cqpklB+7mJ9oNTkVRvvIYjS/gh QrSqXSlD+akuHBFkIyHOupZH2jygy04WbfgvBBzxJoykfe8YcUOwJM6XoBn1msFx dk/SxpXVskwl4m/6UhfnbXcH+35cVlWNhYgtuib56xLnAEZAkGBfCeq1h6lhmrvq lp04DACylLYArfL6K1hjit8MGQ6S9n+UJ93IH5P4u0fpGppUl0cjRxDx/wzSegZq x4DhN9udEo3UPZkwPMY2oKGWNKvuxTj4j0nYKFQtx8QZTXvVba7m+rKwGiaaA/dZ 2lx1/cAt2m8qdQMm2JWxXdi/xYQ84BvqlMDMYAq1wmlcbVUvZE11CwuL8or+bcmj ai9EOr0odfm2mePZA4jUqqyXyNNo9UaQt3aPYTzrm4ps+IIAjHNfMKJHXfdMG4oQ P8/l5dwg =Wako -----END PGP SIGNATURE----- --JLFku25qYTpOo6wh--