[PATCH v1 4/4] printf: Fix format type warnings

Geoff Levand geoff at infradead.org
Sat Jan 6 11:47:39 AEDT 2018


Fixes build warnings like these when building 32 bit programs:

  warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument has type ‘uint64_t’

Signed-off-by: Geoff Levand <geoff at infradead.org>
---
 discover/device-handler.c    | 3 ++-
 discover/devmapper.c         | 3 ++-
 utils/hooks/30-dtb-updates.c | 6 +++---
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/discover/device-handler.c b/discover/device-handler.c
index 8223015..7a570f9 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -1,4 +1,5 @@
 #include <assert.h>
+#include <inttypes.h>
 #include <stdlib.h>
 #include <stdbool.h>
 #include <unistd.h>
@@ -653,7 +654,7 @@ void device_handler_status_download(struct device_handler *handler,
 			unit++;
 		}
 		update = talloc_asprintf(handler,
-				_("%u %s downloading: %.0f%% - %lu%cB"),
+				_("%u %s downloading: %.0f%% - %" PRIu64 "%cB"),
 				handler->n_progress,
 				ngettext("item", "items", handler->n_progress),
 				(current / total) * 100, current_converted,
diff --git a/discover/devmapper.c b/discover/devmapper.c
index 2b28e0f..d8445e6 100644
--- a/discover/devmapper.c
+++ b/discover/devmapper.c
@@ -2,6 +2,7 @@
 #include <types/types.h>
 #include <log/log.h>
 #include <errno.h>
+#include <inttypes.h>
 #include <string.h>
 
 #include <sys/types.h>
@@ -231,7 +232,7 @@ static int run_create_task(const char *dm_name, const struct target *target)
 	struct dm_task *task;
 	uint32_t cookie;
 
-	pb_debug("%s: %lu %lu '%s' '%s'\n", __func__,
+	pb_debug("%s: %" PRIu64 " %" PRIu64 " '%s' '%s'\n", __func__,
 		 target->start_sector, target->end_sector,
 		 target->ttype, target->params);
 
diff --git a/utils/hooks/30-dtb-updates.c b/utils/hooks/30-dtb-updates.c
index e161d87..f7de976 100644
--- a/utils/hooks/30-dtb-updates.c
+++ b/utils/hooks/30-dtb-updates.c
@@ -257,7 +257,7 @@ static int do_translate(void *fdt, int node,
 	current_pci_flags = na > 2 ? of_read_number(addr, 1) : 0;
 	child_pci_flags = cna > 2 ? of_read_number(ranges, 1) : 0;
 	if (current_pci_flags != 0 && current_pci_flags != child_pci_flags) {
-		fprintf(stderr, "Unexpected change in flags: %lx, %lx\n",
+		fprintf(stderr, "Unexpected change in flags: %" PRIu64 ", %" PRIu64 "\n",
 			current_pci_flags, child_pci_flags);
 		return -1;
 	}
@@ -324,7 +324,7 @@ static int do_translate(void *fdt, int node,
 
 	fprintf(stderr, "New address:\n\t");
 	for (i = 0; i < *addr_cells; i++)
-		fprintf(stderr, " %lx ", of_read_number(&addr[i], 1));
+		fprintf(stderr, " %" PRIu64 " ", of_read_number(&addr[i], 1));
 	fprintf(stderr, "\n");
 
 	return 0;
@@ -382,7 +382,7 @@ static int create_translated_addresses(struct offb_ctx *ctx,
 
 	fprintf(stderr, "Final address:\n\t");
 	for (i = 0; i < addr_cells; i++)
-		fprintf(stderr, " %lx ", of_read_number(&addr[i], 1));
+		fprintf(stderr, " %" PRIu64 " ", of_read_number(&addr[i], 1));
 	fprintf(stderr, "\n");
 
 	if (addr_cells + size_cells > reg_cells) {
-- 
2.11.0



More information about the Petitboot mailing list