Browse Source

Use <inttypes.h> format specifiers in a bunch of places we should

Rather than assuming that uint32_t is the same thing as unsigned.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
main
David Gibson 6 years ago
parent
commit
180a939240
  1. 30
      fdtdump.c
  2. 2
      flattree.c

30
fdtdump.c

@ -8,6 +8,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <inttypes.h>


#include <libfdt.h> #include <libfdt.h>
#include <libfdt_env.h> #include <libfdt_env.h>
@ -65,23 +66,24 @@ static void dump_blob(void *blob, bool debug)
shift = 4; shift = 4;


printf("/dts-v1/;\n"); printf("/dts-v1/;\n");
printf("// magic:\t\t0x%x\n", fdt32_to_cpu(bph->magic)); printf("// magic:\t\t0x%"PRIx32"\n", fdt32_to_cpu(bph->magic));
printf("// totalsize:\t\t0x%x (%u)\n", totalsize, totalsize); printf("// totalsize:\t\t0x%"PRIx32" (%"PRIu32")\n",
printf("// off_dt_struct:\t0x%x\n", off_dt); totalsize, totalsize);
printf("// off_dt_strings:\t0x%x\n", off_str); printf("// off_dt_struct:\t0x%"PRIx32"\n", off_dt);
printf("// off_mem_rsvmap:\t0x%x\n", off_mem_rsvmap); printf("// off_dt_strings:\t0x%"PRIx32"\n", off_str);
printf("// version:\t\t%u\n", version); printf("// off_mem_rsvmap:\t0x%"PRIx32"\n", off_mem_rsvmap);
printf("// last_comp_version:\t%u\n", printf("// version:\t\t%"PRIu32"\n", version);
printf("// last_comp_version:\t%"PRIu32"\n",
fdt32_to_cpu(bph->last_comp_version)); fdt32_to_cpu(bph->last_comp_version));
if (version >= 2) if (version >= 2)
printf("// boot_cpuid_phys:\t0x%x\n", printf("// boot_cpuid_phys:\t0x%"PRIx32"\n",
fdt32_to_cpu(bph->boot_cpuid_phys)); fdt32_to_cpu(bph->boot_cpuid_phys));


if (version >= 3) if (version >= 3)
printf("// size_dt_strings:\t0x%x\n", printf("// size_dt_strings:\t0x%"PRIx32"\n",
fdt32_to_cpu(bph->size_dt_strings)); fdt32_to_cpu(bph->size_dt_strings));
if (version >= 17) if (version >= 17)
printf("// size_dt_struct:\t0x%x\n", printf("// size_dt_struct:\t0x%"PRIx32"\n",
fdt32_to_cpu(bph->size_dt_struct)); fdt32_to_cpu(bph->size_dt_struct));
printf("\n"); printf("\n");


@ -91,14 +93,14 @@ static void dump_blob(void *blob, bool debug)
if (addr == 0 && size == 0) if (addr == 0 && size == 0)
break; break;


printf("/memreserve/ %#llx %#llx;\n", printf("/memreserve/ %#"PRIx64" %#"PRIx64";\n",
(unsigned long long)addr, (unsigned long long)size); addr, size);
} }


p = p_struct; p = p_struct;
while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) { while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) {


dumpf("%04zx: tag: 0x%08x (%s)\n", dumpf("%04zx: tag: 0x%08"PRIx32" (%s)\n",
(uintptr_t)p - blob_off - 4, tag, tagname(tag)); (uintptr_t)p - blob_off - 4, tag, tagname(tag));


if (tag == FDT_BEGIN_NODE) { if (tag == FDT_BEGIN_NODE) {
@ -127,7 +129,7 @@ static void dump_blob(void *blob, bool debug)
} }


if (tag != FDT_PROP) { if (tag != FDT_PROP) {
fprintf(stderr, "%*s ** Unknown tag 0x%08x\n", depth * shift, "", tag); fprintf(stderr, "%*s ** Unknown tag 0x%08"PRIx32"\n", depth * shift, "", tag);
break; break;
} }
sz = fdt32_to_cpu(GET_CELL(p)); sz = fdt32_to_cpu(GET_CELL(p));

2
flattree.c

@ -393,7 +393,7 @@ void dt_to_blob(FILE *f, struct dt_info *dti, int version)
padlen = 0; padlen = 0;
if (quiet < 1) if (quiet < 1)
fprintf(stderr, fprintf(stderr,
"Warning: blob size %u >= minimum size %d\n", "Warning: blob size %"PRIu32" >= minimum size %d\n",
fdt32_to_cpu(fdt.totalsize), minsize); fdt32_to_cpu(fdt.totalsize), minsize);
} }
} }

Loading…
Cancel
Save