Skip to contentSkip to conversation

scripts/dtc: fix '%zx' warning

PATCH New Russell King 4 participants 8 messages Jul 25, 2017 – Sep 1, 2017 Device tree

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/dtc: fix '%zx' warning

dtc uses an incorrect format specifier for printing a uint64_t value. uint64_t may be either 'unsigned long' or 'unsigned long long' depending on the host architecture.

Fix this by using %llx and casting to unsigned long long, which ensures that we always have a wide enough variable to print 64 bits of hex.

HOSTCC scripts/dtc/checks.o
scripts/dtc/checks.c: In function 'check_simple_bus_reg':
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]
snprintf(unit_addr, sizeof(unit_addr), "%zx", reg);
^
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]

Fixes 828d4cdd012c ("dtc: check.c fix compile error")
---
 scripts/dtc/checks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I've been carrying this patch for some time, but I guess hardly anyone builds DT based kernels on 32-bit x86 boxes anymore as it has remained unfixed.

scripts/dtc/checks.c +1 -1
index 4b72b530c84f..62ea8f83d4a0 100644
@@ -873,7 +873,7 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no
 	while (size--)
 		reg = (reg << 32) | fdt32_to_cpu(*(cells++));
 
-	snprintf(unit_addr, sizeof(unit_addr), "%zx", reg);
+	snprintf(unit_addr, sizeof(unit_addr), "%llx", (unsigned long long)reg);
 	if (!streq(unitname, unit_addr))
 		FAIL(c, dti, "Node %s simple-bus unit address format error, expected \"%s\"",
 		     node->fullpath, unit_addr);
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 scripts/dtc: fix '%zx' warning

Quoted 14 lines · Russell King

dtc uses an incorrect format specifier for printing a uint64_t value. uint64_t may be either 'unsigned long' or 'unsigned long long' depending on the host architecture.

Fix this by using %llx and casting to unsigned long long, which ensures that we always have a wide enough variable to print 64 bits of hex.

HOSTCC scripts/dtc/checks.o
scripts/dtc/checks.c: In function 'check_simple_bus_reg':
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]
snprintf(unit_addr, sizeof(unit_addr), "%zx", reg);
^
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]

Quoted 2 lines
Fixes 828d4cdd012c ("dtc: check.c fix compile error")

This (embarrassing) error is already fixed in upstream dtc.

Quoted 21 lines
---
 scripts/dtc/checks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I've been carrying this patch for some time, but I guess hardly anyone builds DT based kernels on 32-bit x86 boxes anymore as it has remained unfixed.

scripts/dtc/checks.c +1 -1
index 4b72b530c84f..62ea8f83d4a0 100644
@@ -873,7 +873,7 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no
 	while (size--)
 		reg = (reg << 32) | fdt32_to_cpu(*(cells++));
 
-	snprintf(unit_addr, sizeof(unit_addr), "%zx", reg);
+	snprintf(unit_addr, sizeof(unit_addr), "%llx", (unsigned long long)reg);
 	if (!streq(unitname, unit_addr))
 		FAIL(c, dti, "Node %s simple-bus unit address format error, expected \"%s\"",
 		     node->fullpath, unit_addr);
Signature · 11 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170726/f55751a8/attachment.sig>
#2 lore raw

PATCH 1/1 scripts/dtc: fix '%zx' warning

Quoted 15 lines · David Gibson
Quoted 14 lines · Russell King

dtc uses an incorrect format specifier for printing a uint64_t value. uint64_t may be either 'unsigned long' or 'unsigned long long' depending on the host architecture.

Fix this by using %llx and casting to unsigned long long, which ensures that we always have a wide enough variable to print 64 bits of hex.

HOSTCC scripts/dtc/checks.o
scripts/dtc/checks.c: In function 'check_simple_bus_reg':
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]
snprintf(unit_addr, sizeof(unit_addr), "%zx", reg);
^
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]

Quoted 4 lines
Quoted 2 lines
Fixes 828d4cdd012c ("dtc: check.c fix compile error")

This (embarrassing) error is already fixed in upstream dtc.

It remains unfixed in 4.13-rc4. How do we get this fixed in the kernel's dtc? From what I can see, sending a patch to fix stuff doesn't work.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
#3 lore raw

PATCH 1/1 scripts/dtc: fix '%zx' warning

Quoted 16 lines · Russell King - ARM Linux
Quoted 15 lines · David Gibson
Quoted 14 lines · Russell King

dtc uses an incorrect format specifier for printing a uint64_t value. uint64_t may be either 'unsigned long' or 'unsigned long long' depending on the host architecture.

Fix this by using %llx and casting to unsigned long long, which ensures that we always have a wide enough variable to print 64 bits of hex.

HOSTCC scripts/dtc/checks.o
scripts/dtc/checks.c: In function 'check_simple_bus_reg':
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]
snprintf(unit_addr, sizeof(unit_addr), "%zx", reg);
^
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes 828d4cdd012c ("dtc: check.c fix compile error")

This (embarrassing) error is already fixed in upstream dtc.

It remains unfixed in 4.13-rc4. How do we get this fixed in the kernel's dtc? From what I can see, sending a patch to fix stuff doesn't work.

Um.. I don't know. I haven't been the person doing updates of the kernel dtc to match upstream dtc for ages.

Signature · 11 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170809/a642415a/attachment.sig>
#4 lore raw

PATCH 1/1 scripts/dtc: fix '%zx' warning

Quoted 17 lines · David Gibson
Quoted 16 lines · Russell King - ARM Linux
Quoted 15 lines · David Gibson
Quoted 14 lines · Russell King

dtc uses an incorrect format specifier for printing a uint64_t value. uint64_t may be either 'unsigned long' or 'unsigned long long' depending on the host architecture.

Fix this by using %llx and casting to unsigned long long, which ensures that we always have a wide enough variable to print 64 bits of hex.

HOSTCC scripts/dtc/checks.o
scripts/dtc/checks.c: In function 'check_simple_bus_reg':
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]
snprintf(unit_addr, sizeof(unit_addr), "%zx", reg);
^
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes 828d4cdd012c ("dtc: check.c fix compile error")

This (embarrassing) error is already fixed in upstream dtc.

It remains unfixed in 4.13-rc4. How do we get this fixed in the kernel's dtc? From what I can see, sending a patch to fix stuff doesn't work.

Sorry, didn't see this until Andrew M picked it up.

Quoted 2 lines

Um.. I don't know. I haven't been the person doing updates of the kernel dtc to match upstream dtc for ages.

The flow is submit a patch to upstream dtc on devicetree-compiler at vger.kernel.org and then bug me to cherry-pick or sync dtc.

I will cherry-pick the upstream version.

Rob

#5 lore raw

PATCH 1/1 scripts/dtc: fix '%zx' warning

Quoted 22 lines · Rob Herring
Quoted 20 lines · David Gibson
Quoted 19 lines · Russell King - ARM Linux
Quoted 18 lines · David Gibson
Quoted 16 lines · Russell King

dtc uses an incorrect format specifier for printing a uint64_t value. uint64_t may be either 'unsigned long' or 'unsigned long long' depending on the host architecture.

Fix this by using %llx and casting to unsigned long long, which ensures that we always have a wide enough variable to print 64 bits of hex.

HOSTCC scripts/dtc/checks.o
scripts/dtc/checks.c: In function 'check_simple_bus_reg':
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]
snprintf(unit_addr, sizeof(unit_addr), "%zx", reg);
^
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]

Fixes 828d4cdd012c ("dtc: check.c fix compile error")
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

This (embarrassing) error is already fixed in upstream dtc.

It remains unfixed in 4.13-rc4. How do we get this fixed in the kernel's dtc? From what I can see, sending a patch to fix stuff doesn't work.

Sorry, didn't see this until Andrew M picked it up.

How do we know whether whatever is in upstream dtc fixes the problem that I'm seeing?

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
#6 lore raw

PATCH 1/1 scripts/dtc: fix '%zx' warning

Quoted 25 lines · Russell King - ARM Linux
Quoted 24 lines · Rob Herring
Quoted 22 lines · David Gibson
Quoted 21 lines · Russell King - ARM Linux
Quoted 19 lines · David Gibson
Quoted 14 lines · Russell King

dtc uses an incorrect format specifier for printing a uint64_t value. uint64_t may be either 'unsigned long' or 'unsigned long long' depending on the host architecture.

Fix this by using %llx and casting to unsigned long long, which ensures that we always have a wide enough variable to print 64 bits of hex.

HOSTCC scripts/dtc/checks.o
scripts/dtc/checks.c: In function 'check_simple_bus_reg':
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]
snprintf(unit_addr, sizeof(unit_addr), "%zx", reg);
^
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]

Quoted 2 lines
Fixes 828d4cdd012c ("dtc: check.c fix compile error")

This (embarrassing) error is already fixed in upstream dtc.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

It remains unfixed in 4.13-rc4. How do we get this fixed in the kernel's dtc? From what I can see, sending a patch to fix stuff doesn't work.

Sorry, didn't see this until Andrew M picked it up.

How do we know whether whatever is in upstream dtc fixes the problem that I'm seeing?

Build upstream dtc or here's a branch[1] with the cherry-picked fix.

Rob

[1] git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git dt/testing

#7 lore raw

PATCH 1/1 scripts/dtc: fix '%zx' warning

Quoted 31 lines · Rob Herring
Quoted 29 lines · Russell King - ARM Linux
Quoted 28 lines · Rob Herring
Quoted 25 lines · David Gibson
Quoted 24 lines · Russell King - ARM Linux
Quoted 15 lines · David Gibson
Quoted 14 lines · Russell King

dtc uses an incorrect format specifier for printing a uint64_t value. uint64_t may be either 'unsigned long' or 'unsigned long long' depending on the host architecture.

Fix this by using %llx and casting to unsigned long long, which ensures that we always have a wide enough variable to print 64 bits of hex.

HOSTCC scripts/dtc/checks.o
scripts/dtc/checks.c: In function 'check_simple_bus_reg':
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]
snprintf(unit_addr, sizeof(unit_addr), "%zx", reg);
^
scripts/dtc/checks.c:876:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'uint64_t' [-Wformat=]

Quoted 4 lines
Quoted 2 lines
Fixes 828d4cdd012c ("dtc: check.c fix compile error")

This (embarrassing) error is already fixed in upstream dtc.

It remains unfixed in 4.13-rc4. How do we get this fixed in the kernel's dtc? From what I can see, sending a patch to fix stuff doesn't work.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Sorry, didn't see this until Andrew M picked it up.

How do we know whether whatever is in upstream dtc fixes the problem that I'm seeing?

Build upstream dtc or here's a branch[1] with the cherry-picked fix.

Well, your fix went in before I got the cherry-pick sent to Linus. Still, let me know if there's any issue with the upstream fix because when I sync dtc this fix is going to be overwritten with upstream.

Rob