summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2023-03-14 18:15:43 +1100
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-03-25 12:52:30 +0000
commit3fb4566c02e4152f3edaad773238e8e8dc09695e (patch)
treeae4f7b216269e8c65f452691ba262bbf75a14f1f
parente1ad854c54e691234e2d8e6a60cbce83fed78d6e (diff)
downloadvboot-3fb4566c02e4152f3edaad773238e8e8dc09695e.tar.gz
futility/file_type_*: Use ERROR() macro consistently
Fix grammatical issues in ERROR() usage and over usage of contractions. Now errors shall now be prefixed with "ERROR:" and the function name. BUG=b:268397597 TEST=`emerge-nissa vboot_reference`. TEST=`cros_run_unit_tests --host --packages vboot_reference`. TEST=`cros_run_unit_tests --board nissa --packages vboot_reference`. Change-Id: Iba811c4d4714b9af1a3982613b74ca43958d7934 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4349559 Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
-rw-r--r--futility/file_type.c10
-rw-r--r--futility/file_type_bios.c18
-rw-r--r--futility/file_type_rwsig.c30
-rw-r--r--futility/file_type_usbpd1.c29
4 files changed, 40 insertions, 47 deletions
diff --git a/futility/file_type.c b/futility/file_type.c
index 527dcbe4..69e71496 100644
--- a/futility/file_type.c
+++ b/futility/file_type.c
@@ -107,7 +107,7 @@ enum futil_file_err futil_file_type(const char *filename,
goto done;
if (fstat(ifd, &sb)) {
- fprintf(stderr, "Can't stat input file: %s\n", strerror(errno));
+ ERROR("Cannot stat input file: %s\n", strerror(errno));
err = FILE_ERR_STAT;
goto done;
}
@@ -137,8 +137,8 @@ int futil_file_type_show(enum futil_file_type type, const char *filename)
if (futil_file_types[type].show)
return futil_file_types[type].show(filename, 0);
- fprintf(stderr, "Don't know how to show %s (type %s)\n",
- filename, futil_file_type_name(type));
+ ERROR("Don't know how to show %s (type %s)\n", filename,
+ futil_file_type_name(type));
return 1;
}
@@ -147,7 +147,7 @@ int futil_file_type_sign(enum futil_file_type type, const char *filename)
if (futil_file_types[type].sign)
return futil_file_types[type].sign(filename, 0);
- fprintf(stderr, "Don't know how to sign %s (type %s)\n",
- filename, futil_file_type_name(type));
+ ERROR("Don't know how to sign %s (type %s)\n", filename,
+ futil_file_type_name(type));
return 1;
}
diff --git a/futility/file_type_bios.c b/futility/file_type_bios.c
index 295fdcd9..9552ead5 100644
--- a/futility/file_type_bios.c
+++ b/futility/file_type_bios.c
@@ -238,7 +238,7 @@ static int write_new_preamble(struct bios_area_s *vblock,
signkey);
if (!body_sig) {
- ERROR("Error calculating or creating body signature\n");
+ ERROR("Cannot calculate or creating body signature\n");
return 1;
}
@@ -248,7 +248,7 @@ static int write_new_preamble(struct bios_area_s *vblock,
signkey,
vblock->flags);
if (!preamble) {
- ERROR("Error creating firmware preamble.\n");
+ ERROR("Cannot create firmware preamble.\n");
goto end;
}
@@ -278,26 +278,24 @@ static int write_loem(const char *ab, struct bios_area_s *vblock)
sign_option.loemdir ? sign_option.loemdir : ".",
ab, sign_option.loemid);
if (n >= sizeof(filename)) {
- fprintf(stderr, "LOEM args produce bogus filename\n");
+ ERROR("LOEM args produce bogus filename\n");
return 1;
}
FILE *fp = fopen(filename, "w");
if (!fp) {
- fprintf(stderr, "Can't open %s for writing: %s\n",
- filename, strerror(errno));
+ ERROR("Cannot open %s for writing: %s\n", filename,
+ strerror(errno));
return 1;
}
if (1 != fwrite(vblock->buf, vblock->len, 1, fp)) {
- fprintf(stderr, "Can't write to %s: %s\n",
- filename, strerror(errno));
+ ERROR("Cannot write to %s: %s\n", filename, strerror(errno));
fclose(fp);
return 1;
}
if (fclose(fp)) {
- fprintf(stderr, "Failed closing loem output: %s\n",
- strerror(errno));
+ ERROR("Failed closing loem output: %s\n", strerror(errno));
return 1;
}
@@ -314,7 +312,7 @@ static int sign_bios_at_end(struct bios_state_s *state)
int retval = 0;
if (!vblock_a->is_valid || !fw_a->is_valid) {
- fprintf(stderr, "Something's wrong. Not changing anything\n");
+ ERROR("Something's wrong. Not changing anything\n");
return 1;
}
diff --git a/futility/file_type_rwsig.c b/futility/file_type_rwsig.c
index b5913a35..34e5efed 100644
--- a/futility/file_type_rwsig.c
+++ b/futility/file_type_rwsig.c
@@ -182,7 +182,7 @@ int ft_show_rwsig(const char *name, void *nuthin)
(struct vb21_signature *)sigbuf,
(const struct vb2_public_key *)&key,
&wb)) {
- fprintf(stderr, "Signature verification failed\n");
+ ERROR("Signature verification failed\n");
goto done;
}
}
@@ -190,7 +190,7 @@ int ft_show_rwsig(const char *name, void *nuthin)
/* Check that the rest of region is padded with 0xff. */
for (i = data_size; i < total_data_size; i++) {
if (data[i] != 0xff) {
- fprintf(stderr, "Padding verification failed\n");
+ ERROR("Padding verification failed\n");
goto done;
}
}
@@ -265,7 +265,7 @@ int ft_sign_rwsig(const char *name, void *nuthin)
len - sig_size);
if (len < sig_size) {
- fprintf(stderr, "File is too small\n");
+ ERROR("File is too small\n");
goto done;
}
@@ -275,7 +275,7 @@ int ft_sign_rwsig(const char *name, void *nuthin)
}
if (vb21_verify_signature(old_sig, sig_size)) {
- fprintf(stderr, "Can't find a valid signature\n");
+ ERROR("Can't find a valid signature\n");
goto done;
}
@@ -295,8 +295,7 @@ int ft_sign_rwsig(const char *name, void *nuthin)
r = vb21_sign_data(&tmp_sig,
data, data_size, sign_option.prikey, 0);
if (r) {
- fprintf(stderr,
- "Unable to sign data (error 0x%08x)\n", r);
+ ERROR("Unable to sign data (error 0x%08x)\n", r);
goto done;
}
} else {
@@ -304,7 +303,7 @@ int ft_sign_rwsig(const char *name, void *nuthin)
if (!old_sig) {
/* This isn't necessary because no prikey mode runs only
* for fmap input or RW input */
- fprintf(stderr, "Previous signature not found.\n");
+ ERROR("Previous signature not found.\n");
goto done;
}
tmp_sig = calloc(1, old_sig->c.total_size);
@@ -316,8 +315,8 @@ int ft_sign_rwsig(const char *name, void *nuthin)
if (sign_option.inout_file_count < 2) {
/* Overwrite the old signature */
if (tmp_sig->c.total_size > sig_size) {
- fprintf(stderr, "New sig is too large (%d > %d)\n",
- tmp_sig->c.total_size, sig_size);
+ ERROR("New sig is too large (%d > %d)\n",
+ tmp_sig->c.total_size, sig_size);
goto done;
}
VB2_DEBUG("Replacing old signature with new one\n");
@@ -334,8 +333,7 @@ int ft_sign_rwsig(const char *name, void *nuthin)
/* Write the signature to a new file */
r = vb21_write_object(sign_option.outfile, tmp_sig);
if (r) {
- fprintf(stderr, "Unable to write sig"
- " (error 0x%08x, if that helps)\n", r);
+ ERROR("Unable to write sig (error 0x%08x)\n", r);
goto done;
}
}
@@ -349,14 +347,14 @@ int ft_sign_rwsig(const char *name, void *nuthin)
/* Create the public key */
if (vb2_public_key_alloc(&pubkey,
sign_option.prikey->sig_alg)) {
- fprintf(stderr, "Unable to allocate the public key\n");
+ ERROR("Unable to allocate the public key\n");
goto done;
}
/* Extract the keyb blob */
if (vb_keyb_from_rsa(sign_option.prikey->rsa_private_key,
&keyb_data, &keyb_size)) {
- fprintf(stderr, "Couldn't extract the public key\n");
+ ERROR("Couldn't extract the public key\n");
goto done;
}
@@ -370,7 +368,7 @@ int ft_sign_rwsig(const char *name, void *nuthin)
/* Fill in the internal struct pointers */
if (vb2_unpack_key_data(pubkey, pubkey_buf, keyb_size)) {
- fprintf(stderr, "Unable to unpack the public key blob\n");
+ ERROR("Unable to unpack the public key blob\n");
goto done;
}
@@ -394,8 +392,8 @@ int ft_sign_rwsig(const char *name, void *nuthin)
}
/* Overwrite the old signature */
if (packedkey->c.total_size > fmaparea->area_size) {
- fprintf(stderr, "New sig is too large (%d > %d)\n",
- packedkey->c.total_size, sig_size);
+ ERROR("New sig is too large (%d > %d)\n",
+ packedkey->c.total_size, sig_size);
goto done;
}
diff --git a/futility/file_type_usbpd1.c b/futility/file_type_usbpd1.c
index 056b994e..4b4bf2bd 100644
--- a/futility/file_type_usbpd1.c
+++ b/futility/file_type_usbpd1.c
@@ -110,8 +110,8 @@ int ft_sign_usbpd1(const char *name, void *data)
/* Read the signing keypair file */
if (vb2_private_key_read_pem(&key_ptr, sign_option.pem_signpriv)) {
- fprintf(stderr, "Unable to read keypair from %s\n",
- sign_option.pem_signpriv);
+ ERROR("Unable to read keypair from %s\n",
+ sign_option.pem_signpriv);
goto done;
}
@@ -119,16 +119,16 @@ int ft_sign_usbpd1(const char *name, void *data)
key_ptr->hash_alg = sign_option.hash_alg;
key_ptr->sig_alg = vb2_rsa_sig_alg(key_ptr->rsa_private_key);
if (key_ptr->sig_alg == VB2_SIG_INVALID) {
- fprintf(stderr, "Unsupported sig algorithm in RSA key\n");
+ ERROR("Unsupported sig algorithm in RSA key\n");
goto done;
}
/* Figure out what needs signing */
sig_size = vb2_rsa_sig_size(key_ptr->sig_alg);
if (rw_size < sig_size) {
- fprintf(stderr,
- "The RW image is too small to hold the signature"
- " (0x%08x < %08x)\n", rw_size, sig_size);
+ ERROR("The RW image is too small to hold the signature"
+ " (0x%08x < %08x)\n",
+ rw_size, sig_size);
goto done;
}
rw_size -= sig_size;
@@ -142,17 +142,14 @@ int ft_sign_usbpd1(const char *name, void *data)
/* Sign the blob */
r = vb21_sign_data(&sig_ptr, buf + rw_offset, rw_size, key_ptr, "Bah");
if (r) {
- fprintf(stderr,
- "Unable to sign data (error 0x%08x, if that helps)\n",
- r);
+ ERROR("Unable to sign data (error 0x%08x, if that helps)\n", r);
goto done;
}
/* Double-check the size */
if (sig_ptr->sig_size != sig_size) {
- fprintf(stderr,
- "ERROR: sig size is %d bytes, not %d as expected.\n",
- sig_ptr->sig_size, sig_size);
+ ERROR("The sig size is %d bytes, not %d as expected.\n",
+ sig_ptr->sig_size, sig_size);
goto done;
}
@@ -169,7 +166,7 @@ int ft_sign_usbpd1(const char *name, void *data)
/* Otherwise, now update the public key */
if (vb_keyb_from_rsa(key_ptr->rsa_private_key,
&keyb_data, &keyb_size)) {
- fprintf(stderr, "Couldn't extract the public key\n");
+ ERROR("Could not extract the public key\n");
goto done;
}
VB2_DEBUG("keyb_size is %#x (%d):\n", keyb_size, keyb_size);
@@ -201,9 +198,9 @@ int ft_sign_usbpd1(const char *name, void *data)
pub_offset = ro_offset + ro_size - pub_size;
if (ro_size < pub_size) {
- fprintf(stderr,
- "The RO image is too small to hold the public key"
- " (0x%08x < %08x)\n", ro_size, pub_size);
+ ERROR("The RO image is too small to hold the public key"
+ " (0x%08x < %08x)\n",
+ ro_size, pub_size);
goto done;
}