Skip to contentSkip to conversation

tools: image-host.c: use correct output format

PATCH New Heinrich Schuchardt 3 participants 3 messages Oct 8, 2020 – Oct 23, 2020

lore
Share & tools
lore
#0 lore raw

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

When building on a 32bit host the following warning occurs:

tools/image-host.c: In function ?fit_image_read_data?:
tools/image-host.c:296:56: warning: format ?%ld? expects argument of type ?long int?, but argument 3 has type ?__off64_t?
{aka ?long long int?} [-Wformat=]
printf("File %s don't have the expected size (size=%ld, expected=%d)\n",

                                                      ~~^
                                                      %lld
          filename, sbuf.st_size, expected_size);
                    ~~~~~~~~~~~~

tools/image-host.c:311:62: warning: format ?%ld? expects argument of type ?long int?, but argument 4 has type ?__off64_t?
{aka ?long long int?} [-Wformat=]
printf("Can't read all file %s (read %zd bytes, expexted %ld)\n",

                                                            ~~^
                                                            %lld
          filename, n, sbuf.st_size);
                       ~~~~~~~~~~~~

Fix the format strings.

---
 tools/image-host.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/image-host.c +4 -4
index 9a83b7f675..10e66cdaa2 100644
@@ -293,8 +293,8 @@ static int fit_image_read_data(char *filename, unsigned char *data,
 
 	/* Check file size */
 	if (sbuf.st_size != expected_size) {
-		printf("File %s don't have the expected size (size=%ld, expected=%d)\n",
-		       filename, sbuf.st_size, expected_size);
+		printf("File %s don't have the expected size (size=%lld, expected=%d)\n",
+		       filename, (long long)sbuf.st_size, expected_size);
 		goto err;
 	}
 
@@ -308,8 +308,8 @@ 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 %zd bytes, expexted %ld)\n",
-		       filename, n, sbuf.st_size);
+		printf("Can't read all file %s (read %zd bytes, expexted %lld)\n",
+		       filename, n, (long long)sbuf.st_size);
 		goto err;
 	}
 

--
2.26.2

#1 lore raw

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

Quoted 21 lines · Heinrich Schuchardt

When building on a 32bit host the following warning occurs:

tools/image-host.c: In function ?fit_image_read_data?:
tools/image-host.c:296:56: warning: format ?%ld? expects argument of type ?long int?, but argument 3 has type ?__off64_t?
{aka ?long long int?} [-Wformat=]
printf("File %s don't have the expected size (size=%ld, expected=%d)\n",

                                                      ~~^
                                                      %lld
          filename, sbuf.st_size, expected_size);
                    ~~~~~~~~~~~~

tools/image-host.c:311:62: warning: format ?%ld? expects argument of type ?long int?, but argument 4 has type ?__off64_t?
{aka ?long long int?} [-Wformat=]
printf("Can't read all file %s (read %zd bytes, expexted %ld)\n",

                                                            ~~^
                                                            %lld
          filename, n, sbuf.st_size);
                       ~~~~~~~~~~~~
Quoted 7 lines

Fix the format strings.

---
 tools/image-host.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
#2 lore raw

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

In reply to Heinrich Schuchardt
Quoted 20 lines · Heinrich Schuchardt

When building on a 32bit host the following warning occurs:

tools/image-host.c: In function ?fit_image_read_data?:
tools/image-host.c:296:56: warning: format ?%ld? expects argument of type ?long int?, but argument 3 has type ?__off64_t?
{aka ?long long int?} [-Wformat=]
printf("File %s don't have the expected size (size=%ld, expected=%d)\n",

                                                      ~~^
                                                      %lld
          filename, sbuf.st_size, expected_size);
                    ~~~~~~~~~~~~

tools/image-host.c:311:62: warning: format ?%ld? expects argument of type ?long int?, but argument 4 has type ?__off64_t?
{aka ?long long int?} [-Wformat=]
printf("Can't read all file %s (read %zd bytes, expexted %ld)\n",

                                                            ~~^
                                                            %lld
          filename, n, sbuf.st_size);
                       ~~~~~~~~~~~~
Quoted 4 lines

Fix the format strings.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201022/356b1f9f/attachment.sig>