From e050a2c88fc963cb97d9794849e9e2b60fabbe77 Mon Sep 17 00:00:00 2001 From: Joel Kitching Date: Mon, 22 Jul 2019 14:21:35 +0800 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1710340 Tested-by: Joel Kitching Reviewed-by: Julius Werner Commit-Queue: Joel Kitching --- firmware/include/vboot_api.h | 9 --------- firmware/lib/include/utility.h | 6 ++++-- firmware/stub/vboot_api_stub_init.c | 28 ---------------------------- host/lib/host_key2.c | 6 +++--- tests/tpm_lite/tpmtest_enable.c | 4 +++- tests/tpm_lite/tpmtest_writelimit.c | 4 +++- 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 @@ -308,15 +308,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) */ 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; irsa_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 +#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 #include +#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); } } } -- cgit v1.2.1