From 3617abca97c26e1b9c0a0351b35d4fb23d70926c Mon Sep 17 00:00:00 2001 From: David Garske Date: Tue, 5 Nov 2024 11:34:54 -0800 Subject: [PATCH] Fix warning: `cannot convert argument of incomplete type 'void *' to 'WOLFTPM2_KEY *'`. Fix `extend.c:158:9: warning: Value stored to 'rc' is never read`. Fix `src/tpm2_wrap.c:2193:5: warning: Value stored to 'sensSz' is never read`. --- examples/bench/bench.c | 2 +- examples/keygen/keygen.c | 2 +- examples/keygen/keyimport.c | 2 +- examples/keygen/keyload.c | 2 +- examples/pcr/extend.c | 1 - examples/pcr/quote.c | 2 +- examples/wrap/wrap_test.c | 4 ++-- src/tpm2_wrap.c | 4 +++- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/bench/bench.c b/examples/bench/bench.c index e8ad8a91..3d1ac8a5 100644 --- a/examples/bench/bench.c +++ b/examples/bench/bench.c @@ -269,7 +269,7 @@ int TPM2_Wrapper_BenchArgs(void* userCtx, int argc, char *argv[]) if (rc != 0) goto exit; if (paramEncAlg != TPM_ALG_NULL) { - void* bindKey = &storageKey; + WOLFTPM2_KEY* bindKey = &storageKey; #ifdef NO_RSA bindKey = NULL; /* cannot bind to key without RSA enabled */ #endif diff --git a/examples/keygen/keygen.c b/examples/keygen/keygen.c index dd13db84..34e85008 100644 --- a/examples/keygen/keygen.c +++ b/examples/keygen/keygen.c @@ -235,7 +235,7 @@ int TPM2_Keygen_Example(void* userCtx, int argc, char *argv[]) if (rc != 0) goto exit; if (paramEncAlg != TPM_ALG_NULL) { - void* bindKey = primary; + WOLFTPM2_KEY* bindKey = primary; #ifndef HAVE_ECC if (srkAlg == TPM_ALG_ECC) bindKey = NULL; /* cannot bind to key without ECC enabled */ diff --git a/examples/keygen/keyimport.c b/examples/keygen/keyimport.c index 77bdfda8..a3f9760d 100644 --- a/examples/keygen/keyimport.c +++ b/examples/keygen/keyimport.c @@ -162,7 +162,7 @@ int TPM2_Keyimport_Example(void* userCtx, int argc, char *argv[]) if (rc != 0) goto exit; if (paramEncAlg != TPM_ALG_NULL) { - void* bindKey = &storage; + WOLFTPM2_KEY* bindKey = &storage; #ifndef HAVE_ECC if (srkAlg == TPM_ALG_ECC) bindKey = NULL; /* cannot bind to key without ECC enabled */ diff --git a/examples/keygen/keyload.c b/examples/keygen/keyload.c index 0d7f3dd2..d026b7cc 100644 --- a/examples/keygen/keyload.c +++ b/examples/keygen/keyload.c @@ -159,7 +159,7 @@ int TPM2_Keyload_Example(void* userCtx, int argc, char *argv[]) if (rc != 0) goto exit; } else if (paramEncAlg != TPM_ALG_NULL) { - void* bindKey = &storage; + WOLFTPM2_KEY* bindKey = &storage; #ifndef HAVE_ECC if (srkAlg == TPM_ALG_ECC) bindKey = NULL; /* cannot bind to key without ECC enabled */ diff --git a/examples/pcr/extend.c b/examples/pcr/extend.c index 3b53bc8a..0e59d1d7 100644 --- a/examples/pcr/extend.c +++ b/examples/pcr/extend.c @@ -155,7 +155,6 @@ int TPM2_PCR_Extend_Test(void* userCtx, int argc, char *argv[]) if (filename && fp != XBADFILE) { rc = TPM2_GetHashType(alg); hashType = (enum wc_HashType)rc; - rc = 0; wc_HashInit(&dig, hashType); while (!XFEOF(fp)) { len = XFREAD(dataBuffer, 1, sizeof(dataBuffer), fp); diff --git a/examples/pcr/quote.c b/examples/pcr/quote.c index fea7eb4b..a3d4a34b 100644 --- a/examples/pcr/quote.c +++ b/examples/pcr/quote.c @@ -184,7 +184,7 @@ int TPM2_PCR_Quote_Test(void* userCtx, int argc, char *argv[]) #endif if (paramEncAlg != TPM_ALG_NULL) { - void* bindKey = &storage; + WOLFTPM2_KEY* bindKey = &storage; #ifndef HAVE_ECC if (alg == TPM_ALG_ECC) bindKey = NULL; /* cannot bind to key without ECC enabled */ diff --git a/examples/wrap/wrap_test.c b/examples/wrap/wrap_test.c index 8ebeecf1..35703cb7 100644 --- a/examples/wrap/wrap_test.c +++ b/examples/wrap/wrap_test.c @@ -267,7 +267,7 @@ int TPM2_Wrapper_TestArgs(void* userCtx, int argc, char *argv[]) /* Start an authenticated session (salted / unbound) with parameter encryption */ if (paramEncAlg != TPM_ALG_NULL) { - void* bindKey = &storageKey; + WOLFTPM2_KEY* bindKey = &storageKey; #ifdef NO_RSA bindKey = NULL; /* cannot bind to key without RSA enabled */ #endif @@ -547,7 +547,7 @@ int TPM2_Wrapper_TestArgs(void* userCtx, int argc, char *argv[]) /* Start an authenticated session (salted / unbound) with parameter encryption */ if (paramEncAlg != TPM_ALG_NULL) { - void* bindKey = &storageKey; + WOLFTPM2_KEY* bindKey = &storageKey; #ifndef HAVE_ECC bindKey = NULL; /* cannot bind to key without ECC enabled */ #endif diff --git a/src/tpm2_wrap.c b/src/tpm2_wrap.c index 2fe4bd36..18e24871 100644 --- a/src/tpm2_wrap.c +++ b/src/tpm2_wrap.c @@ -2216,7 +2216,8 @@ static int SensitiveToPrivate(TPM2B_SENSITIVE* sens, TPM2B_PRIVATE* priv, ivField.size == 0 ? NULL : ivField.buffer, AES_ENCRYPTION); if (rc == 0) { /* use inline encryption for both IV and sensitive */ - rc = wc_AesCfbEncrypt(&enc, sensitiveData, sensitiveData, sensSz); + rc = wc_AesCfbEncrypt(&enc, sensitiveData, sensitiveData, + sensSz); } wc_AesFree(&enc); } @@ -2272,6 +2273,7 @@ static int SensitiveToPrivate(TPM2B_SENSITIVE* sens, TPM2B_PRIVATE* priv, (void)sensitiveData; (void)name; (void)symKey; + (void)sensSz; rc = NOT_COMPILED_IN; #endif }