Fix incorrect format strings

In many cases format strings in vboot_reference do not match their
parameters, which causes all kind of ugly results when examining debug
output.

Enforce proper format verification.

CQ-DEPEND=CL:65396
BRANCH=pit
BUG=none
TEST=manual
   . compiled cleanly in vboot_reference, observed debug printouts
     making sense.

Change-Id: I58d5ba1f9097ef9922fbaeb7a9946aadf5eb8617
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65394
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
index dc8be1c..3e0e4ec 100644
--- a/firmware/include/vboot_api.h
+++ b/firmware/include/vboot_api.h
@@ -372,7 +372,8 @@
 /**
  * Output a debug message.  Supports printf()-style formatting.
  */
-void VbExDebug(const char *format, ...);
+void VbExDebug(const char *format, ...)
+	__attribute__ ((format (__printf__, 1, 2)));
 
 /*****************************************************************************/
 /* Memory (from utility.h) */
diff --git a/firmware/lib/tpm_bootmode.c b/firmware/lib/tpm_bootmode.c
index a8e1a7c..0136bd9 100644
--- a/firmware/lib/tpm_bootmode.c
+++ b/firmware/lib/tpm_bootmode.c
@@ -153,6 +153,6 @@
 	result = TlclExtend(BOOT_MODE_PCR, in_digest, out_digest);
 	VBDEBUG(("TPM: SetTPMBootModeState boot mode PCR out_digest "
 		 "%02x %02x %02x %02x\n",
-		 out_digest, out_digest+1, out_digest+2, out_digest+3));
+		 out_digest[0], out_digest[1], out_digest[2], out_digest[3]));
 	return result;
 }
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index f253e92..744ad4d 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -145,7 +145,7 @@
 			return 1;
 			break;
 		case ' ':
-			VBDEBUG(("%s() - Space (%s)\n", __func__,
+			VBDEBUG(("%s() - Space (%d)\n", __func__,
 				 space_means_no));
 			if (space_means_no)
 				return 0;
diff --git a/firmware/lib/vboot_audio.c b/firmware/lib/vboot_audio.c
index 2694b0e..8f96b68 100644
--- a/firmware/lib/vboot_audio.c
+++ b/firmware/lib/vboot_audio.c
@@ -69,7 +69,7 @@
 	uint32_t this_msecs, on_msecs, total_msecs;
 	uint32_t count;
 
-	VBDEBUG(("VbGetDevMusicNotes: use_short is %d, hdr is %lx, "
+	VBDEBUG(("VbGetDevMusicNotes: use_short is %d, hdr is %p, "
 		 "maxsize is %d\n", use_short, hdr, maxsize));
 
 	if (use_short) {
@@ -112,7 +112,8 @@
 	if ((sizeof(VbDevMusicNote) > UINT_MAX / hdr->count) ||
 	    (sizeof(hdr->count) >
 	     UINT_MAX - hdr->count * sizeof(VbDevMusicNote))) {
-		VBDEBUG(("VbGetDevMusicNotes: count=%d, just isn't right\n"));
+		VBDEBUG(("VbGetDevMusicNotes: count=%d, just isn't right\n",
+			 hdr->count));
 		goto nope;
 	}
 
@@ -127,7 +128,7 @@
 		goto nope;
 	}
 
-	VBDEBUG(("VbGetDevMusicNotes: custom notes struct at %lx\n", hdr));
+	VBDEBUG(("VbGetDevMusicNotes: custom notes struct at %p\n", hdr));
 
 	/*
 	 * Measure the audible sound up to the first 22 seconds, being careful
@@ -148,7 +149,7 @@
 	}
 
 	/* We require at least one second of noise in the first 22 seconds */
-	VBDEBUG(("VbGetDevMusicNotes:   with %ld msecs of sound to begin\n",
+	VBDEBUG(("VbGetDevMusicNotes:   with %d msecs of sound to begin\n",
 		 on_msecs));
 	if (on_msecs < REQUIRED_NOISE_TIME)
 		goto nope;
@@ -157,7 +158,7 @@
 	 * We'll also require that the total time be less than a minute. No
 	 * real reason, it just gives us less to worry about.
 	 */
-	VBDEBUG(("VbGetDevMusicNotes:   lasting %ld msecs\n", total_msecs));
+	VBDEBUG(("VbGetDevMusicNotes:   lasting %d msecs\n", total_msecs));
 	if (total_msecs > MAX_CUSTOM_DELAY) {
 		goto nope;
 	}
@@ -183,7 +184,7 @@
 		notebuf[hdr->count].msec = this_msecs;
 		notebuf[hdr->count].frequency = 0;
 		count++;
-		VBDEBUG(("VbGetDevMusicNotes:   adding %ld msecs of silence\n",
+		VBDEBUG(("VbGetDevMusicNotes:   adding %d msecs of silence\n",
 			 this_msecs));
 	}