diff options
author | Joel Kitching <kitching@google.com> | 2019-10-04 17:46:29 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-10-23 16:28:14 +0000 |
commit | 3c477458fa7f1506e722ede38636eaced8810687 (patch) | |
tree | 6af8c80467619faa021405a72ab8c6e5eb12b55b | |
parent | ffa02e80c8cec862106607ffd0333258bb1ed62e (diff) | |
download | vboot-3c477458fa7f1506e722ede38636eaced8810687.tar.gz |
vboot: format hex numbers with %#x instead of 0x%x
Also standardize on using hex for printing ASCII key values
across vboot_ui.c and vboot_ui_menu.c.
BUG=b:124141368
TEST=make clean && make runtests
BRANCH=none
Change-Id: Ib10288d95e29c248ebe807d99108aea75775b155
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1840191
Reviewed-by: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
35 files changed, 123 insertions, 123 deletions
diff --git a/cgpt/cgpt_add.c b/cgpt/cgpt_add.c index 6134504e..e2b0b32e 100644 --- a/cgpt/cgpt_add.c +++ b/cgpt/cgpt_add.c @@ -63,7 +63,7 @@ static const char* DumpCgptAddParams(const CgptAddParams *params) { StrnAppend(buf, tmp, sizeof(buf)); } if (params->set_raw) { - snprintf(tmp, sizeof(tmp), "-A 0x%x ", params->raw_value); + snprintf(tmp, sizeof(tmp), "-A %#x ", params->raw_value); StrnAppend(buf, tmp, sizeof(buf)); } diff --git a/cgpt/cgpt_show.c b/cgpt/cgpt_show.c index 0a956130..c1ea2400 100644 --- a/cgpt/cgpt_show.c +++ b/cgpt/cgpt_show.c @@ -239,7 +239,7 @@ static int GptShow(struct drive *drive, CgptShowParams *params) { printf("%d\n", GetLegacyBoot(drive, ANY_VALID, index)); break; case 'A': - printf("0x%x\n", entry->attrs.fields.gpt_att); + printf("%#x\n", entry->attrs.fields.gpt_att); break; } } else { diff --git a/firmware/2lib/2secdata_firmware.c b/firmware/2lib/2secdata_firmware.c index baca6c46..44cd9e74 100644 --- a/firmware/2lib/2secdata_firmware.c +++ b/firmware/2lib/2secdata_firmware.c @@ -129,14 +129,14 @@ void vb2_secdata_firmware_set(struct vb2_context *ctx, goto fail; } - VB2_DEBUG("secdata_firmware flags updated from 0x%x to 0x%x\n", + VB2_DEBUG("secdata_firmware flags updated from %#x to %#x\n", sec->flags, value); sec->flags = value; break; case VB2_SECDATA_FIRMWARE_VERSIONS: VB2_DEBUG("secdata_firmware versions updated from " - "0x%x to 0x%x\n", + "%#x to %#x\n", sec->fw_versions, value); sec->fw_versions = value; break; diff --git a/firmware/2lib/2secdata_kernel.c b/firmware/2lib/2secdata_kernel.c index 2ed177f0..4764ace1 100644 --- a/firmware/2lib/2secdata_kernel.c +++ b/firmware/2lib/2secdata_kernel.c @@ -125,7 +125,7 @@ void vb2_secdata_kernel_set(struct vb2_context *ctx, switch (param) { case VB2_SECDATA_KERNEL_VERSIONS: - VB2_DEBUG("secdata_kernel versions updated from 0x%x to 0x%x\n", + VB2_DEBUG("secdata_kernel versions updated from %#x to %#x\n", sec->kernel_versions, value); sec->kernel_versions = value; break; diff --git a/firmware/lib/secdata_tpm.c b/firmware/lib/secdata_tpm.c index cf179978..6b77ba55 100644 --- a/firmware/lib/secdata_tpm.c +++ b/firmware/lib/secdata_tpm.c @@ -19,7 +19,7 @@ #define RETURN_ON_FAILURE(tpm_command) do { \ uint32_t result_; \ if ((result_ = (tpm_command)) != TPM_SUCCESS) { \ - VB2_DEBUG("TPM: 0x%x returned by " #tpm_command \ + VB2_DEBUG("TPM: %#x returned by " #tpm_command \ "\n", (int)result_); \ return result_; \ } \ @@ -62,7 +62,7 @@ uint32_t ReadSpaceFirmware(RollbackSpaceFirmware *rsf) r = TlclRead(FIRMWARE_NV_INDEX, rsf, sizeof(RollbackSpaceFirmware)); if (TPM_SUCCESS != r) { - VB2_DEBUG("TPM: read secdata_firmware returned 0x%x\n", r); + VB2_DEBUG("TPM: read secdata_firmware returned %#x\n", r); return r; } PRINT_BYTES("TPM: read secdata_firmware", rsf); @@ -144,7 +144,7 @@ uint32_t ReadSpaceKernel(RollbackSpaceKernel *rsk) r = TlclRead(KERNEL_NV_INDEX, rsk, sizeof(RollbackSpaceKernel)); if (TPM_SUCCESS != r) { - VB2_DEBUG("TPM: read secdata_kernel returned 0x%x\n", r); + VB2_DEBUG("TPM: read secdata_kernel returned %#x\n", r); return r; } PRINT_BYTES("TPM: read secdata_kernel", rsk); @@ -184,7 +184,7 @@ uint32_t RollbackKernelRead(uint32_t* version) RollbackSpaceKernel rsk; RETURN_ON_FAILURE(ReadSpaceKernel(&rsk)); memcpy(version, &rsk.kernel_versions, sizeof(*version)); - VB2_DEBUG("TPM: RollbackKernelRead 0x%x\n", (int)*version); + VB2_DEBUG("TPM: RollbackKernelRead %#x\n", (int)*version); return TPM_SUCCESS; } @@ -194,7 +194,7 @@ uint32_t RollbackKernelWrite(uint32_t version) uint32_t old_version; RETURN_ON_FAILURE(ReadSpaceKernel(&rsk)); memcpy(&old_version, &rsk.kernel_versions, sizeof(old_version)); - VB2_DEBUG("TPM: RollbackKernelWrite 0x%x --> 0x%x\n", + VB2_DEBUG("TPM: RollbackKernelWrite %#x --> %#x\n", (int)old_version, (int)version); memcpy(&rsk.kernel_versions, &version, sizeof(version)); return WriteSpaceKernel(&rsk); @@ -212,7 +212,7 @@ uint32_t RollbackKernelLock(int recovery_mode) if (TPM_SUCCESS == r) kernel_locked = 1; - VB2_DEBUG("TPM: lock secdata_kernel returned 0x%x\n", r); + VB2_DEBUG("TPM: lock secdata_kernel returned %#x\n", r); return r; } @@ -239,7 +239,7 @@ uint32_t RollbackFwmpRead(struct RollbackSpaceFwmp *fwmp) VB2_DEBUG("TPM: no FWMP space\n"); return TPM_SUCCESS; } else if (TPM_SUCCESS != r) { - VB2_DEBUG("TPM: read FWMP returned 0x%x\n", r); + VB2_DEBUG("TPM: read FWMP returned %#x\n", r); return r; } @@ -249,7 +249,7 @@ uint32_t RollbackFwmpRead(struct RollbackSpaceFwmp *fwmp) */ if (u.fwmp.struct_size < sizeof(u.fwmp) || u.fwmp.struct_size > sizeof(u.buf)) { - VB2_DEBUG("TPM: FWMP size invalid: 0x%x\n", u.fwmp.struct_size); + VB2_DEBUG("TPM: FWMP size invalid: %#x\n", u.fwmp.struct_size); return TPM_E_STRUCT_SIZE; } @@ -260,7 +260,7 @@ uint32_t RollbackFwmpRead(struct RollbackSpaceFwmp *fwmp) if (u.fwmp.struct_size > sizeof(u.fwmp)) { r = TlclRead(FWMP_NV_INDEX, u.buf, u.fwmp.struct_size); if (TPM_SUCCESS != r) { - VB2_DEBUG("TPM: re-read FWMP returned 0x%x\n", r); + VB2_DEBUG("TPM: re-read FWMP returned %#x\n", r); return r; } } diff --git a/firmware/lib/tpm_lite/tlcl.c b/firmware/lib/tpm_lite/tlcl.c index 1fba3204..1df51609 100644 --- a/firmware/lib/tpm_lite/tlcl.c +++ b/firmware/lib/tpm_lite/tlcl.c @@ -80,7 +80,7 @@ static uint32_t TlclSendReceiveNoRetry(const uint8_t* request, response, &response_length); if (TPM_SUCCESS != result) { /* Communication with TPM failed, so response is garbage */ - VB2_DEBUG("TPM: command 0x%x send/receive failed: 0x%x\n", + VB2_DEBUG("TPM: command %#x send/receive failed: %#x\n", TpmCommandCode(request), result); return result; } @@ -98,7 +98,7 @@ static uint32_t TlclSendReceiveNoRetry(const uint8_t* request, response[6], response[7], response[8], response[9]); #endif - VB2_DEBUG("TPM: command 0x%x returned 0x%x\n", + VB2_DEBUG("TPM: command %#x returned %#x\n", TpmCommandCode(request), result); return result; @@ -433,7 +433,7 @@ uint32_t TlclContinueSelfTest(void) uint32_t TlclDefineSpace(uint32_t index, uint32_t perm, uint32_t size) { - VB2_DEBUG("TPM: TlclDefineSpace(0x%x, 0x%x, %d)\n", index, perm, size); + VB2_DEBUG("TPM: TlclDefineSpace(%#x, %#x, %d)\n", index, perm, size); return TlclDefineSpaceEx(NULL, 0, index, perm, size, NULL, 0); } @@ -441,7 +441,7 @@ uint32_t TlclDefineSpace(uint32_t index, uint32_t perm, uint32_t size) uint32_t TlclUndefineSpace(uint32_t index) { - VB2_DEBUG("TPM: TlclUndefineSpace(0x%x)\n", index); + VB2_DEBUG("TPM: TlclUndefineSpace(%#x)\n", index); return TlclUndefineSpaceEx(NULL, 0, index); } @@ -621,7 +621,7 @@ uint32_t TlclWrite(uint32_t index, const void* data, uint32_t length) const int total_length = kTpmRequestHeaderLength + kWriteInfoLength + length; - VB2_DEBUG("TPM: TlclWrite(0x%x, %d)\n", index, length); + VB2_DEBUG("TPM: TlclWrite(%#x, %d)\n", index, length); memcpy(&cmd, &tpm_nv_write_cmd, sizeof(cmd)); VB2_ASSERT(total_length <= TPM_LARGE_ENOUGH_COMMAND_SIZE); SetTpmCommandSize(cmd.buffer, total_length); @@ -639,7 +639,7 @@ uint32_t TlclRead(uint32_t index, void* data, uint32_t length) uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE]; uint32_t result; - VB2_DEBUG("TPM: TlclRead(0x%x, %d)\n", index, length); + VB2_DEBUG("TPM: TlclRead(%#x, %d)\n", index, length); memcpy(&cmd, &tpm_nv_read_cmd, sizeof(cmd)); ToTpmUint32(cmd.buffer + tpm_nv_read_cmd.index, index); ToTpmUint32(cmd.buffer + tpm_nv_read_cmd.length, length); @@ -663,7 +663,7 @@ uint32_t TlclPCRRead(uint32_t index, void* data, uint32_t length) uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE]; uint32_t result; - VB2_DEBUG("TPM: TlclPCRRead(0x%x, %d)\n", index, length); + VB2_DEBUG("TPM: TlclPCRRead(%#x, %d)\n", index, length); if (length < kPcrDigestLength) { return TPM_E_IOERROR; } @@ -682,13 +682,13 @@ uint32_t TlclPCRRead(uint32_t index, void* data, uint32_t length) uint32_t TlclWriteLock(uint32_t index) { - VB2_DEBUG("TPM: Write lock 0x%x\n", index); + VB2_DEBUG("TPM: Write lock %#x\n", index); return TlclWrite(index, NULL, 0); } uint32_t TlclReadLock(uint32_t index) { - VB2_DEBUG("TPM: Read lock 0x%x\n", index); + VB2_DEBUG("TPM: Read lock %#x\n", index); return TlclRead(index, NULL, 0); } diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c index 5f8eeaf9..f46c9544 100644 --- a/firmware/lib/vboot_api_kernel.c +++ b/firmware/lib/vboot_api_kernel.c @@ -87,7 +87,7 @@ vb2_error_t VbTryLoadKernel(struct vb2_context *ctx, uint32_t get_info_flags) get_info_flags != (disk_info[i].flags & ~VB_DISK_FLAG_EXTERNAL_GPT)) { VB2_DEBUG(" skipping: bytes_per_lba=%" PRIu64 - " lba_count=%" PRIu64 " flags=0x%x\n", + " lba_count=%" PRIu64 " flags=%#x\n", disk_info[i].bytes_per_lba, disk_info[i].lba_count, disk_info[i].flags); @@ -207,7 +207,7 @@ vb2_error_t VbBootNormal(struct vb2_context *ctx) if (shared->kernel_version_tpm > max_rollforward) { VB2_DEBUG("Limiting TPM kernel version roll-forward " - "to 0x%x < 0x%x\n", + "to %#x < %#x\n", max_rollforward, shared->kernel_version_tpm); shared->kernel_version_tpm = max_rollforward; @@ -443,6 +443,6 @@ vb2_error_t VbSelectAndLoadKernel(struct vb2_context *ctx, vb2_kernel_cleanup(ctx); /* Pass through return value from boot path */ - VB2_DEBUG("Returning %d\n", (int)rv); + VB2_DEBUG("Returning %#x\n", rv); return rv; } diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c index 362aa38e..dee766f8 100644 --- a/firmware/lib/vboot_ui.c +++ b/firmware/lib/vboot_ui.c @@ -208,7 +208,7 @@ static vb2_error_t vb2_altfw_ui(struct vb2_context *ctx) active = 0; break; default: - VB2_DEBUG("VbBootDeveloper() - pressed key %d\n", key); + VB2_DEBUG("VbBootDeveloper() - pressed key %#x\n", key); VbCheckDisplayKey(ctx, key, NULL); break; } @@ -297,7 +297,7 @@ static vb2_error_t vb2_enter_vendor_data_ui(struct vb2_context *ctx, } break; default: - VB2_DEBUG("Vendor Data UI - pressed key %d\n", key); + VB2_DEBUG("Vendor Data UI - pressed key %#x\n", key); VbCheckDisplayKey(ctx, key, &data); break; } @@ -364,7 +364,7 @@ static vb2_error_t vb2_vendor_data_ui(struct vb2_context *ctx) return VBERROR_SHUTDOWN_REQUESTED; } default: - VB2_DEBUG("Vendor Data UI - pressed key %d\n", key); + VB2_DEBUG("Vendor Data UI - pressed key %#x\n", key); VbCheckDisplayKey(ctx, key, &data); break; } @@ -448,7 +448,7 @@ static vb2_error_t vb2_diagnostics_ui(struct vb2_context *ctx) active = 0; break; default: - VB2_DEBUG("vb2_diagnostics_ui() - pressed key %d\n", + VB2_DEBUG("vb2_diagnostics_ui() - pressed key %#x\n", key); VbCheckDisplayKey(ctx, key, NULL); break; @@ -599,7 +599,7 @@ static vb2_error_t vb2_developer_ui(struct vb2_context *ctx) VBOOT_FALLTHROUGH; case ' ': /* See if we should disable virtual dev-mode switch. */ - VB2_DEBUG("shared->flags=0x%x\n", shared->flags); + VB2_DEBUG("shared->flags=%#x\n", shared->flags); if (shared->flags & VBSD_BOOT_DEV_SWITCH_ON) { /* Stop the countdown while we go ask... */ if (gbb->flags & @@ -740,7 +740,7 @@ static vb2_error_t vb2_developer_ui(struct vb2_context *ctx) vb2_try_alt_fw(ctx, allow_legacy, key - '0'); break; default: - VB2_DEBUG("VbBootDeveloper() - pressed key %d\n", key); + VB2_DEBUG("VbBootDeveloper() - pressed key %#x\n", key); VbCheckDisplayKey(ctx, key, NULL); break; } diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c index 81babf02..38dd3053 100644 --- a/firmware/lib/vboot_ui_menu.c +++ b/firmware/lib/vboot_ui_menu.c @@ -394,7 +394,7 @@ static vb2_error_t to_norm_action(struct vb2_context *ctx) /* Action that will power off the system. */ static vb2_error_t power_off_action(struct vb2_context *ctx) { - VB2_DEBUG("Power off requested from screen 0x%x\n", + VB2_DEBUG("Power off requested from screen %#x\n", menus[current_menu].screen); return VBERROR_SHUTDOWN_REQUESTED; } @@ -434,7 +434,7 @@ static void vb2_update_selection(uint32_t key) { current_menu_idx = idx; break; default: - VB2_DEBUG("ERROR: %s called with key 0x%x!\n", __func__, key); + VB2_DEBUG("ERROR: %s called with key %#x!\n", __func__, key); break; } @@ -488,7 +488,7 @@ static vb2_error_t vb2_handle_menu_input(struct vb2_context *ctx, return menus[current_menu].items[current_menu_idx].action(ctx); default: - VB2_DEBUG("pressed key 0x%x\n", key); + VB2_DEBUG("pressed key %#x\n", key); break; } diff --git a/firmware/stub/tpm_lite_stub.c b/firmware/stub/tpm_lite_stub.c index 0d26cfff..5fd673f2 100644 --- a/firmware/stub/tpm_lite_stub.c +++ b/firmware/stub/tpm_lite_stub.c @@ -81,7 +81,7 @@ static uint32_t TpmExecute(const uint8_t *in, const uint32_t in_len, uint8_t response[TPM_MAX_COMMAND_SIZE]; if (in_len <= 0) { return DoError(TPM_E_INPUT_TOO_SMALL, - "invalid command length %d for command 0x%x\n", + "invalid command length %d for command %#x\n", in_len, in[9]); } else if (tpm_fd < 0) { return DoError(TPM_E_NO_DEVICE, diff --git a/futility/cmd_dump_fmap.c b/futility/cmd_dump_fmap.c index 170889b8..ef46ffcd 100644 --- a/futility/cmd_dump_fmap.c +++ b/futility/cmd_dump_fmap.c @@ -354,9 +354,9 @@ static int human_fmap(const FmapHeader *fmh) if (overlaps(i, j)) { printf("ERROR: %s and %s overlap\n", all_nodes[i].name, all_nodes[j].name); - printf(" %s: 0x%x - 0x%x\n", all_nodes[i].name, + printf(" %s: %#x - %#x\n", all_nodes[i].name, all_nodes[i].start, all_nodes[i].end); - printf(" %s: 0x%x - 0x%x\n", all_nodes[j].name, + printf(" %s: %#x - %#x\n", all_nodes[j].name, all_nodes[j].start, all_nodes[j].end); if (opt_overlap < 2) { printf("Use more -h args to ignore" diff --git a/futility/cmd_show.c b/futility/cmd_show.c index 544a41c1..a0e2bb62 100644 --- a/futility/cmd_show.c +++ b/futility/cmd_show.c @@ -62,7 +62,7 @@ static void show_keyblock(struct vb2_keyblock *keyblock, const char *name, printf("Key block:\n"); printf(" Signature: %s\n", sign_key ? (good_sig ? "valid" : "invalid") : "ignored"); - printf(" Size: 0x%x\n", keyblock->keyblock_size); + printf(" Size: %#x\n", keyblock->keyblock_size); printf(" Flags: %d ", keyblock->keyblock_flags); if (keyblock->keyblock_flags & VB2_KEY_BLOCK_FLAG_DEVELOPER_0) printf(" !DEV"); @@ -320,18 +320,18 @@ int ft_show_kernel_preamble(const char *name, uint8_t *buf, uint32_t len, } printf("Kernel Preamble:\n"); - printf(" Size: 0x%x\n", pre2->preamble_size); + printf(" Size: %#x\n", pre2->preamble_size); printf(" Header version: %u.%u\n", pre2->header_version_major, pre2->header_version_minor); printf(" Kernel version: %u\n", pre2->kernel_version); printf(" Body load address: 0x%" PRIx64 "\n", pre2->body_load_address); - printf(" Body size: 0x%x\n", + printf(" Body size: %#x\n", pre2->body_signature.data_size); printf(" Bootloader address: 0x%" PRIx64 "\n", pre2->bootloader_address); - printf(" Bootloader size: 0x%x\n", pre2->bootloader_size); + printf(" Bootloader size: %#x\n", pre2->bootloader_size); uint64_t vmlinuz_header_address = 0; uint32_t vmlinuz_header_size = 0; @@ -341,11 +341,11 @@ int ft_show_kernel_preamble(const char *name, uint8_t *buf, uint32_t len, if (vmlinuz_header_size) { printf(" Vmlinuz_header address: 0x%" PRIx64 "\n", vmlinuz_header_address); - printf(" Vmlinuz header size: 0x%x\n", + printf(" Vmlinuz header size: %#x\n", vmlinuz_header_size); } - printf(" Flags: 0x%x\n", vb2_kernel_get_flags(pre2)); + printf(" Flags: %#x\n", vb2_kernel_get_flags(pre2)); /* Verify kernel body */ uint8_t *kernel_blob = 0; diff --git a/futility/cmd_sign.c b/futility/cmd_sign.c index a3342379..fb096763 100644 --- a/futility/cmd_sign.c +++ b/futility/cmd_sign.c @@ -124,7 +124,7 @@ int ft_sign_raw_kernel(const char *name, uint8_t *buf, uint32_t len, fprintf(stderr, "Unable to create kernel blob\n"); return 1; } - VB2_DEBUG("kblob_size = 0x%x\n", kblob_size); + VB2_DEBUG("kblob_size = %#x\n", kblob_size); vblock_data = SignKernelBlob(kblob_data, kblob_size, sign_option.padding, @@ -138,7 +138,7 @@ int ft_sign_raw_kernel(const char *name, uint8_t *buf, uint32_t len, free(kblob_data); return 1; } - VB2_DEBUG("vblock_size = 0x%x\n", vblock_size); + VB2_DEBUG("vblock_size = %#x\n", vblock_size); /* We should be creating a completely new output file. * If not, something's wrong. */ @@ -385,9 +385,9 @@ static const char usage_new_kpart[] = "\n" "Optional PARAMS:\n" " --kloadaddr NUM" " RAM address to load the kernel body\n" - " (default 0x%x)\n" + " (default %#x)\n" " --pad NUM The vblock padding size in bytes\n" - " (default 0x%x)\n" + " (default %#x)\n" " --vblockonly Emit just the vblock (requires a\n" " distinct outfile)\n" " -f|--flags NUM The preamble flags value\n" @@ -412,7 +412,7 @@ static const char usage_old_kpart[] = "\n" " -v|--version NUM The kernel version number\n" " --config FILE The kernel commandline file\n" " --pad NUM The vblock padding size in bytes\n" - " (default 0x%x)\n" + " (default %#x)\n" " [--outfile] OUTFILE Output kernel partition or vblock\n" " --vblockonly Emit just the vblock (requires a\n" " distinct OUTFILE)\n" diff --git a/futility/cmd_validate_rec_mrc.c b/futility/cmd_validate_rec_mrc.c index a269681a..1d35bed4 100644 --- a/futility/cmd_validate_rec_mrc.c +++ b/futility/cmd_validate_rec_mrc.c @@ -235,7 +235,7 @@ static int do_validate_rec_mrc(int argc, char *argv[]) } if (offset > file_size) { - fprintf(stderr, "File size(0x%x) smaller than offset(0x%x)\n", + fprintf(stderr, "File size(%#x) smaller than offset(%#x)\n", file_size, offset); futil_unmap_file(fd, MAP_RO, buff, file_size); close(fd); @@ -256,7 +256,7 @@ static int do_validate_rec_mrc(int argc, char *argv[]) data_size); else fprintf(stderr, "Offset or data size greater than file size: " - "offset=0x%x, file size=0x%x, data_size=0x%x\n", + "offset=%#x, file size=%#x, data_size=%#x\n", offset, file_size, data_size); if (futil_unmap_file(fd, MAP_RO, buff, file_size) != FILE_ERR_NONE) { diff --git a/futility/cmd_vbutil_kernel.c b/futility/cmd_vbutil_kernel.c index c909cff4..cdcce0b1 100644 --- a/futility/cmd_vbutil_kernel.c +++ b/futility/cmd_vbutil_kernel.c @@ -184,7 +184,7 @@ static uint8_t *ReadOldKPartFromFileOrDie(const char *filename, } else { file_size = statbuf.st_size; } - VB2_DEBUG("%s size is 0x%x\n", filename, file_size); + VB2_DEBUG("%s size is %#x\n", filename, file_size); if (file_size < opt_pad) FATAL("%s is too small to be a valid kernel blob\n", filename); @@ -419,7 +419,7 @@ static int do_vbutil_kernel(int argc, char *argv[]) &t_bootloader_data, &t_bootloader_size)) FATAL("Error reading bootloader file.\n"); - VB2_DEBUG(" bootloader file size=0x%x\n", t_bootloader_size); + VB2_DEBUG(" bootloader file size=%#x\n", t_bootloader_size); if (!vmlinuz_file) FATAL("Missing required vmlinuz file.\n"); @@ -429,7 +429,7 @@ static int do_vbutil_kernel(int argc, char *argv[]) vb2_read_file(vmlinuz_file, &vmlinuz_buf, &vmlinuz_size)) FATAL("Error reading vmlinuz file.\n"); - VB2_DEBUG(" vmlinuz file size=0x%x\n", vmlinuz_size); + VB2_DEBUG(" vmlinuz file size=%#x\n", vmlinuz_size); if (!vmlinuz_size) FATAL("Empty vmlinuz file\n"); @@ -442,7 +442,7 @@ static int do_vbutil_kernel(int argc, char *argv[]) if (!kblob_data) FATAL("Unable to create kernel blob\n"); - VB2_DEBUG("kblob_size = 0x%x\n", kblob_size); + VB2_DEBUG("kblob_size = %#x\n", kblob_size); vblock_data = SignKernelBlob(kblob_data, kblob_size, opt_pad, version, kernel_body_load_address, @@ -451,7 +451,7 @@ static int do_vbutil_kernel(int argc, char *argv[]) if (!vblock_data) FATAL("Unable to sign kernel blob\n"); - VB2_DEBUG("vblock_size = 0x%x\n", vblock_size); + VB2_DEBUG("vblock_size = %#x\n", vblock_size); if (opt_vblockonly) rv = WriteSomeParts(filename, diff --git a/futility/file_type_bios.c b/futility/file_type_bios.c index 44a4ca20..fa4874ee 100644 --- a/futility/file_type_bios.c +++ b/futility/file_type_bios.c @@ -40,7 +40,7 @@ static void fmap_limit_area(FmapAreaHeader *ah, uint32_t len) { uint32_t sum = ah->area_offset + ah->area_size; if (sum < ah->area_size || sum > len) { - VB2_DEBUG("%s 0x%x + 0x%x > 0x%x\n", + VB2_DEBUG("%s %#x + %#x > %#x\n", ah->area_name, ah->area_offset, ah->area_size, len); ah->area_offset = 0; ah->area_size = 0; diff --git a/futility/file_type_rwsig.c b/futility/file_type_rwsig.c index 2990ba7c..d2d67fac 100644 --- a/futility/file_type_rwsig.c +++ b/futility/file_type_rwsig.c @@ -49,12 +49,12 @@ static void show_sig(const char *name, const struct vb21_signature *sig) vb2_get_sig_algorithm_name(sig->sig_alg)); printf(" Hash Algorithm: %d %s\n", sig->hash_alg, vb2_get_hash_algorithm_name(sig->hash_alg)); - printf(" Total size: 0x%x (%d)\n", sig->c.total_size, + printf(" Total size: %#x (%d)\n", sig->c.total_size, sig->c.total_size); printf(" ID: "); vb2_print_bytes(&sig->id, sizeof(sig->id)); printf("\n"); - printf(" Data size: 0x%x (%d)\n", sig->data_size, + printf(" Data size: %#x (%d)\n", sig->data_size, sig->data_size); } @@ -112,7 +112,7 @@ int ft_show_rwsig(const char *name, uint8_t *buf, uint32_t len, void *nuthin) sig_size = fmaparea->area_size; - VB2_DEBUG("Looking for signature at 0x%x (0x%x)\n", + VB2_DEBUG("Looking for signature at %#x (%#x)\n", (uint8_t*)sig - buf, sig_size); if (VB2_SUCCESS != vb21_verify_signature(sig, sig_size)) @@ -137,7 +137,7 @@ int ft_show_rwsig(const char *name, uint8_t *buf, uint32_t len, void *nuthin) if (show_option.sig_size) sig_size = show_option.sig_size; - VB2_DEBUG("Looking for signature at 0x%x\n", len - sig_size); + VB2_DEBUG("Looking for signature at %#x\n", len - sig_size); if (len < sig_size) { VB2_DEBUG("File is too small\n"); @@ -235,7 +235,7 @@ int ft_sign_rwsig(const char *name, uint8_t *buf, uint32_t len, void *nuthin) sig_size = fmaparea->area_size; - VB2_DEBUG("Looking for signature at 0x%x (0x%x)\n", + VB2_DEBUG("Looking for signature at %#x (%#x)\n", (uint8_t*)old_sig - buf, sig_size); data = fmap_find_by_name(buf, len, fmap, "EC_RW", @@ -250,7 +250,7 @@ int ft_sign_rwsig(const char *name, uint8_t *buf, uint32_t len, void *nuthin) if (sign_option.sig_size) sig_size = sign_option.sig_size; - VB2_DEBUG("Looking for old signature at 0x%x\n", + VB2_DEBUG("Looking for old signature at %#x\n", len - sig_size); if (len < sig_size) { @@ -271,7 +271,7 @@ int ft_sign_rwsig(const char *name, uint8_t *buf, uint32_t len, void *nuthin) /* Use the same extent again */ data_size = old_sig->data_size; - VB2_DEBUG("Found sig: data_size is 0x%x (%d)\n", data_size, + VB2_DEBUG("Found sig: data_size is %#x (%d)\n", data_size, data_size); } diff --git a/futility/file_type_usbpd1.c b/futility/file_type_usbpd1.c index 2bcc48d1..f03feeca 100644 --- a/futility/file_type_usbpd1.c +++ b/futility/file_type_usbpd1.c @@ -167,7 +167,7 @@ int ft_sign_usbpd1(const char *name, uint8_t *buf, uint32_t len, void *data) fprintf(stderr, "Couldn't extract the public key\n"); goto done; } - VB2_DEBUG("keyb_size is 0x%x (%d):\n", keyb_size, keyb_size); + VB2_DEBUG("keyb_size is %#x (%d):\n", keyb_size, keyb_size); /* * Of course the packed public key format is different. Why would you diff --git a/futility/vb1_helper.c b/futility/vb1_helper.c index 84dc7969..66f0b5dc 100644 --- a/futility/vb1_helper.c +++ b/futility/vb1_helper.c @@ -70,7 +70,7 @@ uint8_t *ReadConfigFile(const char *config_file, uint32_t *config_size) if (VB2_SUCCESS != vb2_read_file(config_file, &config_buf, config_size)) return NULL; - VB2_DEBUG(" config file size=0x%x\n", *config_size); + VB2_DEBUG(" config file size=%#x\n", *config_size); if (CROS_CONFIG_SIZE <= *config_size) { /* room for trailing '\0' */ fprintf(stderr, "Config file %s is too large (>= %d bytes)\n", config_file, CROS_CONFIG_SIZE); @@ -203,10 +203,10 @@ static int PickApartVmlinuz(uint8_t *kernel_buf, params->cmd_line_ptr = kernel_body_load_address + roundup(kernel32_size, CROS_ALIGN) + find_cmdline_start(g_config_data, g_config_size); - VB2_DEBUG(" cmdline_addr=0x%x\n", params->cmd_line_ptr); - VB2_DEBUG(" version=0x%x\n", params->version); - VB2_DEBUG(" kernel_alignment=0x%x\n", params->kernel_alignment); - VB2_DEBUG(" relocatable_kernel=0x%x\n", + VB2_DEBUG(" cmdline_addr=%#x\n", params->cmd_line_ptr); + VB2_DEBUG(" version=%#x\n", params->version); + VB2_DEBUG(" kernel_alignment=%#x\n", params->kernel_alignment); + VB2_DEBUG(" relocatable_kernel=%#x\n", params->relocatable_kernel); /* Add a fake e820 memory map with 2 entries. */ params->n_e820_entry = 2; @@ -255,9 +255,9 @@ static void UnpackKernelBlob(uint8_t *kernel_blob_data) g_vmlinuz_header_size = vmlinuz_header_size; g_vmlinuz_header_data = kernel_blob_data + now; - VB2_DEBUG("vmlinuz_header_size = 0x%x\n", + VB2_DEBUG("vmlinuz_header_size = %#x\n", g_vmlinuz_header_size); - VB2_DEBUG("vmlinuz_header_ofs = 0x%x\n", now); + VB2_DEBUG("vmlinuz_header_ofs = %#x\n", now); } /* Where does the bootloader stub begin? */ @@ -268,25 +268,25 @@ static void UnpackKernelBlob(uint8_t *kernel_blob_data) g_bootloader_data = kernel_blob_data + now; /* TODO: What to do if this is beyond the end of the blob? */ - VB2_DEBUG("bootloader_size = 0x%x\n", g_bootloader_size); - VB2_DEBUG("bootloader_ofs = 0x%x\n", now); + VB2_DEBUG("bootloader_size = %#x\n", g_bootloader_size); + VB2_DEBUG("bootloader_ofs = %#x\n", now); /* Before that is the params */ now -= CROS_PARAMS_SIZE; g_param_size = CROS_PARAMS_SIZE; g_param_data = kernel_blob_data + now; - VB2_DEBUG("param_ofs = 0x%x\n", now); + VB2_DEBUG("param_ofs = %#x\n", now); /* Before that is the config */ now -= CROS_CONFIG_SIZE; g_config_size = CROS_CONFIG_SIZE; g_config_data = kernel_blob_data + now; - VB2_DEBUG("config_ofs = 0x%x\n", now); + VB2_DEBUG("config_ofs = %#x\n", now); /* The kernel starts at offset 0 and extends up to the config */ g_kernel_data = kernel_blob_data; g_kernel_size = now; - VB2_DEBUG("kernel_size = 0x%x\n", g_kernel_size); + VB2_DEBUG("kernel_size = %#x\n", g_kernel_size); } @@ -324,7 +324,7 @@ uint8_t *unpack_kernel_partition(uint8_t *kpart_data, /* Sanity-check the keyblock */ struct vb2_keyblock *keyblock = (struct vb2_keyblock *)kpart_data; - VB2_DEBUG("Keyblock is 0x%x bytes\n", keyblock->keyblock_size); + VB2_DEBUG("Keyblock is %#x bytes\n", keyblock->keyblock_size); now += keyblock->keyblock_size; if (now > kpart_size) { fprintf(stderr, @@ -343,7 +343,7 @@ uint8_t *unpack_kernel_partition(uint8_t *kpart_data, /* And the preamble */ preamble = (struct vb2_kernel_preamble *)(kpart_data + now); - VB2_DEBUG("Preamble is 0x%x bytes\n", preamble->preamble_size); + VB2_DEBUG("Preamble is %#x bytes\n", preamble->preamble_size); now += preamble->preamble_size; if (now > kpart_size) { fprintf(stderr, @@ -359,12 +359,12 @@ uint8_t *unpack_kernel_partition(uint8_t *kpart_data, VB2_DEBUG(" kernel_version = %d\n", preamble->kernel_version); VB2_DEBUG(" bootloader_address = 0x%" PRIx64 "\n", preamble->bootloader_address); - VB2_DEBUG(" bootloader_size = 0x%x\n", preamble->bootloader_size); - VB2_DEBUG(" kern_blob_size = 0x%x\n", + VB2_DEBUG(" bootloader_size = %#x\n", preamble->bootloader_size); + VB2_DEBUG(" kern_blob_size = %#x\n", preamble->body_signature.data_size); uint32_t flags = vb2_kernel_get_flags(preamble); - VB2_DEBUG(" flags = 0x%x\n", flags); + VB2_DEBUG(" flags = %#x\n", flags); g_preamble = preamble; g_ondisk_bootloader_addr = g_preamble->bootloader_address; @@ -375,18 +375,18 @@ uint8_t *unpack_kernel_partition(uint8_t *kpart_data, if (vmlinuz_header_size) { VB2_DEBUG(" vmlinuz_header_address = 0x%" PRIx64 "\n", vmlinuz_header_address); - VB2_DEBUG(" vmlinuz_header_size = 0x%x\n", vmlinuz_header_size); + VB2_DEBUG(" vmlinuz_header_size = %#x\n", vmlinuz_header_size); g_ondisk_vmlinuz_header_addr = vmlinuz_header_address; } - VB2_DEBUG("kernel blob is at offset 0x%x\n", now); + VB2_DEBUG("kernel blob is at offset %#x\n", now); g_kernel_blob_data = kpart_data + now; g_kernel_blob_size = preamble->body_signature.data_size; /* Sanity check */ if (g_kernel_blob_size < preamble->body_signature.data_size) fprintf(stderr, - "Warning: kernel file only has 0x%x bytes\n", + "Warning: kernel file only has %#x bytes\n", g_kernel_blob_size); /* Update the blob pointers */ @@ -536,7 +536,7 @@ int VerifyKernelBlob(uint8_t *kernel_blob, struct vb2_packed_key *data_key = &g_keyblock->data_key; printf(" Signature: %s\n", signpub_key ? "valid" : "ignored"); - printf(" Size: 0x%x\n", g_keyblock->keyblock_size); + printf(" Size: %#x\n", g_keyblock->keyblock_size); printf(" Flags: %u ", g_keyblock->keyblock_flags); if (g_keyblock->keyblock_flags & KEY_BLOCK_FLAG_DEVELOPER_0) printf(" !DEV"); @@ -591,18 +591,18 @@ int VerifyKernelBlob(uint8_t *kernel_blob, } printf("Preamble:\n"); - printf(" Size: 0x%x\n", g_preamble->preamble_size); + printf(" Size: %#x\n", g_preamble->preamble_size); printf(" Header version: %u.%u\n", g_preamble->header_version_major, g_preamble->header_version_minor); printf(" Kernel version: %u\n", g_preamble->kernel_version); printf(" Body load address: 0x%" PRIx64 "\n", g_preamble->body_load_address); - printf(" Body size: 0x%x\n", + printf(" Body size: %#x\n", g_preamble->body_signature.data_size); printf(" Bootloader address: 0x%" PRIx64 "\n", g_preamble->bootloader_address); - printf(" Bootloader size: 0x%x\n", g_preamble->bootloader_size); + printf(" Bootloader size: %#x\n", g_preamble->bootloader_size); vb2_kernel_get_vmlinuz_header(g_preamble, &vmlinuz_header_address, @@ -610,11 +610,11 @@ int VerifyKernelBlob(uint8_t *kernel_blob, if (vmlinuz_header_size) { printf(" Vmlinuz header address: 0x%" PRIx64 "\n", vmlinuz_header_address); - printf(" Vmlinuz header size: 0x%x\n", + printf(" Vmlinuz header size: %#x\n", (uint32_t)vmlinuz_header_size); } - printf(" Flags : 0x%x\n", + printf(" Flags : %#x\n", vb2_kernel_get_flags(g_preamble)); if (g_preamble->kernel_version < (min_version & 0xFFFF)) { diff --git a/host/lib/host_key2.c b/host/lib/host_key2.c index 072eb5a2..fa97f9fa 100644 --- a/host/lib/host_key2.c +++ b/host/lib/host_key2.c @@ -229,7 +229,7 @@ struct vb2_packed_key *vb2_read_packed_keyb(const char *filename, } if (version > VB2_MAX_KEY_VERSION) { /* Currently, TPM only supports 16-bit version */ - fprintf(stderr, "%s() - invalid version 0x%x\n", __func__, + fprintf(stderr, "%s() - invalid version %#x\n", __func__, version); return NULL; } diff --git a/scripts/image_signing/set_gbb_flags.sh b/scripts/image_signing/set_gbb_flags.sh index 11da707c..a313ec4b 100755 --- a/scripts/image_signing/set_gbb_flags.sh +++ b/scripts/image_signing/set_gbb_flags.sh @@ -57,7 +57,7 @@ main() { # Keep 'local' declaration split from assignment so return code is checked. local old_value old_value="$(futility gbb -g --flags "${image_file}")" - printf "Setting GBB flags from %s to 0x%x.." "${old_value}" "${value}" + printf "Setting GBB flags from %s to %#x.." "${old_value}" "${value}" futility gbb -s --flags="${value}" "${image_file}" if [ -z "${FLAGS_file}" ]; then diff --git a/tests/secdata_tpm_tests.c b/tests/secdata_tpm_tests.c index cac51338..dd28e62a 100644 --- a/tests/secdata_tpm_tests.c +++ b/tests/secdata_tpm_tests.c @@ -141,7 +141,7 @@ uint32_t TlclSetDeactivated(uint8_t flag) uint32_t TlclRead(uint32_t index, void* data, uint32_t length) { - mock_cnext += sprintf(mock_cnext, "TlclRead(0x%x, %d)\n", + mock_cnext += sprintf(mock_cnext, "TlclRead(%#x, %d)\n", index, length); if (FIRMWARE_NV_INDEX == index) { @@ -164,7 +164,7 @@ uint32_t TlclRead(uint32_t index, void* data, uint32_t length) uint32_t TlclWrite(uint32_t index, const void *data, uint32_t length) { - mock_cnext += sprintf(mock_cnext, "TlclWrite(0x%x, %d)\n", + mock_cnext += sprintf(mock_cnext, "TlclWrite(%#x, %d)\n", index, length); if (FIRMWARE_NV_INDEX == index) { @@ -180,7 +180,7 @@ uint32_t TlclWrite(uint32_t index, const void *data, uint32_t length) uint32_t TlclDefineSpace(uint32_t index, uint32_t perm, uint32_t size) { - mock_cnext += sprintf(mock_cnext, "TlclDefineSpace(0x%x, 0x%x, %d)\n", + mock_cnext += sprintf(mock_cnext, "TlclDefineSpace(%#x, %#x, %d)\n", index, perm, size); return (++mock_count == fail_at_count) ? fail_with_error : TPM_SUCCESS; } @@ -246,7 +246,7 @@ uint32_t TlclLockPhysicalPresence(void) uint32_t TlclGetPermissions(uint32_t index, uint32_t* permissions) { - mock_cnext += sprintf(mock_cnext, "TlclGetPermissions(0x%x)\n", index); + mock_cnext += sprintf(mock_cnext, "TlclGetPermissions(%#x)\n", index); *permissions = mock_permissions; return (++mock_count == fail_at_count) ? fail_with_error : TPM_SUCCESS; } diff --git a/tests/test_common.c b/tests/test_common.c index 02cbc165..21740b60 100644 --- a/tests/test_common.c +++ b/tests/test_common.c @@ -27,7 +27,7 @@ int test_eq(int result, int expected, } else { fprintf(stderr, "%s: %s ... " COL_RED "FAILED\n" COL_STOP, preamble, comment ? comment : desc); - fprintf(stderr, " Expected: 0x%x (%d), got: 0x%x (%d)\n", + fprintf(stderr, " Expected: %#x (%d), got: %#x (%d)\n", expected, expected, result, result); gTestSuccess = 0; return 0; @@ -44,7 +44,7 @@ int test_neq(int result, int not_expected, } else { fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, preamble, desc, comment); - fprintf(stderr, " Didn't expect 0x%x (%d), but got it.\n", + fprintf(stderr, " Didn't expect %#x (%d), but got it.\n", not_expected, not_expected); gTestSuccess = 0; return 0; @@ -139,7 +139,7 @@ int test_succ(int result, } else { fprintf(stderr, "%s: %s ... " COL_RED "FAILED\n" COL_STOP, preamble, comment ? comment : desc); - fprintf(stderr, " Expected SUCCESS, got: 0x%x (%d)\n", + fprintf(stderr, " Expected SUCCESS, got: %#x (%d)\n", result, result); gTestSuccess = 0; } diff --git a/tests/tlcl_tests.c b/tests/tlcl_tests.c index 7e8d2311..c9521f97 100644 --- a/tests/tlcl_tests.c +++ b/tests/tlcl_tests.c @@ -88,7 +88,7 @@ uint32_t VbExTpmSendReceive(const uint8_t *request, uint32_t request_length, FromTpmUint32(request + 6, &c->req_cmd); // KLUDGE - remove - printf("TSR [%d] 0x%x\n", ncalls-1, c->req_cmd); + printf("TSR [%d] %#x\n", ncalls-1, c->req_cmd); memset(response, 0, *response_length); if (c->rsp_size) diff --git a/tests/tpm_lite/lock.c b/tests/tpm_lite/lock.c index bfc10e2e..55d2dfe7 100644 --- a/tests/tpm_lite/lock.c +++ b/tests/tpm_lite/lock.c @@ -24,6 +24,6 @@ int main(int argc, char** argv) { TlclWriteLock(INDEX0); - printf("Locked 0x%x\n", INDEX0); + printf("Locked %#x\n", INDEX0); exit(0); } diff --git a/tests/tpm_lite/startup.c b/tests/tpm_lite/startup.c index 3d901f39..573373dc 100644 --- a/tests/tpm_lite/startup.c +++ b/tests/tpm_lite/startup.c @@ -15,17 +15,17 @@ int main(int argc, char** argv) { TlclLibInit(); result = TlclStartup(); if (result != 0) { - printf("tpm startup failed with 0x%x\n", result); + printf("tpm startup failed with %#x\n", result); } result = TlclGetFlags(NULL, NULL, NULL); if (result != 0) { - printf("tpm getflags failed with 0x%x\n", result); + printf("tpm getflags failed with %#x\n", result); } printf("executing SelfTestFull\n"); TlclSelfTestFull(); result = TlclGetFlags(NULL, NULL, NULL); if (result != 0) { - printf("tpm getflags failed with 0x%x\n", result); + printf("tpm getflags failed with %#x\n", result); } printf("TEST SUCCEEDED\n"); return 0; diff --git a/tests/tpm_lite/tlcl_tests.h b/tests/tpm_lite/tlcl_tests.h index 7b0d295c..db0999cd 100644 --- a/tests/tpm_lite/tlcl_tests.h +++ b/tests/tpm_lite/tlcl_tests.h @@ -19,8 +19,8 @@ uint32_t _result = (tpm_command); \ uint32_t _exp = (expected_result); \ if (_result != _exp) { \ - printf("TEST FAILED: line %d: " #tpm_command ": 0x%x" \ - " (expecting 0x%x)\n", __LINE__, _result, _exp); \ + printf("TEST FAILED: line %d: " #tpm_command ": %#x" \ + " (expecting %#x)\n", __LINE__, _result, _exp); \ return _result; \ } \ } while (0) diff --git a/tests/tpm_lite/tpmtest_timing.c b/tests/tpm_lite/tpmtest_timing.c index d86b4eee..1ec14a2e 100644 --- a/tests/tpm_lite/tpmtest_timing.c +++ b/tests/tpm_lite/tpmtest_timing.c @@ -28,7 +28,7 @@ gettimeofday(&before, NULL); \ __result = op; \ if (__result != TPM_SUCCESS) { \ - printf(#op ": error 0x%x\n", __result); \ + printf(#op ": error %#x\n", __result); \ errors++; \ } \ gettimeofday(&after, NULL); \ diff --git a/tests/tpm_lite/tpmtest_writelimit.c b/tests/tpm_lite/tpmtest_writelimit.c index 75bae9f1..05e4a178 100644 --- a/tests/tpm_lite/tpmtest_writelimit.c +++ b/tests/tpm_lite/tpmtest_writelimit.c @@ -43,7 +43,7 @@ int main(int argc, char** argv) { "MAX_NV_WRITES_NOOWNER reached"); break; default: - VB2_DEBUG("unexpected error code %d (0x%x)\n", + VB2_DEBUG("unexpected error code %d (%#x)\n", result, result); exit(1); } diff --git a/tests/vboot_api_kernel_tests.c b/tests/vboot_api_kernel_tests.c index 8c57dee6..5452f1d3 100644 --- a/tests/vboot_api_kernel_tests.c +++ b/tests/vboot_api_kernel_tests.c @@ -364,7 +364,7 @@ vb2_error_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count, mock_disks[num_disks].handle = (VbExDiskHandle_t) t->disks_to_provide[i].diskname; VB2_DEBUG(" mock_disk[%d] %" PRIu64 " %" PRIu64 - " 0x%x %s\n", i, + " %#x %s\n", i, mock_disks[num_disks].bytes_per_lba, mock_disks[num_disks].lba_count, mock_disks[num_disks].flags, @@ -384,7 +384,7 @@ vb2_error_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count, *count = num_disks; VB2_DEBUG(" *count=%" PRIu32 "\n", *count); - VB2_DEBUG(" return 0x%x\n", t->diskgetinfo_return_val); + VB2_DEBUG(" return %#x\n", t->diskgetinfo_return_val); return t->diskgetinfo_return_val; } @@ -416,7 +416,7 @@ void vb2_nv_set(struct vb2_context *c, { if (param != VB2_NV_RECOVERY_REQUEST) return; - VB2_DEBUG("%s(): got_recovery_request_val = %d (0x%x)\n", __FUNCTION__, + VB2_DEBUG("%s(): got_recovery_request_val = %d (%#x)\n", __FUNCTION__, value, value); got_recovery_request_val = value; } diff --git a/tests/vboot_detach_menu_tests.c b/tests/vboot_detach_menu_tests.c index ade3abd9..8d134e46 100644 --- a/tests/vboot_detach_menu_tests.c +++ b/tests/vboot_detach_menu_tests.c @@ -220,7 +220,7 @@ vb2_error_t VbDisplayScreen(struct vb2_context *c, uint32_t screen, int force, { if (screens_count < ARRAY_SIZE(screens_displayed)) screens_displayed[screens_count++] = screen; - printf("VbDisplayScreen: screens_displayed[%d] = 0x%x\n", + printf("VbDisplayScreen: screens_displayed[%d] = %#x\n", screens_count - 1, screen); return VB2_SUCCESS; } @@ -232,8 +232,8 @@ vb2_error_t VbDisplayMenu(struct vb2_context *c, uint32_t screen, int force, screens_displayed[screens_count++] = screen; else printf("Ran out of screens_displayed entries!\n"); - printf("VbDisplayMenu: screens_displayed[%d] = 0x%x," - " selected_index = %u, disabled_idx_mask = 0x%x\n", + printf("VbDisplayMenu: screens_displayed[%d] = %#x," + " selected_index = %u, disabled_idx_mask = %#x\n", screens_count - 1, screen, selected_index, disabled_idx_mask); diff --git a/utility/chromeos-tpm-recovery-test b/utility/chromeos-tpm-recovery-test index e633d311..42331e25 100755 --- a/utility/chromeos-tpm-recovery-test +++ b/utility/chromeos-tpm-recovery-test @@ -327,7 +327,7 @@ test_wrong_size_hog () { space_hog_size=$(( $(tpm-nvsize) - 2 )) fi echo "hogging $(( $space_hog_size )) bytes" >> log - $tpmc definespace 0xcafe $(printf "0x%x" $space_hog_size) 0x1 \ + $tpmc definespace 0xcafe $(printf "%#x" $space_hog_size) 0x1 \ || echo "hogging failed!" >> log takeownership diff --git a/utility/tlcl_generator.c b/utility/tlcl_generator.c index e34542b1..99ec4a5e 100644 --- a/utility/tlcl_generator.c +++ b/utility/tlcl_generator.c @@ -553,15 +553,15 @@ int OutputBytes_(Command* cmd, Field* fld) { cursor = fld->offset; switch (fld->size) { case 1: - printf("0x%x, ", fld->value); + printf("%#x, ", fld->value); cursor += 1; break; case 2: - printf("0x%x, 0x%x, ", fld->value >> 8, fld->value & 0xff); + printf("%#x, %#x, ", fld->value >> 8, fld->value & 0xff); cursor += 2; break; case 4: - printf("0x%x, 0x%x, 0x%x, 0x%x, ", fld->value >> 24, + printf("%#x, %#x, %#x, %#x, ", fld->value >> 24, (fld->value >> 16) & 0xff, (fld->value >> 8) & 0xff, fld->value & 0xff); diff --git a/utility/tpm-nvsize b/utility/tpm-nvsize index 724dcd8b..ec2d0337 100755 --- a/utility/tpm-nvsize +++ b/utility/tpm-nvsize @@ -15,7 +15,7 @@ try=$high # Binary search with no upper bound while true; do ## echo trying $try [ $low $high ] - if /usr/bin/tpmc definespace 0xf004 $(printf "0x%x" $try) 0x1 \ + if /usr/bin/tpmc definespace 0xf004 $(printf "%#x" $try) 0x1 \ > /dev/null 2>&1; then # definespace success: end, or $try must grow if [ $try -eq $low ]; then diff --git a/utility/tpmc.c b/utility/tpmc.c index dc41b03c..5723edff 100644 --- a/utility/tpmc.c +++ b/utility/tpmc.c @@ -115,7 +115,7 @@ static uint8_t ErrorCheck(uint32_t result, const char* cmd) { } else { int i; int n = sizeof(tpm_error_table) / sizeof(tpm_error_table[0]); - fprintf(stderr, "command \"%s\" failed with code 0x%x\n", cmd, result); + fprintf(stderr, "command \"%s\" failed with code %#x\n", cmd, result); for (i = 0; i < n; i++) { if (tpm_error_table[i].code == result) { fprintf(stderr, "%s\n%s\n", tpm_error_table[i].name, @@ -326,7 +326,7 @@ static uint32_t HandlerRead(void) { exit(OTHER_ERROR); } if (size > sizeof(value)) { - fprintf(stderr, "size of read (0x%x) is too big\n", size); + fprintf(stderr, "size of read (%#x) is too big\n", size); exit(OTHER_ERROR); } result = TlclRead(index, value, size); @@ -351,7 +351,7 @@ static uint32_t HandlerGetPermissions(void) { } result = TlclGetPermissions(index, &permissions); if (result == 0) { - printf("space 0x%x has permissions 0x%x\n", index, permissions); + printf("space %#x has permissions %#x\n", index, permissions); } return result; } |