diff options
author | Rich Salz <rsalz@openssl.org> | 2015-04-28 15:28:14 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-04-28 15:28:14 -0400 |
commit | b196e7d936fb377d9c5b305748ac25ff0e53ef6d (patch) | |
tree | c855f0808899e5e7ef3a704c35f464ca36014964 /crypto/asn1 | |
parent | 3e47caff4830d2a117eda15b57a5feab89b846ae (diff) |
remove malloc casts
Following ANSI C rules, remove the casts from calls to
OPENSSL_malloc and OPENSSL_realloc.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/asn1')
-rw-r--r-- | crypto/asn1/a_bitstr.c | 7 | ||||
-rw-r--r-- | crypto/asn1/a_digest.c | 2 | ||||
-rw-r--r-- | crypto/asn1/a_enum.c | 3 | ||||
-rw-r--r-- | crypto/asn1/a_i2d_fp.c | 2 | ||||
-rw-r--r-- | crypto/asn1/a_int.c | 7 | ||||
-rw-r--r-- | crypto/asn1/a_object.c | 4 | ||||
-rw-r--r-- | crypto/asn1/a_sign.c | 4 | ||||
-rw-r--r-- | crypto/asn1/asn1_lib.c | 2 | ||||
-rw-r--r-- | crypto/asn1/asn_mime.c | 4 | ||||
-rw-r--r-- | crypto/asn1/f_enum.c | 7 | ||||
-rw-r--r-- | crypto/asn1/f_int.c | 3 | ||||
-rw-r--r-- | crypto/asn1/f_string.c | 7 | ||||
-rw-r--r-- | crypto/asn1/n_pkey.c | 2 | ||||
-rw-r--r-- | crypto/asn1/t_x509.c | 2 | ||||
-rw-r--r-- | crypto/asn1/x_info.c | 2 |
15 files changed, 24 insertions, 34 deletions
diff --git a/crypto/asn1/a_bitstr.c b/crypto/asn1/a_bitstr.c index 24cdb0f66a..8a9e17cb27 100644 --- a/crypto/asn1/a_bitstr.c +++ b/crypto/asn1/a_bitstr.c @@ -156,7 +156,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, ret->flags |= (ASN1_STRING_FLAG_BITS_LEFT | i); /* set */ if (len-- > 1) { /* using one because of the bits left byte */ - s = (unsigned char *)OPENSSL_malloc((int)len); + s = OPENSSL_malloc((int)len); if (s == NULL) { i = ERR_R_MALLOC_FAILURE; goto err; @@ -206,10 +206,9 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) if (!value) return (1); /* Don't need to set */ if (a->data == NULL) - c = (unsigned char *)OPENSSL_malloc(w + 1); + c = OPENSSL_malloc(w + 1); else - c = (unsigned char *)OPENSSL_realloc_clean(a->data, - a->length, w + 1); + c = OPENSSL_realloc_clean(a->data, a->length, w + 1); if (c == NULL) { ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT, ERR_R_MALLOC_FAILURE); return 0; diff --git a/crypto/asn1/a_digest.c b/crypto/asn1/a_digest.c index 7cbc4751cd..8fac13b89e 100644 --- a/crypto/asn1/a_digest.c +++ b/crypto/asn1/a_digest.c @@ -79,7 +79,7 @@ int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data, unsigned char *str, *p; i = i2d(data, NULL); - if ((str = (unsigned char *)OPENSSL_malloc(i)) == NULL) { + if ((str = OPENSSL_malloc(i)) == NULL) { ASN1err(ASN1_F_ASN1_DIGEST, ERR_R_MALLOC_FAILURE); return (0); } diff --git a/crypto/asn1/a_enum.c b/crypto/asn1/a_enum.c index 00312b072d..54d6542cbe 100644 --- a/crypto/asn1/a_enum.c +++ b/crypto/asn1/a_enum.c @@ -77,8 +77,7 @@ int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v) if (a->length < (int)(sizeof(long) + 1)) { if (a->data != NULL) OPENSSL_free(a->data); - if ((a->data = - (unsigned char *)OPENSSL_malloc(sizeof(long) + 1)) != NULL) + if ((a->data = OPENSSL_malloc(sizeof(long) + 1)) != NULL) memset((char *)a->data, 0, sizeof(long) + 1); } if (a->data == NULL) { diff --git a/crypto/asn1/a_i2d_fp.c b/crypto/asn1/a_i2d_fp.c index 746e34a856..e0f236e640 100644 --- a/crypto/asn1/a_i2d_fp.c +++ b/crypto/asn1/a_i2d_fp.c @@ -87,7 +87,7 @@ int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x) int i, j = 0, n, ret = 1; n = i2d(x, NULL); - b = (char *)OPENSSL_malloc(n); + b = OPENSSL_malloc(n); if (b == NULL) { ASN1err(ASN1_F_ASN1_I2D_BIO, ERR_R_MALLOC_FAILURE); return (0); diff --git a/crypto/asn1/a_int.c b/crypto/asn1/a_int.c index 3920d5ce96..b5246a65c3 100644 --- a/crypto/asn1/a_int.c +++ b/crypto/asn1/a_int.c @@ -206,7 +206,7 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, * We must OPENSSL_malloc stuff, even for 0 bytes otherwise it signifies * a missing NULL parameter. */ - s = (unsigned char *)OPENSSL_malloc((int)len + 1); + s = OPENSSL_malloc((int)len + 1); if (s == NULL) { i = ERR_R_MALLOC_FAILURE; goto err; @@ -312,7 +312,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, * We must OPENSSL_malloc stuff, even for 0 bytes otherwise it signifies * a missing NULL parameter. */ - s = (unsigned char *)OPENSSL_malloc((int)len + 1); + s = OPENSSL_malloc((int)len + 1); if (s == NULL) { i = ERR_R_MALLOC_FAILURE; goto err; @@ -351,8 +351,7 @@ int ASN1_INTEGER_set(ASN1_INTEGER *a, long v) if (a->length < (int)(sizeof(long) + 1)) { if (a->data != NULL) OPENSSL_free(a->data); - if ((a->data = - (unsigned char *)OPENSSL_malloc(sizeof(long) + 1)) != NULL) + if ((a->data = OPENSSL_malloc(sizeof(long) + 1)) != NULL) memset((char *)a->data, 0, sizeof(long) + 1); } if (a->data == NULL) { diff --git a/crypto/asn1/a_object.c b/crypto/asn1/a_object.c index 845413cffa..166eb65a48 100644 --- a/crypto/asn1/a_object.c +++ b/crypto/asn1/a_object.c @@ -317,7 +317,7 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, ret->length = 0; if (data != NULL) OPENSSL_free(data); - data = (unsigned char *)OPENSSL_malloc(length); + data = OPENSSL_malloc(length); if (data == NULL) { i = ERR_R_MALLOC_FAILURE; goto err; @@ -348,7 +348,7 @@ ASN1_OBJECT *ASN1_OBJECT_new(void) { ASN1_OBJECT *ret; - ret = (ASN1_OBJECT *)OPENSSL_malloc(sizeof(ASN1_OBJECT)); + ret = OPENSSL_malloc(sizeof(ASN1_OBJECT)); if (ret == NULL) { ASN1err(ASN1_F_ASN1_OBJECT_NEW, ERR_R_MALLOC_FAILURE); return (NULL); diff --git a/crypto/asn1/a_sign.c b/crypto/asn1/a_sign.c index 9fe6665fbc..21cbe0c347 100644 --- a/crypto/asn1/a_sign.c +++ b/crypto/asn1/a_sign.c @@ -171,9 +171,9 @@ int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, X509_ALGOR *algor2, } } inl = i2d(data, NULL); - buf_in = (unsigned char *)OPENSSL_malloc((unsigned int)inl); + buf_in = OPENSSL_malloc((unsigned int)inl); outll = outl = EVP_PKEY_size(pkey); - buf_out = (unsigned char *)OPENSSL_malloc((unsigned int)outl); + buf_out = OPENSSL_malloc((unsigned int)outl); if ((buf_in == NULL) || (buf_out == NULL)) { outl = 0; ASN1err(ASN1_F_ASN1_SIGN, ERR_R_MALLOC_FAILURE); diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c index b29e636358..97f1d23da8 100644 --- a/crypto/asn1/asn1_lib.c +++ b/crypto/asn1/asn1_lib.c @@ -354,7 +354,7 @@ ASN1_STRING *ASN1_STRING_type_new(int type) { ASN1_STRING *ret; - ret = (ASN1_STRING *)OPENSSL_malloc(sizeof(ASN1_STRING)); + ret = OPENSSL_malloc(sizeof(ASN1_STRING)); if (ret == NULL) { ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE); return (NULL); diff --git a/crypto/asn1/asn_mime.c b/crypto/asn1/asn_mime.c index e810345579..9b397aeaa0 100644 --- a/crypto/asn1/asn_mime.c +++ b/crypto/asn1/asn_mime.c @@ -844,7 +844,7 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value) } } } - mhdr = (MIME_HEADER *)OPENSSL_malloc(sizeof(MIME_HEADER)); + mhdr = OPENSSL_malloc(sizeof(MIME_HEADER)); if (!mhdr) goto err; mhdr->name = tmpname; @@ -886,7 +886,7 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value) goto err; } /* Parameter values are case sensitive so leave as is */ - mparam = (MIME_PARAM *)OPENSSL_malloc(sizeof(MIME_PARAM)); + mparam = OPENSSL_malloc(sizeof(MIME_PARAM)); if (!mparam) goto err; mparam->param_name = tmpname; diff --git a/crypto/asn1/f_enum.c b/crypto/asn1/f_enum.c index 591c3b5781..c623cdc784 100644 --- a/crypto/asn1/f_enum.c +++ b/crypto/asn1/f_enum.c @@ -152,12 +152,9 @@ int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size) i /= 2; if (num + i > slen) { if (s == NULL) - sp = (unsigned char *)OPENSSL_malloc((unsigned int)num + - i * 2); + sp = OPENSSL_malloc((unsigned int)num + i * 2); else - sp = (unsigned char *)OPENSSL_realloc(s, - (unsigned int)num + - i * 2); + sp = OPENSSL_realloc(s, (unsigned int)num + i * 2); if (sp == NULL) { ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE); if (s != NULL) diff --git a/crypto/asn1/f_int.c b/crypto/asn1/f_int.c index 4a81f81c88..39c9a61e59 100644 --- a/crypto/asn1/f_int.c +++ b/crypto/asn1/f_int.c @@ -166,8 +166,7 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size) i /= 2; if (num + i > slen) { if (s == NULL) - sp = (unsigned char *)OPENSSL_malloc((unsigned int)num + - i * 2); + sp = OPENSSL_malloc((unsigned int)num + i * 2); else sp = OPENSSL_realloc_clean(s, slen, num + i * 2); if (sp == NULL) { diff --git a/crypto/asn1/f_string.c b/crypto/asn1/f_string.c index 6a6cf34714..6cb4cfdff9 100644 --- a/crypto/asn1/f_string.c +++ b/crypto/asn1/f_string.c @@ -158,12 +158,9 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size) i /= 2; if (num + i > slen) { if (s == NULL) - sp = (unsigned char *)OPENSSL_malloc((unsigned int)num + - i * 2); + sp = OPENSSL_malloc((unsigned int)num + i * 2); else - sp = (unsigned char *)OPENSSL_realloc(s, - (unsigned int)num + - i * 2); + sp = OPENSSL_realloc(s, (unsigned int)num + i * 2); if (sp == NULL) { ASN1err(ASN1_F_A2I_ASN1_STRING, ERR_R_MALLOC_FAILURE); if (s != NULL) diff --git a/crypto/asn1/n_pkey.c b/crypto/asn1/n_pkey.c index cd6391e941..0d8480b8dd 100644 --- a/crypto/asn1/n_pkey.c +++ b/crypto/asn1/n_pkey.c @@ -167,7 +167,7 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp, } /* Since its RC4 encrypted length is actual length */ - if ((zz = (unsigned char *)OPENSSL_malloc(rsalen)) == NULL) { + if ((zz = OPENSSL_malloc(rsalen)) == NULL) { ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE); goto err; } diff --git a/crypto/asn1/t_x509.c b/crypto/asn1/t_x509.c index e97222021f..da73b6dfc8 100644 --- a/crypto/asn1/t_x509.c +++ b/crypto/asn1/t_x509.c @@ -268,7 +268,7 @@ int X509_ocspid_print(BIO *bp, X509 *x) if (BIO_printf(bp, " Subject OCSP hash: ") <= 0) goto err; derlen = i2d_X509_NAME(x->cert_info->subject, NULL); - if ((der = dertmp = (unsigned char *)OPENSSL_malloc(derlen)) == NULL) + if ((der = dertmp = OPENSSL_malloc(derlen)) == NULL) goto err; i2d_X509_NAME(x->cert_info->subject, &dertmp); diff --git a/crypto/asn1/x_info.c b/crypto/asn1/x_info.c index a847277b49..fff54c808e 100644 --- a/crypto/asn1/x_info.c +++ b/crypto/asn1/x_info.c @@ -66,7 +66,7 @@ X509_INFO *X509_INFO_new(void) { X509_INFO *ret = NULL; - ret = (X509_INFO *)OPENSSL_malloc(sizeof(X509_INFO)); + ret = OPENSSL_malloc(sizeof(X509_INFO)); if (ret == NULL) { ASN1err(ASN1_F_X509_INFO_NEW, ERR_R_MALLOC_FAILURE); return (NULL); |