summaryrefslogtreecommitdiff
path: root/futility
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2019-10-04 17:46:29 +0800
committerCommit Bot <commit-bot@chromium.org>2019-10-23 16:28:14 +0000
commit3c477458fa7f1506e722ede38636eaced8810687 (patch)
tree6af8c80467619faa021405a72ab8c6e5eb12b55b /futility
parentffa02e80c8cec862106607ffd0333258bb1ed62e (diff)
downloadvboot-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>
Diffstat (limited to 'futility')
-rw-r--r--futility/cmd_dump_fmap.c4
-rw-r--r--futility/cmd_show.c12
-rw-r--r--futility/cmd_sign.c10
-rw-r--r--futility/cmd_validate_rec_mrc.c4
-rw-r--r--futility/cmd_vbutil_kernel.c10
-rw-r--r--futility/file_type_bios.c2
-rw-r--r--futility/file_type_rwsig.c14
-rw-r--r--futility/file_type_usbpd1.c2
-rw-r--r--futility/vb1_helper.c52
9 files changed, 55 insertions, 55 deletions
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)) {