fix up printf settings

Mark the printf style func as such and fix up the resulting warnings.

BUG=None
TEST=precq passes

Change-Id: I8d4cd9ffa697ab91d42017b0a88a426e38d2faf6
Reviewed-on: https://chromium-review.googlesource.com/262673
Trybot-Ready: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Daniel Ehrenberg <dehrenberg@chromium.org>
diff --git a/Makefile b/Makefile
index 0cdac36..a462156 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
 
 include common.mk
 
-CFLAGS += -Wformat=0
+CFLAGS += -Wno-format-nonliteral
 
 bootcache_OBJS = bootcache.o
 
diff --git a/bootcache.c b/bootcache.c
index 5c6967e..1be8e5a 100644
--- a/bootcache.c
+++ b/bootcache.c
@@ -49,6 +49,7 @@
 #include <sys/user.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <inttypes.h>
 #include <stdarg.h>
 #include <stdbool.h>
 #include <stdint.h>
@@ -89,20 +90,12 @@
 #define fatal(fmt, ...)	pr_fatal(__FILE__, __FUNCTION__, __LINE__, \
 				fmt, ## __VA_ARGS__)
 
-#define PRs(_x) printf("|%s<%d> %s %s\n", __FUNCTION__, __LINE__, \
-			# _x, _x);
-
-#define PRd(_x) printf("|%s<%d> %s %lld\n", __FUNCTION__, __LINE__, \
-			# _x, (unsigned long long)(_x));
-
-#define PRx(_x) printf("|%s<%d> %s %llx\n", __FUNCTION__, __LINE__, \
-			# _x, (unsigned long long)(_x));
-
 /*
  * pr_fatal:  Because bootcache is not critical to
  * the running of the system, we only print what
  * happened and exit.
  */
+__attribute__ ((__format__ (__printf__, 4, 5)))
 static void pr_fatal(
 	const char *file,
 	const char *func,
@@ -140,7 +133,7 @@
 
 	p = malloc(n);
 	if (p == NULL) {
-		fatal("malloc of %u bytes failed:", n);
+		fatal("malloc of %zu bytes failed:", n);
 	}
 	return p;
 }
@@ -234,20 +227,20 @@
 		}
 		rc = pread(src, buf, n, offset);
 		if (rc < 0) {
-			fatal("pread trace offset=%llu num sectors=%llu:",
+			fatal("pread trace offset=%"PRIu64" num sectors=%"PRIu64":",
 				offset >> SECTOR_SHIFT, n >> SECTOR_SHIFT);
 		}
 		if (rc != n) {
-			fatal("pread read only %u bytes expected %llu",
+			fatal("pread read only %u bytes expected %"PRIu64,
 				rc, n);
 		}
 		rc = write(dst, buf, n);
 		if (rc < 0) {
-			fatal("write trace offset=%llu num sectors=%llu:",
+			fatal("write trace offset=%"PRIu64" num sectors=%"PRIu64":",
 				offset >> SECTOR_SHIFT, n >> SECTOR_SHIFT);
 		}
 		if (rc != n) {
-			fatal("write wrote only %u bytes expected %llu",
+			fatal("write wrote only %u bytes expected %"PRIu64,
 				rc, n);
 		}
 		offset += n;
@@ -284,7 +277,10 @@
 
 	if (0) {
 		for (i = 0; i < Trace.num; i++, tr++) {
-			printf("%llu %llu %llu\n", tr->sector, tr->count, tr->ino);
+			printf("%"PRIu64" %"PRIu64" %"PRIu64"\n",
+				(uint64_t)tr->sector,
+				(uint64_t)tr->count,
+				(uint64_t)tr->ino);
 		}
 	}
 }
@@ -338,7 +334,7 @@
 			fatal("read %s:", file);
 		}
 		if (rc == 0) {
-			fatal("trying to read %lld bytes", n);
+			fatal("trying to read %"PRIu64" bytes", n);
 		}
 	}
 	dump_trace();
@@ -396,7 +392,7 @@
 	fd = eopen(file, O_WRONLY);
 	rc = pwrite(fd, Trace.tr, size, Trace_start << SECTOR_SHIFT);
 	if (rc != size) {
-		fatal("pwrite %s rc=%ld size=%ld:", file, rc, size);
+		fatal("pwrite %s rc=%zd size=%zd:", file, rc, size);
 	}
 	efsync(fd);
 	eclose(fd);