Skip to contentSkip to conversation

cmd/ubi.c: Fix format warning

PATCH New Tom Rini 2 participants 3 messages Jul 26, 2018

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 cmd/ubi.c: Fix format warning

On 64bit platforms we would otherwise see:
../cmd/ubi.c: In function 'ubi_volume_read':
../cmd/ubi.c:359:16: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'size_t {aka long unsigned int}' [-Wformat=]

Fixes 68c7025d99db ("cmd: ubi: print load size after establishing volume size")
---
 cmd/ubi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/ubi.c +1 -1
index 0e935e34b8e6..04bbd01da396 100644
@@ -356,7 +356,7 @@ int ubi_volume_read(char *volume, char *buf, size_t size)
 		size = vol->used_bytes;
 	}
 
-	printf("Read %u bytes from volume %s to %p\n", size, volume, buf);
+	printf("Read %zd bytes from volume %s to %p\n", size, volume, buf);
 
 	if (vol->corrupted)
 		printf("read from corrupted volume %d", vol->vol_id);
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 cmd/ubi.c: Fix format warning

cmd/ubi.c int ubi_volume_read(char *volume, char *buf, size_t size) · line 359

Quoted 2 lines · Tom Rini
cmd/ubi.c +1 -1
-	printf("Read %u bytes from volume %s to %p\n", size, volume, buf);
+	printf("Read %zd bytes from volume %s to %p\n", size, volume, buf);

Why make it signed? "%zu bytes" should be better.

Martin

author
#2 lore raw

PATCH 1/1 cmd/ubi.c: Fix format warning

Quoted 5 lines · Martin Husemann

cmd/ubi.c int ubi_volume_read(char *volume, char *buf, size_t size) · line 359

Quoted 2 lines · Tom Rini
cmd/ubi.c +1 -1
-	printf("Read %u bytes from volume %s to %p\n", size, volume, buf);
+	printf("Read %zd bytes from volume %s to %p\n", size, volume, buf);

Why make it signed? "%zu bytes" should be better.

Whoops, thanks.

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