summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu-Ping Wu <yupingso@chromium.org>2023-04-12 15:58:57 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-13 04:33:28 +0000
commit35f50c3154e58821cc027bf13be2b949bc4c90f3 (patch)
tree57d9161b15578c9532cb168d55580bd038f811f7
parent35f62791446b10ac50f184397a9a38dbf762bddd (diff)
downloadvboot-35f50c3154e58821cc027bf13be2b949bc4c90f3.tar.gz
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 <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4418006 Reviewed-by: Julius Werner <jwerner@chromium.org>
-rw-r--r--firmware/stub/tpm_lite_stub.c10
1 files 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) ||
@@ -278,6 +277,7 @@ uint32_t vb2ex_tpm_send_recv(const uint8_t* request, uint32_t request_length,
response_tag == TPM_TAG_RSP_AUTH2_COMMAND));
assert(*response_length == TpmResponseSize(response));
#endif
+#endif
return TPM_SUCCESS;
}