Skip to content

Commit d044360

Browse files
committed
Fixes for scan-build and g++ warnings.
1 parent 8087afa commit d044360

6 files changed

Lines changed: 16 additions & 5 deletions

File tree

examples/pcr/quote.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ int TPM2_Quote_Test(void* userCtx, int argc, char *argv[])
213213
#else
214214
printf("Quote Blob %d\n", dataSz);
215215
TPM2_PrintBin(data, dataSz);
216+
(void)data;
217+
(void)dataSz;
216218
#endif
217219

218220
printf("TPM with signature attests (type 0x%x):\n", attestedData.type);

examples/timestamp/signed_timestamp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ int TPM2_Timestamp_TestArgs(void* userCtx, int argc, char *argv[])
230230

231231
printf("TPM with signature attests (type 0x%x):\n", attestedData.type);
232232
/* time value in milliseconds that advances while the TPM is powered */
233-
printf("\tTPM uptime since last power-up(in ms): %lu\n",
233+
printf("\tTPM uptime since last power-up (in ms): %lu\n",
234234
(unsigned long)attestedData.attested.time.time.time);
235235
/* time value in milliseconds that advances while the TPM is powered */
236-
printf("\tTPM clock, total time the TPM has been on(in ms): %lu\n",
236+
printf("\tTPM clock, total time the TPM has been on (in ms): %lu\n",
237237
(unsigned long)attestedData.attested.time.time.clockInfo.clock);
238238
/* number of occurrences of TPM Reset since the last TPM2_Clear() */
239239
printf("\tReset Count: %u\n",
@@ -245,7 +245,7 @@ int TPM2_Timestamp_TestArgs(void* userCtx, int argc, char *argv[])
245245
printf("\tClock Safe: %u\n",
246246
attestedData.attested.time.time.clockInfo.safe);
247247
/* a TPM vendor-specific value indicating the version number of the firmware */
248-
printf("\tFirmware Version(vendor specific): 0x%lX\n",
248+
printf("\tFirmware Version (vendor specific): 0x%lX\n",
249249
(unsigned long)attestedData.attested.time.firmwareVersion);
250250

251251
exit:

examples/wrap/wrap_test.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ int TPM2_Wrapper_TestArgs(void* userCtx, int argc, char *argv[])
117117
ecc_key wolfEccPubKey;
118118
ecc_key wolfEccPrivKey;
119119
#endif
120+
#endif /* !WOLFTPM2_NO_WOLFCRYPT */
120121
TPM_ALG_ID paramEncAlg = TPM_ALG_NULL;
121122
WOLFTPM2_SESSION tpmSession;
122123

124+
#ifndef WOLFTPM2_NO_WOLFCRYPT
123125
#ifndef NO_RSA
124126
XMEMSET(&wolfRsaPubKey, 0, sizeof(wolfRsaPubKey));
125127
XMEMSET(&wolfRsaPrivKey, 0, sizeof(wolfRsaPrivKey));
@@ -128,8 +130,8 @@ int TPM2_Wrapper_TestArgs(void* userCtx, int argc, char *argv[])
128130
XMEMSET(&wolfEccPubKey, 0, sizeof(wolfEccPubKey));
129131
XMEMSET(&wolfEccPrivKey, 0, sizeof(wolfEccPrivKey));
130132
#endif
131-
XMEMSET(&tpmSession, 0, sizeof(tpmSession));
132133
#endif /* !WOLFTPM2_NO_WOLFCRYPT */
134+
XMEMSET(&tpmSession, 0, sizeof(tpmSession));
133135

134136
if (argc >= 2) {
135137
if (XSTRNCMP(argv[1], "-?", 2) == 0 ||

src/tpm2.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ static int TPM2_CommandProcess(TPM2_CTX* ctx, TPM2_Packet* packet,
139139
#ifdef WOLFTPM_DEBUG_VERBOSE
140140
printf("CommandProcess: Handles (Auth %d, In %d), CmdSz %d, AuthSz %d, ParamSz %d, EncSz %d\n",
141141
info->authCnt, info->inHandleCnt, cmdSz, authSz, paramSz, encParamSz);
142+
#else
143+
(void)paramSz;
142144
#endif
143145

144146
for (i=0; i<info->authCnt; i++) {

src/tpm2_wrap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,9 @@ int wolfTPM2_SensitiveToPrivate(TPM2B_SENSITIVE* sens, TPM2B_PRIVATE* priv,
11381138
rc = wc_AesCfbEncrypt(&enc, &packet.buf[innerSz], &packet.buf[innerSz], sensSz);
11391139
wc_AesFree(&enc);
11401140
}
1141+
#else
1142+
(void)innerAlg;
1143+
(void)sensSz;
11411144
#endif
11421145
}
11431146

@@ -1712,6 +1715,7 @@ int wolfTPM2_EccKey_WolfToTpm_ex(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* parentKey,
17121715
if (dev == NULL || tpmKey == NULL || wolfKey == NULL)
17131716
return BAD_FUNC_ARG;
17141717

1718+
XMEMSET(tpmKey, 0, sizeof(*tpmKey));
17151719
XMEMSET(qx, 0, sizeof(qx));
17161720
XMEMSET(qy, 0, sizeof(qy));
17171721

@@ -4099,6 +4103,7 @@ int wolfTPM2_CryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx)
40994103
byte sigRS[MAX_ECC_BYTES*2];
41004104
byte *r = sigRS, *s = &sigRS[MAX_ECC_BYTES];
41014105
word32 rLen = MAX_ECC_BYTES, sLen = MAX_ECC_BYTES;
4106+
XMEMSET(&eccPub, 0, sizeof(eccPub));
41024107

41034108
/* Decode ECDSA Header */
41044109
rc = wc_ecc_sig_to_rs(info->pk.eccverify.sig,

wolftpm/tpm2_wrap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ typedef struct WOLFTPM2_HANDLE {
3838
#define TPM_SES_PWD 0xFF /* Session type for Password that fits in one byte */
3939

4040
typedef struct WOLFTPM2_SESSION {
41-
TPM_ST_T type; /* Trial, Policy or HMAC; or TPM_SES_PWD */
41+
TPM_ST type; /* Trial, Policy or HMAC; or TPM_SES_PWD */
4242
WOLFTPM2_HANDLE handle; /* Session handle from StartAuthSession */
4343
TPM2B_NONCE nonceTPM; /* Value from StartAuthSession */
4444
TPM2B_NONCE nonceCaller; /* Fresh nonce at each command */

0 commit comments

Comments
 (0)