From mboxrd@z Thu Jan 1 00:00:00 1970 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 4C580C433F5 for ; Mon, 17 Jan 2022 20:21:07 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 36C9D81E3E; Mon, 17 Jan 2022 21:21:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=arvanta.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 665E480FE4; Mon, 17 Jan 2022 21:21:03 +0100 (CET) Received: from fx.arvanta.net (static-213-198-238-194.adsl.eunet.rs [213.198.238.194]) by phobos.denx.de (Postfix) with ESMTP id 2201D82A71 for ; Mon, 17 Jan 2022 21:21:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=arvanta.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mps@arvanta.net Received: from m1 (unknown [10.5.1.15]) by fx.arvanta.net (Postfix) with ESMTP id 238DE27620; Mon, 17 Jan 2022 21:20:59 +0100 (CET) Date: Mon, 17 Jan 2022 21:20:58 +0100 From: Milan =?utf-8?Q?P=2E_Stani=C4=87?= To: Heinrich Schuchardt Cc: Tom Rini , Simon Glass , Alexandru Gagniuc , Thomas Hebb , Yann Dirson , Joel Stanley , u-boot@lists.denx.de Subject: Re: [PATCH 1/1] mkimage: struct stat.st_size may not be long Message-ID: References: <20220115191256.118920-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220115191256.118920-1-heinrich.schuchardt@canonical.com> 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.2 at phobos.denx.de X-Virus-Status: Clean It fixes these warnings below. On Sat, 2022-01-15 at 20:12, Heinrich Schuchardt wrote: > The component st_size of struct stat is of type off_t. Depending on the > system printing it it with %ld leads to a warning: > > tools/mkimage.c:438:54: warning: format '%ld' expects argument of type > 'long int', but argument 5 has type > 'off_t' {aka 'long long int'} [-Wformat=] > 438 | "%s: Bad size: \"%s\" is not valid image: size %ld < %u\n", > | ~~^ > | | > | long int > | %lld > > When comparing an off_t value to a 32bit integer we should not convert to > uint32_t but to off_t which may be wider. > > Reported-by: Milan P. Stanić > Fixes: 331f0800f1a3 ("mkimage: allow -l to work on block devices on Linux") > Signed-off-by: Heinrich Schuchardt Tested by: Milan P. Stanić > --- > tools/mkimage.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/tools/mkimage.c b/tools/mkimage.c > index fbe883ce36..79042be828 100644 > --- a/tools/mkimage.c > +++ b/tools/mkimage.c > @@ -433,11 +433,12 @@ int main(int argc, char **argv) > params.cmdname, params.imagefile); > exit (EXIT_FAILURE); > #endif > - } else if ((unsigned)sbuf.st_size < tparams->header_size) { > + } else if (sbuf.st_size < (off_t)tparams->header_size) { > fprintf (stderr, > - "%s: Bad size: \"%s\" is not valid image: size %ld < %u\n", > + "%s: Bad size: \"%s\" is not valid image: size %llu < %u\n", > params.cmdname, params.imagefile, > - sbuf.st_size, tparams->header_size); > + (unsigned long long) sbuf.st_size, > + tparams->header_size); > exit (EXIT_FAILURE); > } else { > size = sbuf.st_size; > -- > 2.33.1 >