scripts/dtc: fix '%zx' warning
PATCH 6/6 scripts/dtc: fix '%zx' warning
From: Russell King <[email protected]>
Subject: 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.oscripts/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=]
---
scripts/dtc/checks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/dtc/checks.c renamed from scripts/dtc/checks.c~scripts-dtc-fix-%zx-warning +1 -1
@@ -873,7 +873,7 @@ static void check_simple_bus_reg(structwhile (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);
_