Better fixes for pedantic to resolve (error: comparison of unsigned expression >= 0 is always true). Also overlong lines.

This commit is contained in:
David Garske
2023-04-04 14:26:18 -07:00
committed by Daniel Pouzzner
parent f3eee4bc99
commit 72c6429276
5 changed files with 15 additions and 13 deletions

View File

@@ -4563,8 +4563,8 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
#if (defined(HAVE_AESGCM) && !defined(WC_NO_RNG)) || defined(HAVE_AESCCM)
static WC_INLINE void IncCtr(byte* ctr, word32 ctrSz)
{
word32 i;
for (i = ctrSz-1; i >= 0; i--) {
int i;
for (i = (int)ctrSz - 1; i >= 0; i--) {
if (++ctr[i])
break;
}

View File

@@ -8185,7 +8185,8 @@ int wc_EncryptPKCS8Key(byte* key, word32 keySz, byte* out, word32* outSz,
ret = GetAlgoV2(encAlgId, &encOid, &encOidSz, &pbeId, &blockSz);
}
if (ret == 0) {
padSz = (word32)((blockSz - ((int)keySz & (blockSz - 1))) & (blockSz - 1));
padSz = (word32)((blockSz - ((int)keySz & (blockSz - 1))) &
(blockSz - 1));
/* inner = OCT salt INT itt */
innerLen = 2 + saltSz + 2 + (itt < 256 ? 1 : 2);
@@ -17309,7 +17310,7 @@ static int DecodeAltNames(const byte* input, word32 sz, DecodedCert* cert)
}
length -= (idx - lenStartIdx);
/* check that strLen at index is not past input buffer */
if (strLen + (int)idx > sz) {
if (strLen + idx > sz) {
return BUFFER_E;
}
@@ -17444,12 +17445,12 @@ static int DecodeAltNames(const byte* input, word32 sz, DecodedCert* cert)
cert->weOwnAltNames = 1;
if (length + (int)idx != sz) {
if (length + idx != sz) {
ret = ASN_PARSE_E;
}
}
while ((ret == 0) && ((int)idx < sz)) {
while ((ret == 0) && (idx < sz)) {
ASNGetData dataASN[altNameASN_Length];
/* Clear dynamic data items. */
@@ -18583,7 +18584,8 @@ static int DecodeSubtree(const byte* input, word32 sz, Base_entry** head,
return MEMORY_E;
}
entry->name = (char*)XMALLOC((word32)strLength+1, heap, DYNAMIC_TYPE_ALTNAME);
entry->name = (char*)XMALLOC((word32)strLength+1, heap,
DYNAMIC_TYPE_ALTNAME);
if (entry->name == NULL) {
WOLFSSL_MSG("allocate error");
XFREE(entry, heap, DYNAMIC_TYPE_ALTNAME);

View File

@@ -519,8 +519,8 @@ int wc_RNG_DRBG_Reseed(WC_RNG* rng, const byte* seed, word32 seedSz)
static WC_INLINE void array_add_one(byte* data, word32 dataSz)
{
word32 i;
for (i = dataSz - 1; i >= 0; i--) {
int i;
for (i = (int)dataSz - 1; i >= 0; i--) {
data[i]++;
if (data[i] != 0) break;
}
@@ -618,11 +618,11 @@ static int Hash_gen(DRBG_internal* drbg, byte* out, word32 outSz, const byte* V)
static WC_INLINE void array_add(byte* d, word32 dLen, const byte* s, word32 sLen)
{
if (dLen > 0 && sLen > 0 && dLen >= sLen) {
word32 sIdx, dIdx;
int sIdx, dIdx;
word16 carry = 0;
dIdx = dLen - 1;
for (sIdx = sLen - 1; sIdx >= 0; sIdx--) {
for (sIdx = (int)sLen - 1; sIdx >= 0; sIdx--) {
carry += (word16)d[dIdx] + (word16)s[sIdx];
d[dIdx] = (byte)carry;
carry >>= 8;

View File

@@ -39,7 +39,7 @@ enum wc_SignatureType {
WC_SIGNATURE_TYPE_NONE = 0,
WC_SIGNATURE_TYPE_ECC = 1,
WC_SIGNATURE_TYPE_RSA = 2,
WC_SIGNATURE_TYPE_RSA_W_ENC = 3 /* Adds DER header via wc_EncodeSignature */
WC_SIGNATURE_TYPE_RSA_W_ENC = 3 /* Adds DER header via wc_EncodeSignature */
};
WOLFSSL_API int wc_SignatureGetSize(enum wc_SignatureType sig_type,

View File

@@ -672,7 +672,7 @@ typedef struct sp_ecc_ctx {
unsigned int ii; \
for (ii = (a)->used - 1; ii >= 0 && (a)->dp[ii] == 0; ii--) { \
} \
(a)->used = ii + 1; \
(a)->used = (unsigned int)ii + 1; \
} while (0)
/* Check the compiled and linked math implementation are the same.