summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2019-07-22 14:21:35 +0800
committerCommit Bot <commit-bot@chromium.org>2019-07-24 06:53:41 +0000
commite050a2c88fc963cb97d9794849e9e2b60fabbe77 (patch)
treef037b8c93a7dc4b8a5d23c9b7a643d1dedfc71e0
parent34abb32ed2e48ccad95320c37fb001df8e3442fd (diff)
downloadvboot-e050a2c88fc963cb97d9794849e9e2b60fabbe77.tar.gz
vboot: deprecate VbExError function
Convert uses of this function to call VB2_DEBUG and manually exit if necessary. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I9006b1a9c66645757d33310d96207233b88eaed5 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1710340 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
-rw-r--r--firmware/include/vboot_api.h9
-rw-r--r--firmware/lib/include/utility.h6
-rw-r--r--firmware/stub/vboot_api_stub_init.c28
-rw-r--r--host/lib/host_key2.c6
-rw-r--r--tests/tpm_lite/tpmtest_enable.c4
-rw-r--r--tests/tpm_lite/tpmtest_writelimit.c4
6 files changed, 13 insertions, 44 deletions
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
index 6142cfa7..518b8cd8 100644
--- a/firmware/include/vboot_api.h
+++ b/firmware/include/vboot_api.h
@@ -309,15 +309,6 @@ VbError_t VbVerifyMemoryBootImage(struct vb2_context *ctx,
VbError_t VbUnlockDevice(void);
/*****************************************************************************/
-/* Debug output (from utility.h) */
-
-/**
- * Output an error message and quit. Does not return. Supports
- * printf()-style formatting.
- */
-void VbExError(const char *format, ...);
-
-/*****************************************************************************/
/* Timer and delay (first two from utility.h) */
#define VB_USEC_PER_MSEC 1000ULL
diff --git a/firmware/lib/include/utility.h b/firmware/lib/include/utility.h
index 10562a58..272b9f42 100644
--- a/firmware/lib/include/utility.h
+++ b/firmware/lib/include/utility.h
@@ -11,13 +11,15 @@
#ifndef VBOOT_REFERENCE_UTILITY_H_
#define VBOOT_REFERENCE_UTILITY_H_
+#include "2common.h"
#include "sysincludes.h"
#include "vboot_api.h"
#ifdef VBOOT_DEBUG
#define VbAssert(expr) do { if (!(expr)) { \
- VbExError("assert fail: %s at %s:%d\n", \
- #expr, __FILE__, __LINE__); }} while(0)
+ VB2_DEBUG("assert fail: %s at %s:%d\n", \
+ #expr, __FILE__, __LINE__); \
+ exit(1); }} while(0)
#else
#define VbAssert(expr)
#endif
diff --git a/firmware/stub/vboot_api_stub_init.c b/firmware/stub/vboot_api_stub_init.c
index 23ae9f78..0f7a3482 100644
--- a/firmware/stub/vboot_api_stub_init.c
+++ b/firmware/stub/vboot_api_stub_init.c
@@ -15,34 +15,6 @@
#include "vboot_api.h"
-/* U-Boot's printf uses '%L' for uint64_t. gcc uses '%l'. */
-#define MAX_FMT 255
-static char fmtbuf[MAX_FMT+1];
-
-static const char *fixfmt(const char *format)
-{
- int i;
- for(i=0; i<sizeof(fmtbuf)-1 && format[i]; i++) {
- fmtbuf[i] = format[i];
- if(format[i] == '%' && format[i+1] == 'L') {
- fmtbuf[i+1] = 'l';
- i++;
- }
- }
- fmtbuf[i] = '\0';
- return fmtbuf;
-}
-
-void VbExError(const char *format, ...)
-{
- va_list ap;
- va_start(ap, format);
- fprintf(stderr, "ERROR: ");
- vfprintf(stderr, fixfmt(format), ap);
- va_end(ap);
- exit(1);
-}
-
uint64_t VbExGetTimer(void)
{
struct timeval tv;
diff --git a/host/lib/host_key2.c b/host/lib/host_key2.c
index b33ba164..64aab1b4 100644
--- a/host/lib/host_key2.c
+++ b/host/lib/host_key2.c
@@ -44,14 +44,14 @@ struct vb2_private_key *vb2_read_private_key(const char *filename)
uint8_t *buf = NULL;
uint32_t bufsize = 0;
if (VB2_SUCCESS != vb2_read_file(filename, &buf, &bufsize)) {
- VbExError("unable to read from file %s\n", filename);
+ VB2_DEBUG("unable to read from file %s\n", filename);
return NULL;
}
struct vb2_private_key *key =
(struct vb2_private_key *)calloc(sizeof(*key), 1);
if (!key) {
- VbExError("Unable to allocate private key\n");
+ VB2_DEBUG("Unable to allocate private key\n");
free(buf);
return NULL;
}
@@ -65,7 +65,7 @@ struct vb2_private_key *vb2_read_private_key(const char *filename)
d2i_RSAPrivateKey(0, &start, bufsize - sizeof(alg));
if (!key->rsa_private_key) {
- VbExError("Unable to parse RSA private key\n");
+ VB2_DEBUG("Unable to parse RSA private key\n");
free(buf);
free(key);
return NULL;
diff --git a/tests/tpm_lite/tpmtest_enable.c b/tests/tpm_lite/tpmtest_enable.c
index 645cd467..c2fe54b0 100644
--- a/tests/tpm_lite/tpmtest_enable.c
+++ b/tests/tpm_lite/tpmtest_enable.c
@@ -8,6 +8,7 @@
#include <stdio.h>
+#include "2common.h"
#include "host_common.h"
#include "tlcl.h"
#include "tlcl_tests.h"
@@ -27,7 +28,8 @@ int main(int argc, char** argv) {
TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
printf("disable is %d, deactivated is %d\n", disable, deactivated);
if (disable == 1 || deactivated == 1) {
- VbExError("failed to enable or activate");
+ VB2_DEBUG("failed to enable or activate");
+ return 1;
}
printf("TEST SUCCEEDED\n");
return 0;
diff --git a/tests/tpm_lite/tpmtest_writelimit.c b/tests/tpm_lite/tpmtest_writelimit.c
index 66dcc036..cedcd831 100644
--- a/tests/tpm_lite/tpmtest_writelimit.c
+++ b/tests/tpm_lite/tpmtest_writelimit.c
@@ -10,6 +10,7 @@
#include <stdint.h>
#include <stdlib.h>
+#include "2common.h"
#include "host_common.h"
#include "tlcl.h"
#include "tlcl_tests.h"
@@ -39,8 +40,9 @@ int main(int argc, char** argv) {
VbAssert(i >= TPM_MAX_NV_WRITES_NOOWNER);
break;
default:
- VbExError("unexpected error code %d (0x%x)\n",
+ VB2_DEBUG("unexpected error code %d (0x%x)\n",
result, result);
+ exit(1);
}
}
}