From 35f50c3154e58821cc027bf13be2b949bc4c90f3 Mon Sep 17 00:00:00 2001 From: Yu-Ping Wu Date: Wed, 12 Apr 2023 15:58:57 +0800 Subject: Fix build error when compiling without -DNDEBUG Currently the host lib is always built with "-DNDEBUG" (added by Makefile). When NDEBUG is undefined, the symbols such as TPM_TAG_RQU_COMMAND will be undeclared, leading to build error. Since the assertion is for TPM1 only, add #ifndef guard for TPM2_MODE. BUG=none TEST=make hostlib TPM2_MODE=0 DISABLE_NDEBUG=0 TEST=make hostlib TPM2_MODE=0 DISABLE_NDEBUG=1 TEST=make hostlib TPM2_MODE=1 DISABLE_NDEBUG=0 TEST=make hostlib TPM2_MODE=1 DISABLE_NDEBUG=1 BRANCH=none Change-Id: Id2cb327e512140ed8fff04f5e54d3090d9e25dbe Signed-off-by: Yu-Ping Wu Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4418006 Reviewed-by: Julius Werner --- firmware/stub/tpm_lite_stub.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/firmware/stub/tpm_lite_stub.c b/firmware/stub/tpm_lite_stub.c index ed405b09..1b7170a6 100644 --- a/firmware/stub/tpm_lite_stub.c +++ b/firmware/stub/tpm_lite_stub.c @@ -24,6 +24,7 @@ #include "2sysincludes.h" #include "tlcl.h" #include "tlcl_internal.h" +#include "tss_constants.h" #define TPM_DEVICE_PATH "/dev/tpm0" /* Retry failed open()s for 5 seconds in 10ms polling intervals. */ @@ -240,9 +241,6 @@ uint32_t vb2ex_tpm_send_recv(const uint8_t* request, uint32_t request_length, * response); * // Error checking depending on the value of the status above */ -#ifndef NDEBUG - int tag, response_tag; -#endif uint32_t result; #ifdef VBOOT_DEBUG @@ -266,9 +264,10 @@ uint32_t vb2ex_tpm_send_recv(const uint8_t* request, uint32_t request_length, #endif #ifndef NDEBUG +#ifndef TPM2_MODE /* validity checks */ - tag = TpmTag(request); - response_tag = TpmTag(response); + int tag = TpmTag(request); + int response_tag = TpmTag(response); assert( (tag == TPM_TAG_RQU_COMMAND && response_tag == TPM_TAG_RSP_COMMAND) || @@ -277,6 +276,7 @@ uint32_t vb2ex_tpm_send_recv(const uint8_t* request, uint32_t request_length, (tag == TPM_TAG_RQU_AUTH2_COMMAND && response_tag == TPM_TAG_RSP_AUTH2_COMMAND)); assert(*response_length == TpmResponseSize(response)); +#endif #endif return TPM_SUCCESS; -- cgit v1.2.1