From: "Milan P. Stanić" <mps@arvanta.net>
To: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Cc: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
Alexandru Gagniuc <mr.nuke.me@gmail.com>,
Thomas Hebb <tommyhebb@gmail.com>,
Yann Dirson <yann@blade-group.com>, Joel Stanley <joel@jms.id.au>,
u-boot@lists.denx.de
Subject: Re: [PATCH 1/1] mkimage: struct stat.st_size may not be long
Date: Mon, 17 Jan 2022 21:20:58 +0100 [thread overview]
Message-ID: <YeXPqkuKYvYWkvcv@m1> (raw)
In-Reply-To: <20220115191256.118920-1-heinrich.schuchardt@canonical.com>
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ć <mps@arvanta.net>
> Fixes: 331f0800f1a3 ("mkimage: allow -l to work on block devices on Linux")
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Tested by: Milan P. Stanić <mps@arvanta.net>
> ---
> 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
>
next prev parent reply other threads:[~2022-01-17 20:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-15 19:12 [PATCH 1/1] mkimage: struct stat.st_size may not be long Heinrich Schuchardt
2022-01-17 20:20 ` Milan P. Stanić [this message]
2022-01-17 20:35 ` Mark Kettenis
2022-01-24 16:53 ` Tom Rini
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=YeXPqkuKYvYWkvcv@m1 \
--to=mps@arvanta.net \
--cc=heinrich.schuchardt@canonical.com \
--cc=joel@jms.id.au \
--cc=mr.nuke.me@gmail.com \
--cc=sjg@chromium.org \
--cc=tommyhebb@gmail.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=yann@blade-group.com \
/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