Merge pull request #689 from dgarske/fix_iar_arm

Fixes for compiler warnings with IAR EWARM 8
This commit is contained in:
toddouska
2017-01-03 15:46:12 -08:00
committed by GitHub
7 changed files with 39 additions and 32 deletions

View File

@@ -8,6 +8,7 @@
#define NO_DEV_RANDOM #define NO_DEV_RANDOM
#define USE_CERT_BUFFERS_2048 #define USE_CERT_BUFFERS_2048
#define WOLFSSL_USER_CURRTIME #define WOLFSSL_USER_CURRTIME
#define SIZEOF_LONG_LONG 8
#define CUSTOM_RAND_GENERATE custom_rand_generate #define CUSTOM_RAND_GENERATE custom_rand_generate
/* warning "write a real random seed!!!!, just for testing now" */ /* warning "write a real random seed!!!!, just for testing now" */

View File

@@ -1423,9 +1423,9 @@ int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method, void* heap)
/* In case contexts are held in array and don't want to free actual ctx */ /* In case contexts are held in array and don't want to free actual ctx */
void SSL_CtxResourceFree(WOLFSSL_CTX* ctx) void SSL_CtxResourceFree(WOLFSSL_CTX* ctx)
{ {
#ifdef HAVE_CERTIFICATE_STATUS_REQUEST_V2
int i; int i;
#endif
(void)i;
#ifdef HAVE_WOLF_EVENT #ifdef HAVE_WOLF_EVENT
wolfEventQueue_Free(&ctx->event_queue); wolfEventQueue_Free(&ctx->event_queue);
@@ -1438,14 +1438,14 @@ void SSL_CtxResourceFree(WOLFSSL_CTX* ctx)
#ifndef NO_DH #ifndef NO_DH
XFREE(ctx->serverDH_G.buffer, ctx->heap, DYNAMIC_TYPE_DH); XFREE(ctx->serverDH_G.buffer, ctx->heap, DYNAMIC_TYPE_DH);
XFREE(ctx->serverDH_P.buffer, ctx->heap, DYNAMIC_TYPE_DH); XFREE(ctx->serverDH_P.buffer, ctx->heap, DYNAMIC_TYPE_DH);
#endif #endif /* !NO_DH */
#ifdef SINGLE_THREADED #ifdef SINGLE_THREADED
if (ctx->rng) { if (ctx->rng) {
wc_FreeRng(ctx->rng); wc_FreeRng(ctx->rng);
XFREE(ctx->rng, ctx->heap, DYNAMIC_TYPE_RNG); XFREE(ctx->rng, ctx->heap, DYNAMIC_TYPE_RNG);
} }
#endif #endif /* SINGLE_THREADED */
#ifndef NO_CERTS #ifndef NO_CERTS
FreeDer(&ctx->privateKey); FreeDer(&ctx->privateKey);
@@ -1455,16 +1455,15 @@ void SSL_CtxResourceFree(WOLFSSL_CTX* ctx)
if (ctx->ourCert) { if (ctx->ourCert) {
XFREE(ctx->ourCert, ctx->heap, DYNAMIC_TYPE_X509); XFREE(ctx->ourCert, ctx->heap, DYNAMIC_TYPE_X509);
} }
#endif #endif /* KEEP_OUR_CERT */
FreeDer(&ctx->certChain); FreeDer(&ctx->certChain);
wolfSSL_CertManagerFree(ctx->cm); wolfSSL_CertManagerFree(ctx->cm);
#endif #endif /* !NO_CERTS */
#ifdef HAVE_TLS_EXTENSIONS #ifdef HAVE_TLS_EXTENSIONS
TLSX_FreeAll(ctx->extensions, ctx->heap); TLSX_FreeAll(ctx->extensions, ctx->heap);
#ifndef NO_WOLFSSL_SERVER #ifndef NO_WOLFSSL_SERVER
#if defined(HAVE_CERTIFICATE_STATUS_REQUEST) \ #if defined(HAVE_CERTIFICATE_STATUS_REQUEST) \
|| defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2) || defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2)
if (ctx->certOcspRequest) { if (ctx->certOcspRequest) {
@@ -1473,29 +1472,28 @@ void SSL_CtxResourceFree(WOLFSSL_CTX* ctx)
} }
#endif #endif
#if defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2) #ifdef HAVE_CERTIFICATE_STATUS_REQUEST_V2
for (i = 0; i < MAX_CHAIN_DEPTH; i++) { for (i = 0; i < MAX_CHAIN_DEPTH; i++) {
if (ctx->chainOcspRequest[i]) { if (ctx->chainOcspRequest[i]) {
FreeOcspRequest(ctx->chainOcspRequest[i]); FreeOcspRequest(ctx->chainOcspRequest[i]);
XFREE(ctx->chainOcspRequest[i], ctx->heap, DYNAMIC_TYPE_OCSP_REQUEST); XFREE(ctx->chainOcspRequest[i], ctx->heap, DYNAMIC_TYPE_OCSP_REQUEST);
} }
} }
#endif #endif /* HAVE_CERTIFICATE_STATUS_REQUEST_V2 */
#endif /* !NO_WOLFSSL_SERVER */
#endif /* NO_WOLFSSL_SERVER */
#endif /* HAVE_TLS_EXTENSIONS */ #endif /* HAVE_TLS_EXTENSIONS */
#ifdef WOLFSSL_STATIC_MEMORY #ifdef WOLFSSL_STATIC_MEMORY
if (ctx->heap != NULL) { if (ctx->heap != NULL) {
#ifdef WOLFSSL_HEAP_TEST #ifdef WOLFSSL_HEAP_TEST
/* avoid derefrencing a test value */ /* avoid derefrencing a test value */
if (ctx->heap != (void*)WOLFSSL_HEAP_TEST) { if (ctx->heap != (void*)WOLFSSL_HEAP_TEST)
#endif #endif
WOLFSSL_HEAP_HINT* hint = (WOLFSSL_HEAP_HINT*)(ctx->heap); {
wc_FreeMutex(&((WOLFSSL_HEAP*)(hint->memory))->memory_mutex); WOLFSSL_HEAP_HINT* hint = (WOLFSSL_HEAP_HINT*)(ctx->heap);
#ifdef WOLFSSL_HEAP_TEST wc_FreeMutex(&((WOLFSSL_HEAP*)(hint->memory))->memory_mutex);
} }
#endif
} }
#endif /* WOLFSSL_STATIC_MEMORY */ #endif /* WOLFSSL_STATIC_MEMORY */
} }

View File

@@ -19931,8 +19931,9 @@ WOLFSSL_X509* wolfSSL_get_chain_X509(WOLFSSL_X509_CHAIN* chain, int idx)
InitDecodedCert(cert, chain->certs[idx].buffer, InitDecodedCert(cert, chain->certs[idx].buffer,
chain->certs[idx].length, NULL); chain->certs[idx].length, NULL);
if ((ret = ParseCertRelative(cert, CERT_TYPE, 0, NULL)) != 0) if ((ret = ParseCertRelative(cert, CERT_TYPE, 0, NULL)) != 0) {
WOLFSSL_MSG("Failed to parse cert"); WOLFSSL_MSG("Failed to parse cert");
}
else { else {
x509 = (WOLFSSL_X509*)XMALLOC(sizeof(WOLFSSL_X509), NULL, x509 = (WOLFSSL_X509*)XMALLOC(sizeof(WOLFSSL_X509), NULL,
DYNAMIC_TYPE_X509); DYNAMIC_TYPE_X509);
@@ -20730,7 +20731,7 @@ int wolfSSL_PEM_write_bio_X509(WOLFSSL_BIO *bp, WOLFSSL_X509 *x) {
} }
#ifndef NO_DH #if defined(OPENSSL_EXTRA) && !defined(NO_DH)
/* Intialize ctx->dh with dh's params. Return SSL_SUCCESS on ok */ /* Intialize ctx->dh with dh's params. Return SSL_SUCCESS on ok */
long wolfSSL_CTX_set_tmp_dh(WOLFSSL_CTX* ctx, WOLFSSL_DH* dh) long wolfSSL_CTX_set_tmp_dh(WOLFSSL_CTX* ctx, WOLFSSL_DH* dh)
{ {
@@ -20771,7 +20772,7 @@ long wolfSSL_CTX_set_tmp_dh(WOLFSSL_CTX* ctx, WOLFSSL_DH* dh)
return pSz > 0 && gSz > 0 ? ret : SSL_FATAL_ERROR; return pSz > 0 && gSz > 0 ? ret : SSL_FATAL_ERROR;
} }
#endif /* NO_DH */ #endif /* OPENSSL_EXTRA && !NO_DH */
#endif /* HAVE_LIGHTY || HAVE_STUNNEL || WOLFSSL_MYSQL_COMPATIBLE */ #endif /* HAVE_LIGHTY || HAVE_STUNNEL || WOLFSSL_MYSQL_COMPATIBLE */

View File

@@ -3855,9 +3855,9 @@ int wc_ecc_export_x963_ex(ecc_key* key, byte* out, word32* outLen,
#ifdef HAVE_COMP_KEY #ifdef HAVE_COMP_KEY
else else
return wc_ecc_export_x963_compressed(key, out, outLen); return wc_ecc_export_x963_compressed(key, out, outLen);
#endif #else
return NOT_COMPILED_IN; return NOT_COMPILED_IN;
#endif
} }
#endif /* HAVE_ECC_KEY_EXPORT */ #endif /* HAVE_ECC_KEY_EXPORT */
@@ -5221,7 +5221,8 @@ static int add_entry(int idx, ecc_point *g)
static int build_lut(int idx, mp_int* a, mp_int* modulus, mp_digit mp, static int build_lut(int idx, mp_int* a, mp_int* modulus, mp_digit mp,
mp_int* mu) mp_int* mu)
{ {
unsigned x, y, err, bitlen, lut_gap; int err;
unsigned x, y, bitlen, lut_gap;
mp_int tmp; mp_int tmp;
if (mp_init(&tmp) != MP_OKAY) if (mp_init(&tmp) != MP_OKAY)
@@ -5367,8 +5368,8 @@ static int accel_fp_mul(int idx, mp_int* k, ecc_point *R, mp_int* a,
#else #else
unsigned char kb[KB_SIZE]; unsigned char kb[KB_SIZE];
#endif #endif
int x; int x, err;
unsigned y, z = 0, err, bitlen, bitpos, lut_gap, first; unsigned y, z = 0, bitlen, bitpos, lut_gap, first;
mp_int tk, order; mp_int tk, order;
if (mp_init_multi(&tk, &order, NULL, NULL, NULL, NULL) != MP_OKAY) if (mp_init_multi(&tk, &order, NULL, NULL, NULL, NULL) != MP_OKAY)
@@ -5516,8 +5517,8 @@ static int accel_fp_mul2add(int idx1, int idx2,
#else #else
unsigned char kb[2][KB_SIZE]; unsigned char kb[2][KB_SIZE];
#endif #endif
int x; int x, err;
unsigned y, z, err, bitlen, bitpos, lut_gap, first, zA, zB; unsigned y, z, bitlen, bitpos, lut_gap, first, zA, zB;
mp_int tka, tkb, order; mp_int tka, tkb, order;
if (mp_init_multi(&tka, &tkb, &order, NULL, NULL, NULL) != MP_OKAY) if (mp_init_multi(&tka, &tkb, &order, NULL, NULL, NULL) != MP_OKAY)

View File

@@ -812,13 +812,13 @@ int wc_HKDF(int type, const byte* inKey, word32 inKeySz,
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
#ifdef WOLFSSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
tmp = (byte*)XMALLOC(MAX_DIGEST_SIZE, myHmac.heap, DYNAMIC_TYPE_TMP_BUFFER); tmp = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (tmp == NULL) if (tmp == NULL)
return MEMORY_E; return MEMORY_E;
prk = (byte*)XMALLOC(MAX_DIGEST_SIZE, myHmac.heap, DYNAMIC_TYPE_TMP_BUFFER); prk = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (prk == NULL) { if (prk == NULL) {
XFREE(tmp, myHmac.heap, DYNAMIC_TYPE_TMP_BUFFER); XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
return MEMORY_E; return MEMORY_E;
} }
#endif #endif
@@ -870,8 +870,8 @@ int wc_HKDF(int type, const byte* inKey, word32 inKeySz,
} }
#ifdef WOLFSSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(tmp, myHmac.heap, DYNAMIC_TYPE_TMP_BUFFER); XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(prk, myHmac.heap, DYNAMIC_TYPE_TMP_BUFFER); XFREE(prk, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #endif
return ret; return ret;

View File

@@ -50,6 +50,12 @@
#else #else
#if defined(__ICCARM__)
#include <intrinsics.h>
#endif
#ifdef INTEL_INTRINSICS #ifdef INTEL_INTRINSICS
#include <stdlib.h> /* get intrinsic definitions */ #include <stdlib.h> /* get intrinsic definitions */

View File

@@ -3562,9 +3562,9 @@ static int wc_PKCS7_DecodeUnprotectedAttributes(PKCS7* pkcs7, byte* pkiMsg,
/* save attribute value bytes and size */ /* save attribute value bytes and size */
if (GetSet(pkiMsg, &idx, &length, pkiMsgSz) < 0) { if (GetSet(pkiMsg, &idx, &length, pkiMsgSz) < 0) {
return ASN_PARSE_E;
XFREE(attrib->oid, pkcs7->heap, DYNAMIC_TYPE_PKCS); XFREE(attrib->oid, pkcs7->heap, DYNAMIC_TYPE_PKCS);
XFREE(attrib, pkcs7->heap, DYNAMIC_TYPE_PKCS); XFREE(attrib, pkcs7->heap, DYNAMIC_TYPE_PKCS);
return ASN_PARSE_E;
} }
if ((pkiMsgSz - idx) < (word32)length) { if ((pkiMsgSz - idx) < (word32)length) {