add explicit casts to XMALLOC()s, even for (void *), to avoid warnings in C++ and MSVC/MSVS builds, and to avoid false positives on simple text searches.

This commit is contained in:
Daniel Pouzzner
2020-12-02 13:32:48 -06:00
parent f47cdfcaed
commit f277339528
8 changed files with 10 additions and 10 deletions

View File

@ -351,7 +351,7 @@ static word32 GetEntropy(unsigned char* out, word32 num_bytes)
static void* myAlloc(void* opaque, unsigned int item, unsigned int size)
{
(void)opaque;
return XMALLOC(item * size, opaque, DYNAMIC_TYPE_LIBZ);
return (void *)XMALLOC(item * size, opaque, DYNAMIC_TYPE_LIBZ);
}
@ -6052,7 +6052,7 @@ int AllocKey(WOLFSSL* ssl, int type, void** pKey)
}
/* Allocate memory for key */
*pKey = XMALLOC(sz, ssl->heap, type);
*pKey = (void *)XMALLOC(sz, ssl->heap, type);
if (*pKey == NULL) {
return MEMORY_E;
}

View File

@ -29045,7 +29045,7 @@ void *wolfSSL_ASN1_item_new(const WOLFSSL_ASN1_ITEM *tpl)
if (!tpl) {
return NULL;
}
if (!(ret = XMALLOC(tpl->size, NULL, DYNAMIC_TYPE_OPENSSL))) {
if (!(ret = (void *)XMALLOC(tpl->size, NULL, DYNAMIC_TYPE_OPENSSL))) {
return NULL;
}
XMEMSET(ret, 0, tpl->size);
@ -31817,7 +31817,7 @@ void wolfSSL_OPENSSL_free(void* p)
void *wolfSSL_OPENSSL_malloc(size_t a)
{
return XMALLOC(a, NULL, DYNAMIC_TYPE_OPENSSL);
return (void *)XMALLOC(a, NULL, DYNAMIC_TYPE_OPENSSL);
}
int wolfSSL_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)

View File

@ -2091,7 +2091,7 @@ void* mynewt_ctx_new() {
if(!mynewt_ctx) return NULL;
XMEMSET(mynewt_ctx, 0, sizeof(Mynewt_Ctx));
mynewt_ctx->mnMemBuffer = XMALLOC(mempool_bytes, 0, 0);
mynewt_ctx->mnMemBuffer = (void *)XMALLOC(mempool_bytes, 0, 0);
if(!mynewt_ctx->mnMemBuffer) {
mynewt_ctx_clear((void*)mynewt_ctx);
return NULL;

View File

@ -1193,7 +1193,7 @@ int wc_BerToDer(const byte* ber, word32 berSz, byte* der, word32* derSz)
return BAD_FUNC_ARG;
#ifdef WOLFSSL_SMALL_STACK
indefItems = XMALLOC(sizeof(IndefItems), NULL, DYNAMIC_TYPE_TMP_BUFFER);
indefItems = (IndefItems *)XMALLOC(sizeof(IndefItems), NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (indefItems == NULL) {
ret = MEMORY_E;
goto end;

View File

@ -360,7 +360,7 @@ static WC_INLINE int wc_XChaCha20Poly1305_crypt_oneshot(
byte *dst_i;
size_t src_len_rem;
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
ChaChaPoly_Aead *aead = XMALLOC(sizeof *aead, NULL, DYNAMIC_TYPE_TMP_BUFFER);
ChaChaPoly_Aead *aead = (ChaChaPoly_Aead *)XMALLOC(sizeof *aead, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (aead == NULL)
return MEMORY_E;

View File

@ -47,7 +47,7 @@
static void* myAlloc(void* opaque, unsigned int item, unsigned int size)
{
(void)opaque;
return XMALLOC(item * size, opaque, DYNAMIC_TYPE_LIBZ);
return (void *)XMALLOC(item * size, opaque, DYNAMIC_TYPE_LIBZ);
}

View File

@ -2476,7 +2476,7 @@ static int Pkcs11ECDSA_Verify(Pkcs11Session* session, wc_CryptoInfo* info)
}
if (ret == 0) {
sig = XMALLOC(sz * 2, info->pk.eccverify.key->heap,
sig = (unsigned char *)XMALLOC(sz * 2, info->pk.eccverify.key->heap,
DYNAMIC_TYPE_TMP_BUFFER);
if (sig == NULL)
ret = MEMORY_E;

View File

@ -700,7 +700,7 @@ XFILE z_fs_open(const char* filename, const char* perm)
{
XFILE file;
file = XMALLOC(sizeof(*file), NULL, DYNAMIC_TYPE_FILE);
file = (XFILE)XMALLOC(sizeof(*file), NULL, DYNAMIC_TYPE_FILE);
if (file != NULL) {
if (fs_open(file, filename) != 0) {
XFREE(file, NULL, DYNAMIC_TYPE_FILE);