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
This commit is contained in:
Vadim Bendebury
2013-08-09 16:02:28 -07:00
committed by ChromeBot
parent 53710471b5
commit 7aa250f2db
4 changed files with 11 additions and 9 deletions

View File

@@ -372,7 +372,8 @@ void VbExError(const char *format, ...);
/** /**
* Output a debug message. Supports printf()-style formatting. * 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) */ /* Memory (from utility.h) */

View File

@@ -153,6 +153,6 @@ uint32_t SetTPMBootModeState(int developer_mode, int recovery_mode,
result = TlclExtend(BOOT_MODE_PCR, in_digest, out_digest); result = TlclExtend(BOOT_MODE_PCR, in_digest, out_digest);
VBDEBUG(("TPM: SetTPMBootModeState boot mode PCR out_digest " VBDEBUG(("TPM: SetTPMBootModeState boot mode PCR out_digest "
"%02x %02x %02x %02x\n", "%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; return result;
} }

View File

@@ -145,7 +145,7 @@ int VbUserConfirms(VbCommonParams *cparams, int space_means_no)
return 1; return 1;
break; break;
case ' ': case ' ':
VBDEBUG(("%s() - Space (%s)\n", __func__, VBDEBUG(("%s() - Space (%d)\n", __func__,
space_means_no)); space_means_no));
if (space_means_no) if (space_means_no)
return 0; return 0;

View File

@@ -69,7 +69,7 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
uint32_t this_msecs, on_msecs, total_msecs; uint32_t this_msecs, on_msecs, total_msecs;
uint32_t count; 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)); "maxsize is %d\n", use_short, hdr, maxsize));
if (use_short) { if (use_short) {
@@ -112,7 +112,8 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
if ((sizeof(VbDevMusicNote) > UINT_MAX / hdr->count) || if ((sizeof(VbDevMusicNote) > UINT_MAX / hdr->count) ||
(sizeof(hdr->count) > (sizeof(hdr->count) >
UINT_MAX - hdr->count * sizeof(VbDevMusicNote))) { 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; goto nope;
} }
@@ -127,7 +128,7 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
goto nope; 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 * Measure the audible sound up to the first 22 seconds, being careful
@@ -148,7 +149,7 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
} }
/* We require at least one second of noise in the first 22 seconds */ /* 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)); on_msecs));
if (on_msecs < REQUIRED_NOISE_TIME) if (on_msecs < REQUIRED_NOISE_TIME)
goto nope; goto nope;
@@ -157,7 +158,7 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
* We'll also require that the total time be less than a minute. No * We'll also require that the total time be less than a minute. No
* real reason, it just gives us less to worry about. * 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) { if (total_msecs > MAX_CUSTOM_DELAY) {
goto nope; goto nope;
} }
@@ -183,7 +184,7 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
notebuf[hdr->count].msec = this_msecs; notebuf[hdr->count].msec = this_msecs;
notebuf[hdr->count].frequency = 0; notebuf[hdr->count].frequency = 0;
count++; count++;
VBDEBUG(("VbGetDevMusicNotes: adding %ld msecs of silence\n", VBDEBUG(("VbGetDevMusicNotes: adding %d msecs of silence\n",
this_msecs)); this_msecs));
} }