diff mbox series

[1/1] tools: image-host.c: use correct output format

Message ID 20200411163604.5208-1-xypron.glpk@gmx.de
State Accepted
Commit b21c08a12b8ebeea0cb77830d662ee118245774e
Headers show
Series [1/1] tools: image-host.c: use correct output format | expand

Commit Message

Heinrich Schuchardt April 11, 2020, 4:36 p.m. UTC
When building on a 32bit host the following warning occurs:

tools/image-host.c: In function ?fit_image_read_data?:
tools/image-host.c:310:42: warning: format ?%ld? expects argument of type
?long int?, but argument 3 has type ?ssize_t? {aka ?int?} [-Wformat=]
   printf("Can't read all file %s (read %ld bytes, expexted %ld)\n",
                                        ~~^
                                        %d
          filename, n, sbuf.st_size);
                    ~

n is of type ssize_t so we should use %zd for printing.

Fixes: 7298e422504e ("mkimage: fit: add support to encrypt image with aes")
Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 tools/image-host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.25.1

Comments

Simon Glass April 19, 2020, 11:37 p.m. UTC | #1
On Sat, 11 Apr 2020 at 10:36, Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
>
> When building on a 32bit host the following warning occurs:
>
> tools/image-host.c: In function ?fit_image_read_data?:
> tools/image-host.c:310:42: warning: format ?%ld? expects argument of type
> ?long int?, but argument 3 has type ?ssize_t? {aka ?int?} [-Wformat=]
>    printf("Can't read all file %s (read %ld bytes, expexted %ld)\n",
>                                         ~~^
>                                         %d
>           filename, n, sbuf.st_size);
>                     ~
>
> n is of type ssize_t so we should use %zd for printing.
>
> Fixes: 7298e422504e ("mkimage: fit: add support to encrypt image with aes")
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
>  tools/image-host.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg at chromium.org>
Tom Rini April 24, 2020, 5:11 p.m. UTC | #2
On Sat, Apr 11, 2020 at 06:36:04PM +0200, Heinrich Schuchardt wrote:

> When building on a 32bit host the following warning occurs:
> 
> tools/image-host.c: In function ?fit_image_read_data?:
> tools/image-host.c:310:42: warning: format ?%ld? expects argument of type
> ?long int?, but argument 3 has type ?ssize_t? {aka ?int?} [-Wformat=]
>    printf("Can't read all file %s (read %ld bytes, expexted %ld)\n",
>                                         ~~^
>                                         %d
>           filename, n, sbuf.st_size);
>                     ~
> 
> n is of type ssize_t so we should use %zd for printing.
> 
> Fixes: 7298e422504e ("mkimage: fit: add support to encrypt image with aes")
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> Reviewed-by: Simon Glass <sjg at chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/tools/image-host.c b/tools/image-host.c
index 4e57ddea96..5bb68965e7 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -307,7 +307,7 @@  static int fit_image_read_data(char *filename, unsigned char *data,

 	/* Check that we have read all the file */
 	if (n != sbuf.st_size) {
-		printf("Can't read all file %s (read %ld bytes, expexted %ld)\n",
+		printf("Can't read all file %s (read %zd bytes, expexted %ld)\n",
 		       filename, n, sbuf.st_size);
 		goto err;
 	}