[openssl-commits] [openssl] master update

Rich Salz rsalz at openssl.org
Tue Apr 28 19:28:35 UTC 2015


The branch master has been updated
       via  b196e7d936fb377d9c5b305748ac25ff0e53ef6d (commit)
      from  3e47caff4830d2a117eda15b57a5feab89b846ae (commit)


- Log -----------------------------------------------------------------
commit b196e7d936fb377d9c5b305748ac25ff0e53ef6d
Author: Rich Salz <rsalz at openssl.org>
Date:   Tue Apr 28 15:28:14 2015 -0400

    remove malloc casts
    
    Following ANSI C rules, remove the casts from calls to
    OPENSSL_malloc and OPENSSL_realloc.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 apps/apps.c                   |  7 +++----
 apps/ca.c                     | 21 +++++++++------------
 apps/dgst.c                   |  2 +-
 apps/dhparam.c                |  2 +-
 apps/dsaparam.c               |  2 +-
 apps/ecparam.c                |  3 +--
 apps/enc.c                    |  2 +-
 apps/rsa.c                    |  2 +-
 apps/s_client.c               |  2 +-
 apps/s_server.c               |  4 ++--
 apps/s_socket.c               |  2 +-
 apps/speed.c                  |  6 ++----
 apps/srp.c                    |  3 +--
 apps/vms_decc_init.c          |  2 +-
 crypto/asn1/a_bitstr.c        |  7 +++----
 crypto/asn1/a_digest.c        |  2 +-
 crypto/asn1/a_enum.c          |  3 +--
 crypto/asn1/a_i2d_fp.c        |  2 +-
 crypto/asn1/a_int.c           |  7 +++----
 crypto/asn1/a_object.c        |  4 ++--
 crypto/asn1/a_sign.c          |  4 ++--
 crypto/asn1/asn1_lib.c        |  2 +-
 crypto/asn1/asn_mime.c        |  4 ++--
 crypto/asn1/f_enum.c          |  7 ++-----
 crypto/asn1/f_int.c           |  3 +--
 crypto/asn1/f_string.c        |  7 ++-----
 crypto/asn1/n_pkey.c          |  2 +-
 crypto/asn1/t_x509.c          |  2 +-
 crypto/asn1/x_info.c          |  2 +-
 crypto/bio/bf_buff.c          | 10 +++++-----
 crypto/bio/bf_lbuf.c          |  6 +++---
 crypto/bio/bf_nbio.c          |  2 +-
 crypto/bio/bio_lib.c          |  2 +-
 crypto/bio/bss_acpt.c         |  2 +-
 crypto/bio/bss_conn.c         |  2 +-
 crypto/bio/bss_log.c          |  2 +-
 crypto/bn/bn_blind.c          |  2 +-
 crypto/bn/bn_exp.c            |  3 +--
 crypto/bn/bn_gf2m.c           | 10 +++++-----
 crypto/bn/bn_lib.c            |  6 +++---
 crypto/bn/bn_mont.c           |  2 +-
 crypto/bn/bn_print.c          |  7 +++----
 crypto/bn/bn_rand.c           |  2 +-
 crypto/bn/bn_recp.c           |  2 +-
 crypto/comp/c_zlib.c          |  3 +--
 crypto/comp/comp_lib.c        |  2 +-
 crypto/conf/conf_def.c        |  6 +++---
 crypto/dh/dh_lib.c            |  3 +--
 crypto/dsa/dsa_ameth.c        |  2 +-
 crypto/dsa/dsa_lib.c          |  2 +-
 crypto/dso/dso_lib.c          |  5 +++--
 crypto/dso/dso_win32.c        |  2 +-
 crypto/ec/ec_ameth.c          |  2 +-
 crypto/ec/ec_key.c            |  2 +-
 crypto/ec/ec_mult.c           |  2 +-
 crypto/ec/ec_print.c          |  2 +-
 crypto/ec/ecp_nistp224.c      |  2 +-
 crypto/ec/ecp_nistp256.c      |  2 +-
 crypto/ec/ecp_nistp521.c      |  2 +-
 crypto/ec/ecp_nistz256.c      |  2 +-
 crypto/ecdh/ech_lib.c         |  2 +-
 crypto/ecdsa/ecs_lib.c        |  2 +-
 crypto/engine/eng_cryptodev.c |  2 +-
 crypto/engine/eng_lib.c       |  2 +-
 crypto/err/err.c              |  2 +-
 crypto/evp/bio_b64.c          |  2 +-
 crypto/evp/bio_enc.c          |  2 +-
 crypto/evp/bio_ok.c           |  2 +-
 crypto/evp/evp_pbe.c          |  2 +-
 crypto/evp/p_lib.c            |  2 +-
 crypto/evp/p_open.c           |  2 +-
 crypto/ex_data.c              |  3 +--
 crypto/lhash/lhash.c          | 15 ++++++---------
 crypto/lock.c                 |  2 +-
 crypto/mem.c                  |  2 +-
 crypto/mem_dbg.c              |  4 ++--
 crypto/modes/gcm128.c         |  2 +-
 crypto/modes/ocb128.c         |  2 +-
 crypto/objects/o_names.c      |  2 +-
 crypto/objects/obj_dat.c      | 14 ++++++--------
 crypto/pem/pem_lib.c          |  2 +-
 crypto/pem/pem_seal.c         |  4 ++--
 crypto/pem/pem_sign.c         |  2 +-
 crypto/pqueue/pqueue.c        |  4 ++--
 crypto/rsa/rsa_ameth.c        |  2 +-
 crypto/rsa/rsa_lib.c          |  2 +-
 crypto/rsa/rsa_saos.c         |  4 ++--
 crypto/rsa/rsa_sign.c         |  4 ++--
 crypto/srp/srp_vfy.c          |  7 +++----
 crypto/stack/stack.c          |  5 ++---
 crypto/store/str_lib.c        |  4 ++--
 crypto/store/str_mem.c        |  3 +--
 crypto/store/str_meth.c       |  3 +--
 crypto/ts/ts_rsp_sign.c       |  4 ++--
 crypto/ts/ts_verify_ctx.c     |  4 ++--
 crypto/ui/ui_lib.c            |  9 ++++-----
 crypto/x509/by_dir.c          |  2 +-
 crypto/x509/x509_lu.c         |  8 ++++----
 crypto/x509/x509_req.c        |  2 +-
 crypto/x509/x509_vfy.c        |  3 ++-
 crypto/x509v3/v3_lib.c        |  4 +---
 crypto/x509v3/v3_utl.c        |  2 +-
 demos/b64.c                   |  2 +-
 engines/ccgost/gost_crypt.c   |  2 +-
 engines/e_cswift.c            |  2 +-
 ssl/bio_ssl.c                 |  2 +-
 ssl/d1_both.c                 |  7 +++----
 ssl/ssl_cert.c                |  4 ++--
 ssl/ssl_ciph.c                |  7 +++----
 ssl/ssl_lib.c                 |  4 ++--
 ssl/ssl_sess.c                |  4 ++--
 ssl/t1_enc.c                  |  4 ++--
 test/dhtest.c                 |  4 ++--
 test/ecdhtest.c               |  4 ++--
 114 files changed, 191 insertions(+), 226 deletions(-)

diff --git a/apps/apps.c b/apps/apps.c
index 462e2b6..66e3796 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -180,7 +180,7 @@ int chopup_args(ARGS *arg, char *buf)
     arg->argc = 0;
     if (arg->size == 0) {
         arg->size = 20;
-        arg->argv = (char **)OPENSSL_malloc(sizeof(char *) * arg->size);
+        arg->argv = OPENSSL_malloc(sizeof(char *) * arg->size);
         if (arg->argv == NULL)
             return 0;
     }
@@ -195,8 +195,7 @@ int chopup_args(ARGS *arg, char *buf)
         /* The start of something good :-) */
         if (arg->argc >= arg->size) {
             arg->size += 20;
-            arg->argv = (char **)OPENSSL_realloc(arg->argv,
-                                                 sizeof(char *) * arg->size);
+            arg->argv = OPENSSL_realloc(arg->argv, sizeof(char *) * arg->size);
             if (arg->argv == NULL)
                 return 0;
         }
@@ -368,7 +367,7 @@ int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_tmp)
             ok = UI_add_input_string(ui, prompt, ui_flags, buf,
                                      PW_MIN_LENGTH, bufsiz - 1);
         if (ok >= 0 && verify) {
-            buff = (char *)OPENSSL_malloc(bufsiz);
+            buff = OPENSSL_malloc(bufsiz);
             if (!buff) {
                 BIO_printf(bio_err, "Out of memory\n");
                 UI_free(ui);
diff --git a/apps/ca.c b/apps/ca.c
index 218a407..ac720db 100644
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -1986,17 +1986,17 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
         goto end;
 
     /* We now just add it to the database */
-    row[DB_type] = (char *)OPENSSL_malloc(2);
+    row[DB_type] = OPENSSL_malloc(2);
 
     tm = X509_get_notAfter(ret);
-    row[DB_exp_date] = (char *)OPENSSL_malloc(tm->length + 1);
+    row[DB_exp_date] = OPENSSL_malloc(tm->length + 1);
     memcpy(row[DB_exp_date], tm->data, tm->length);
     row[DB_exp_date][tm->length] = '\0';
 
     row[DB_rev_date] = NULL;
 
     /* row[DB_serial] done already */
-    row[DB_file] = (char *)OPENSSL_malloc(8);
+    row[DB_file] = OPENSSL_malloc(8);
     row[DB_name] = X509_NAME_oneline(X509_get_subject_name(ret), NULL, 0);
 
     if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
@@ -2008,8 +2008,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
     row[DB_type][0] = 'V';
     row[DB_type][1] = '\0';
 
-    if ((irow =
-         (char **)OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) {
+    if ((irow = OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) {
         BIO_printf(bio_err, "Memory allocation failure\n");
         goto end;
     }
@@ -2242,17 +2241,17 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
                    row[DB_serial], row[DB_name]);
 
         /* We now just add it to the database */
-        row[DB_type] = (char *)OPENSSL_malloc(2);
+        row[DB_type] = OPENSSL_malloc(2);
 
         tm = X509_get_notAfter(x509);
-        row[DB_exp_date] = (char *)OPENSSL_malloc(tm->length + 1);
+        row[DB_exp_date] = OPENSSL_malloc(tm->length + 1);
         memcpy(row[DB_exp_date], tm->data, tm->length);
         row[DB_exp_date][tm->length] = '\0';
 
         row[DB_rev_date] = NULL;
 
         /* row[DB_serial] done already */
-        row[DB_file] = (char *)OPENSSL_malloc(8);
+        row[DB_file] = OPENSSL_malloc(8);
 
         /* row[DB_name] done already */
 
@@ -2265,9 +2264,7 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
         row[DB_type][0] = 'V';
         row[DB_type][1] = '\0';
 
-        if ((irow =
-             (char **)OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) ==
-            NULL) {
+        if ((irow = OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) {
             BIO_printf(bio_err, "Memory allocation failure\n");
             goto end;
         }
@@ -2406,7 +2403,7 @@ static int do_updatedb(CA_DB *db)
 
     /* get actual time and make a string */
     a_tm = X509_gmtime_adj(a_tm, 0);
-    a_tm_s = (char *)OPENSSL_malloc(a_tm->length + 1);
+    a_tm_s = OPENSSL_malloc(a_tm->length + 1);
     if (a_tm_s == NULL) {
         cnt = -1;
         goto end;
diff --git a/apps/dgst.c b/apps/dgst.c
index adfa2a6..106e939 100644
--- a/apps/dgst.c
+++ b/apps/dgst.c
@@ -139,7 +139,7 @@ int dgst_main(int argc, char **argv)
     int engine_impl = 0;
 
     prog = opt_progname(argv[0]);
-    if ((buf = (unsigned char *)OPENSSL_malloc(BUFSIZE)) == NULL) {
+    if ((buf = OPENSSL_malloc(BUFSIZE)) == NULL) {
         BIO_printf(bio_err, "%s: out of memory\n", prog);
         goto end;
     }
diff --git a/apps/dhparam.c b/apps/dhparam.c
index 6e51c0b..e7fa7ae 100644
--- a/apps/dhparam.c
+++ b/apps/dhparam.c
@@ -379,7 +379,7 @@ int dhparam_main(int argc, char **argv)
 
         len = BN_num_bytes(dh->p);
         bits = BN_num_bits(dh->p);
-        data = (unsigned char *)OPENSSL_malloc(len);
+        data = OPENSSL_malloc(len);
         if (data == NULL) {
             perror("OPENSSL_malloc");
             goto end;
diff --git a/apps/dsaparam.c b/apps/dsaparam.c
index f7365b9..5aa6e2c 100644
--- a/apps/dsaparam.c
+++ b/apps/dsaparam.c
@@ -273,7 +273,7 @@ int dsaparam_main(int argc, char **argv)
 
         len = BN_num_bytes(dsa->p);
         bits_p = BN_num_bits(dsa->p);
-        data = (unsigned char *)OPENSSL_malloc(len + 20);
+        data = OPENSSL_malloc(len + 20);
         if (data == NULL) {
             perror("OPENSSL_malloc");
             goto end;
diff --git a/apps/ecparam.c b/apps/ecparam.c
index 049fc78..f316793 100644
--- a/apps/ecparam.c
+++ b/apps/ecparam.c
@@ -388,8 +388,7 @@ int ecparam_main(int argc, char **argv)
         if ((tmp_len = (size_t)BN_num_bytes(ec_cofactor)) > buf_len)
             buf_len = tmp_len;
 
-        buffer = (unsigned char *)OPENSSL_malloc(buf_len);
-
+        buffer = OPENSSL_malloc(buf_len);
         if (buffer == NULL) {
             perror("OPENSSL_malloc");
             goto end;
diff --git a/apps/enc.c b/apps/enc.c
index 61a64d4..794fce1 100644
--- a/apps/enc.c
+++ b/apps/enc.c
@@ -314,7 +314,7 @@ int enc_main(int argc, char **argv)
         BIO_printf(bio_err, "bufsize=%d\n", bsize);
 
     strbuf = OPENSSL_malloc(SIZE);
-    buff = (unsigned char *)OPENSSL_malloc(EVP_ENCODE_LENGTH(bsize));
+    buff = OPENSSL_malloc(EVP_ENCODE_LENGTH(bsize));
     if ((buff == NULL) || (strbuf == NULL)) {
         BIO_printf(bio_err, "OPENSSL_malloc failure %ld\n",
                    (long)EVP_ENCODE_LENGTH(bsize));
diff --git a/apps/rsa.c b/apps/rsa.c
index 8e93dd2..c8b05e6 100644
--- a/apps/rsa.c
+++ b/apps/rsa.c
@@ -349,7 +349,7 @@ int rsa_main(int argc, char **argv)
 
         i = 1;
         size = i2d_RSA_NET(rsa, NULL, NULL, 0);
-        if ((p = (unsigned char *)OPENSSL_malloc(size)) == NULL) {
+        if ((p = OPENSSL_malloc(size)) == NULL) {
             BIO_printf(bio_err, "Memory allocation failure\n");
             goto end;
         }
diff --git a/apps/s_client.c b/apps/s_client.c
index 431a106..9181c75 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -385,7 +385,7 @@ static int ssl_srp_verify_param_cb(SSL *s, void *arg)
 static char *ssl_give_srp_client_pwd_cb(SSL *s, void *arg)
 {
     SRP_ARG *srp_arg = (SRP_ARG *)arg;
-    char *pass = (char *)OPENSSL_malloc(PWD_STRLEN + 1);
+    char *pass = OPENSSL_malloc(PWD_STRLEN + 1);
     PW_CB_DATA cb_tmp;
     int l;
 
diff --git a/apps/s_server.c b/apps/s_server.c
index e12db0c..fb6fd3d 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -461,7 +461,7 @@ static int ebcdic_new(BIO *bi)
 {
     EBCDIC_OUTBUFF *wbuf;
 
-    wbuf = (EBCDIC_OUTBUFF *) OPENSSL_malloc(sizeof(EBCDIC_OUTBUFF) + 1024);
+    wbuf = OPENSSL_malloc(sizeof(EBCDIC_OUTBUFF) + 1024);
     if (!wbuf)
         return 0;
     wbuf->alloced = 1024;
@@ -518,7 +518,7 @@ static int ebcdic_write(BIO *b, const char *in, int inl)
         num = num + num;        /* double the size */
         if (num < inl)
             num = inl;
-        wbuf = (EBCDIC_OUTBUFF *) OPENSSL_malloc(sizeof(EBCDIC_OUTBUFF) + num);
+        wbuf = OPENSSL_malloc(sizeof(EBCDIC_OUTBUFF) + num);
         if (!wbuf)
             return 0;
         OPENSSL_free(b->ptr);
diff --git a/apps/s_socket.c b/apps/s_socket.c
index 4c440dc..050426a 100644
--- a/apps/s_socket.c
+++ b/apps/s_socket.c
@@ -562,7 +562,7 @@ static int do_accept(int acc_sock, int *sock, char **host)
         *host = NULL;
         /* return(0); */
     } else {
-        if ((*host = (char *)OPENSSL_malloc(strlen(h1->h_name) + 1)) == NULL) {
+        if ((*host = OPENSSL_malloc(strlen(h1->h_name) + 1)) == NULL) {
             perror("OPENSSL_malloc");
             closesocket(ret);
             return (0);
diff --git a/apps/speed.c b/apps/speed.c
index 5758705..7dfdda8 100644
--- a/apps/speed.c
+++ b/apps/speed.c
@@ -791,13 +791,11 @@ int speed_main(int argc, char **argv)
         ecdh_doit[i] = 0;
 #endif
 
-    if ((buf_malloc =
-         (unsigned char *)OPENSSL_malloc((int)BUFSIZE + misalign)) == NULL) {
+    if ((buf_malloc = OPENSSL_malloc((int)BUFSIZE + misalign)) == NULL) {
         BIO_printf(bio_err, "out of memory\n");
         goto end;
     }
-    if ((buf2_malloc =
-         (unsigned char *)OPENSSL_malloc((int)BUFSIZE + misalign)) == NULL) {
+    if ((buf2_malloc = OPENSSL_malloc((int)BUFSIZE + misalign)) == NULL) {
         BIO_printf(bio_err, "out of memory\n");
         goto end;
     }
diff --git a/apps/srp.c b/apps/srp.c
index c62d55d..0acbb8a 100644
--- a/apps/srp.c
+++ b/apps/srp.c
@@ -138,8 +138,7 @@ static int update_index(CA_DB *db, BIO *bio, char **row)
     char **irow;
     int i;
 
-    if ((irow =
-         (char **)OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) {
+    if ((irow = OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) {
         BIO_printf(bio_err, "Memory allocation failure\n");
         return 0;
     }
diff --git a/apps/vms_decc_init.c b/apps/vms_decc_init.c
index 3c953aa..1717dae 100644
--- a/apps/vms_decc_init.c
+++ b/apps/vms_decc_init.c
@@ -130,7 +130,7 @@ char **copy_argv(int *argc, char *argv[])
      */
 
     int i, count = *argc;
-    char **newargv = (char **)OPENSSL_malloc((count + 1) * sizeof *newargv);
+    char **newargv = OPENSSL_malloc((count + 1) * sizeof *newargv);
 
     for (i = 0; i < count; i++)
         newargv[i] = argv[i];
diff --git a/crypto/asn1/a_bitstr.c b/crypto/asn1/a_bitstr.c
index 24cdb0f..8a9e17c 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 7cbc475..8fac13b 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 00312b0..54d6542 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 746e34a..e0f236e 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 3920d5c..b5246a6 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 845413c..166eb65 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 9fe6665..21cbe0c 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 b29e636..97f1d23 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 e810345..9b397ae 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 591c3b5..c623cdc 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 4a81f81..39c9a61 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 6a6cf34..6cb4cfd 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 cd6391e..0d8480b 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 e972220..da73b6d 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 a847277..fff54c8 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);
diff --git a/crypto/bio/bf_buff.c b/crypto/bio/bf_buff.c
index 0e998d6..d82385a 100644
--- a/crypto/bio/bf_buff.c
+++ b/crypto/bio/bf_buff.c
@@ -93,15 +93,15 @@ static int buffer_new(BIO *bi)
 {
     BIO_F_BUFFER_CTX *ctx;
 
-    ctx = (BIO_F_BUFFER_CTX *)OPENSSL_malloc(sizeof(BIO_F_BUFFER_CTX));
+    ctx = OPENSSL_malloc(sizeof(BIO_F_BUFFER_CTX));
     if (ctx == NULL)
         return (0);
-    ctx->ibuf = (char *)OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
+    ctx->ibuf = OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
     if (ctx->ibuf == NULL) {
         OPENSSL_free(ctx);
         return (0);
     }
-    ctx->obuf = (char *)OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
+    ctx->obuf = OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
     if (ctx->obuf == NULL) {
         OPENSSL_free(ctx->ibuf);
         OPENSSL_free(ctx);
@@ -366,12 +366,12 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
         p1 = ctx->ibuf;
         p2 = ctx->obuf;
         if ((ibs > DEFAULT_BUFFER_SIZE) && (ibs != ctx->ibuf_size)) {
-            p1 = (char *)OPENSSL_malloc((int)num);
+            p1 = OPENSSL_malloc((int)num);
             if (p1 == NULL)
                 goto malloc_error;
         }
         if ((obs > DEFAULT_BUFFER_SIZE) && (obs != ctx->obuf_size)) {
-            p2 = (char *)OPENSSL_malloc((int)num);
+            p2 = OPENSSL_malloc((int)num);
             if (p2 == NULL) {
                 if (p1 != ctx->ibuf)
                     OPENSSL_free(p1);
diff --git a/crypto/bio/bf_lbuf.c b/crypto/bio/bf_lbuf.c
index 3b75b7e..ef12820 100644
--- a/crypto/bio/bf_lbuf.c
+++ b/crypto/bio/bf_lbuf.c
@@ -104,10 +104,10 @@ static int linebuffer_new(BIO *bi)
 {
     BIO_LINEBUFFER_CTX *ctx;
 
-    ctx = (BIO_LINEBUFFER_CTX *)OPENSSL_malloc(sizeof(BIO_LINEBUFFER_CTX));
+    ctx = OPENSSL_malloc(sizeof(BIO_LINEBUFFER_CTX));
     if (ctx == NULL)
         return (0);
-    ctx->obuf = (char *)OPENSSL_malloc(DEFAULT_LINEBUFFER_SIZE);
+    ctx->obuf = OPENSSL_malloc(DEFAULT_LINEBUFFER_SIZE);
     if (ctx->obuf == NULL) {
         OPENSSL_free(ctx);
         return (0);
@@ -278,7 +278,7 @@ static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr)
         obs = (int)num;
         p = ctx->obuf;
         if ((obs > DEFAULT_LINEBUFFER_SIZE) && (obs != ctx->obuf_size)) {
-            p = (char *)OPENSSL_malloc((int)num);
+            p = OPENSSL_malloc((int)num);
             if (p == NULL)
                 goto malloc_error;
         }
diff --git a/crypto/bio/bf_nbio.c b/crypto/bio/bf_nbio.c
index 0ba6055..df547a1 100644
--- a/crypto/bio/bf_nbio.c
+++ b/crypto/bio/bf_nbio.c
@@ -102,7 +102,7 @@ static int nbiof_new(BIO *bi)
 {
     NBIO_TEST *nt;
 
-    if (!(nt = (NBIO_TEST *)OPENSSL_malloc(sizeof(NBIO_TEST))))
+    if (!(nt = OPENSSL_malloc(sizeof(NBIO_TEST))))
         return (0);
     nt->lrn = -1;
     nt->lwn = -1;
diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c
index a5d8680..e7957a7 100644
--- a/crypto/bio/bio_lib.c
+++ b/crypto/bio/bio_lib.c
@@ -67,7 +67,7 @@ BIO *BIO_new(BIO_METHOD *method)
 {
     BIO *ret = NULL;
 
-    ret = (BIO *)OPENSSL_malloc(sizeof(BIO));
+    ret = OPENSSL_malloc(sizeof(BIO));
     if (ret == NULL) {
         BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c
index 72f7bd2..d6f6678 100644
--- a/crypto/bio/bss_acpt.c
+++ b/crypto/bio/bss_acpt.c
@@ -137,7 +137,7 @@ static BIO_ACCEPT *BIO_ACCEPT_new(void)
 {
     BIO_ACCEPT *ret;
 
-    if ((ret = (BIO_ACCEPT *)OPENSSL_malloc(sizeof(BIO_ACCEPT))) == NULL)
+    if ((ret = OPENSSL_malloc(sizeof(BIO_ACCEPT))) == NULL)
         return (NULL);
 
     memset(ret, 0, sizeof(BIO_ACCEPT));
diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c
index e95b4b3..e44bb32 100644
--- a/crypto/bio/bss_conn.c
+++ b/crypto/bio/bss_conn.c
@@ -287,7 +287,7 @@ BIO_CONNECT *BIO_CONNECT_new(void)
 {
     BIO_CONNECT *ret;
 
-    if ((ret = (BIO_CONNECT *)OPENSSL_malloc(sizeof(BIO_CONNECT))) == NULL)
+    if ((ret = OPENSSL_malloc(sizeof(BIO_CONNECT))) == NULL)
         return (NULL);
     ret->state = BIO_CONN_S_BEFORE;
     ret->param_hostname = NULL;
diff --git a/crypto/bio/bss_log.c b/crypto/bio/bss_log.c
index 5f9ab57..2399ff8 100644
--- a/crypto/bio/bss_log.c
+++ b/crypto/bio/bss_log.c
@@ -239,7 +239,7 @@ static int slg_write(BIO *b, const char *in, int inl)
         /* The default */
     };
 
-    if ((buf = (char *)OPENSSL_malloc(inl + 1)) == NULL) {
+    if ((buf = OPENSSL_malloc(inl + 1)) == NULL) {
         return (0);
     }
     strncpy(buf, in, inl);
diff --git a/crypto/bn/bn_blind.c b/crypto/bn/bn_blind.c
index 1cd6fb8..f045904 100644
--- a/crypto/bn/bn_blind.c
+++ b/crypto/bn/bn_blind.c
@@ -137,7 +137,7 @@ BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod)
 
     bn_check_top(mod);
 
-    if ((ret = (BN_BLINDING *)OPENSSL_malloc(sizeof(BN_BLINDING))) == NULL) {
+    if ((ret = OPENSSL_malloc(sizeof(BN_BLINDING))) == NULL) {
         BNerr(BN_F_BN_BLINDING_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
     }
diff --git a/crypto/bn/bn_exp.c b/crypto/bn/bn_exp.c
index 8c46e50..153a970 100644
--- a/crypto/bn/bn_exp.c
+++ b/crypto/bn/bn_exp.c
@@ -758,8 +758,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
     else
 #endif
         if ((powerbufFree =
-             (unsigned char *)OPENSSL_malloc(powerbufLen +
-                                             MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH))
+             OPENSSL_malloc(powerbufLen + MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH))
             == NULL)
         goto err;
 
diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c
index aeee49a..fc7ad24 100644
--- a/crypto/bn/bn_gf2m.c
+++ b/crypto/bn/bn_gf2m.c
@@ -551,7 +551,7 @@ int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
     bn_check_top(a);
     bn_check_top(b);
     bn_check_top(p);
-    if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL)
+    if ((arr = OPENSSL_malloc(sizeof(int) * max)) == NULL)
         goto err;
     ret = BN_GF2m_poly2arr(p, arr, max);
     if (!ret || ret > max) {
@@ -610,7 +610,7 @@ int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
 
     bn_check_top(a);
     bn_check_top(p);
-    if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL)
+    if ((arr = OPENSSL_malloc(sizeof(int) * max)) == NULL)
         goto err;
     ret = BN_GF2m_poly2arr(p, arr, max);
     if (!ret || ret > max) {
@@ -1027,7 +1027,7 @@ int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
     bn_check_top(a);
     bn_check_top(b);
     bn_check_top(p);
-    if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL)
+    if ((arr = OPENSSL_malloc(sizeof(int) * max)) == NULL)
         goto err;
     ret = BN_GF2m_poly2arr(p, arr, max);
     if (!ret || ret > max) {
@@ -1087,7 +1087,7 @@ int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
     int *arr = NULL;
     bn_check_top(a);
     bn_check_top(p);
-    if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL)
+    if ((arr = OPENSSL_malloc(sizeof(int) * max)) == NULL)
         goto err;
     ret = BN_GF2m_poly2arr(p, arr, max);
     if (!ret || ret > max) {
@@ -1218,7 +1218,7 @@ int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
     int *arr = NULL;
     bn_check_top(a);
     bn_check_top(p);
-    if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL)
+    if ((arr = OPENSSL_malloc(sizeof(int) * max)) == NULL)
         goto err;
     ret = BN_GF2m_poly2arr(p, arr, max);
     if (!ret || ret > max) {
diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c
index c3164fa..9cffba8 100644
--- a/crypto/bn/bn_lib.c
+++ b/crypto/bn/bn_lib.c
@@ -268,7 +268,7 @@ BIGNUM *BN_new(void)
 {
     BIGNUM *ret;
 
-    if ((ret = (BIGNUM *)OPENSSL_malloc(sizeof(BIGNUM))) == NULL) {
+    if ((ret = OPENSSL_malloc(sizeof(BIGNUM))) == NULL) {
         BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
     }
@@ -299,7 +299,7 @@ static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
         BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);
         return (NULL);
     }
-    a = A = (BN_ULONG *)OPENSSL_malloc(sizeof(BN_ULONG) * words);
+    a = A = OPENSSL_malloc(sizeof(BN_ULONG) * words);
     if (A == NULL) {
         BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);
         return (NULL);
@@ -921,7 +921,7 @@ BN_GENCB *BN_GENCB_new(void)
 {
     BN_GENCB *ret;
 
-    if ((ret = (BN_GENCB *)OPENSSL_malloc(sizeof(BN_GENCB))) == NULL) {
+    if ((ret = OPENSSL_malloc(sizeof(BN_GENCB))) == NULL) {
         BNerr(BN_F_BN_GENCB_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
     }
diff --git a/crypto/bn/bn_mont.c b/crypto/bn/bn_mont.c
index 45deed7..f19910d 100644
--- a/crypto/bn/bn_mont.c
+++ b/crypto/bn/bn_mont.c
@@ -314,7 +314,7 @@ BN_MONT_CTX *BN_MONT_CTX_new(void)
 {
     BN_MONT_CTX *ret;
 
-    if ((ret = (BN_MONT_CTX *)OPENSSL_malloc(sizeof(BN_MONT_CTX))) == NULL)
+    if ((ret = OPENSSL_malloc(sizeof(BN_MONT_CTX))) == NULL)
         return (NULL);
 
     BN_MONT_CTX_init(ret);
diff --git a/crypto/bn/bn_print.c b/crypto/bn/bn_print.c
index 1000e69..9b03240 100644
--- a/crypto/bn/bn_print.c
+++ b/crypto/bn/bn_print.c
@@ -71,7 +71,7 @@ char *BN_bn2hex(const BIGNUM *a)
     char *buf;
     char *p;
 
-    buf = (char *)OPENSSL_malloc(a->top * BN_BYTES * 2 + 2);
+    buf = OPENSSL_malloc(a->top * BN_BYTES * 2 + 2);
     if (buf == NULL) {
         BNerr(BN_F_BN_BN2HEX, ERR_R_MALLOC_FAILURE);
         goto err;
@@ -114,9 +114,8 @@ char *BN_bn2dec(const BIGNUM *a)
      */
     i = BN_num_bits(a) * 3;
     num = (i / 10 + i / 1000 + 1) + 1;
-    bn_data =
-        (BN_ULONG *)OPENSSL_malloc((num / BN_DEC_NUM + 1) * sizeof(BN_ULONG));
-    buf = (char *)OPENSSL_malloc(num + 3);
+    bn_data = OPENSSL_malloc((num / BN_DEC_NUM + 1) * sizeof(BN_ULONG));
+    buf = OPENSSL_malloc(num + 3);
     if ((buf == NULL) || (bn_data == NULL)) {
         BNerr(BN_F_BN_BN2DEC, ERR_R_MALLOC_FAILURE);
         goto err;
diff --git a/crypto/bn/bn_rand.c b/crypto/bn/bn_rand.c
index be58a5a..1096464 100644
--- a/crypto/bn/bn_rand.c
+++ b/crypto/bn/bn_rand.c
@@ -131,7 +131,7 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
     bit = (bits - 1) % 8;
     mask = 0xff << (bit + 1);
 
-    buf = (unsigned char *)OPENSSL_malloc(bytes);
+    buf = OPENSSL_malloc(bytes);
     if (buf == NULL) {
         BNerr(BN_F_BNRAND, ERR_R_MALLOC_FAILURE);
         goto err;
diff --git a/crypto/bn/bn_recp.c b/crypto/bn/bn_recp.c
index 4f94408..ef1972b 100644
--- a/crypto/bn/bn_recp.c
+++ b/crypto/bn/bn_recp.c
@@ -71,7 +71,7 @@ BN_RECP_CTX *BN_RECP_CTX_new(void)
 {
     BN_RECP_CTX *ret;
 
-    if ((ret = (BN_RECP_CTX *)OPENSSL_malloc(sizeof(BN_RECP_CTX))) == NULL)
+    if ((ret = OPENSSL_malloc(sizeof(BN_RECP_CTX))) == NULL)
         return (NULL);
 
     BN_RECP_CTX_init(ret);
diff --git a/crypto/comp/c_zlib.c b/crypto/comp/c_zlib.c
index c3b064c..aa03f8f 100644
--- a/crypto/comp/c_zlib.c
+++ b/crypto/comp/c_zlib.c
@@ -119,8 +119,7 @@ static int zlib_stateful_ex_idx = -1;
 static int zlib_stateful_init(COMP_CTX *ctx)
 {
     int err;
-    struct zlib_state *state =
-        (struct zlib_state *)OPENSSL_malloc(sizeof(struct zlib_state));
+    struct zlib_state *state = OPENSSL_malloc(sizeof(struct zlib_state));
 
     if (state == NULL)
         goto err;
diff --git a/crypto/comp/comp_lib.c b/crypto/comp/comp_lib.c
index bd4eb7a..7bcdd6b 100644
--- a/crypto/comp/comp_lib.c
+++ b/crypto/comp/comp_lib.c
@@ -8,7 +8,7 @@ COMP_CTX *COMP_CTX_new(COMP_METHOD *meth)
 {
     COMP_CTX *ret;
 
-    if ((ret = (COMP_CTX *)OPENSSL_malloc(sizeof(COMP_CTX))) == NULL) {
+    if ((ret = OPENSSL_malloc(sizeof(COMP_CTX))) == NULL) {
         /* ZZZZZZZZZZZZZZZZ */
         return (NULL);
     }
diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
index c8744e6..ef3fef4 100644
--- a/crypto/conf/conf_def.c
+++ b/crypto/conf/conf_def.c
@@ -225,7 +225,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
         goto err;
     }
 
-    section = (char *)OPENSSL_malloc(10);
+    section = OPENSSL_malloc(10);
     if (section == NULL) {
         CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
         goto err;
@@ -357,13 +357,13 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
             p++;
             *p = '\0';
 
-            if (!(v = (CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE)))) {
+            if (!(v = OPENSSL_malloc(sizeof(CONF_VALUE)))) {
                 CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
                 goto err;
             }
             if (psection == NULL)
                 psection = section;
-            v->name = (char *)OPENSSL_malloc(strlen(pname) + 1);
+            v->name = OPENSSL_malloc(strlen(pname) + 1);
             v->value = NULL;
             if (v->name == NULL) {
                 CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c
index 4f07a27..68a54a6 100644
--- a/crypto/dh/dh_lib.c
+++ b/crypto/dh/dh_lib.c
@@ -109,9 +109,8 @@ DH *DH_new(void)
 
 DH *DH_new_method(ENGINE *engine)
 {
-    DH *ret;
+    DH *ret = OPENSSL_malloc(sizeof(DH));
 
-    ret = (DH *)OPENSSL_malloc(sizeof(DH));
     if (ret == NULL) {
         DHerr(DH_F_DH_NEW_METHOD, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/dsa/dsa_ameth.c b/crypto/dsa/dsa_ameth.c
index 65e07fd..c155e5b 100644
--- a/crypto/dsa/dsa_ameth.c
+++ b/crypto/dsa/dsa_ameth.c
@@ -451,7 +451,7 @@ static int do_dsa_print(BIO *bp, const DSA *x, int off, int ptype)
     update_buflen(priv_key, &buf_len);
     update_buflen(pub_key, &buf_len);
 
-    m = (unsigned char *)OPENSSL_malloc(buf_len + 10);
+    m = OPENSSL_malloc(buf_len + 10);
     if (m == NULL) {
         DSAerr(DSA_F_DO_DSA_PRINT, ERR_R_MALLOC_FAILURE);
         goto err;
diff --git a/crypto/dsa/dsa_lib.c b/crypto/dsa/dsa_lib.c
index c94be9d..5cf1824 100644
--- a/crypto/dsa/dsa_lib.c
+++ b/crypto/dsa/dsa_lib.c
@@ -117,7 +117,7 @@ DSA *DSA_new_method(ENGINE *engine)
 {
     DSA *ret;
 
-    ret = (DSA *)OPENSSL_malloc(sizeof(DSA));
+    ret = OPENSSL_malloc(sizeof(DSA));
     if (ret == NULL) {
         DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/dso/dso_lib.c b/crypto/dso/dso_lib.c
index 09b8eaf..c1d6d25 100644
--- a/crypto/dso/dso_lib.c
+++ b/crypto/dso/dso_lib.c
@@ -96,14 +96,15 @@ DSO *DSO_new_method(DSO_METHOD *meth)
 {
     DSO *ret;
 
-    if (default_DSO_meth == NULL)
+    if (default_DSO_meth == NULL) {
         /*
          * We default to DSO_METH_openssl() which in turn defaults to
          * stealing the "best available" method. Will fallback to
          * DSO_METH_null() in the worst case.
          */
         default_DSO_meth = DSO_METHOD_openssl();
-    ret = (DSO *)OPENSSL_malloc(sizeof(DSO));
+    }
+    ret = OPENSSL_malloc(sizeof(DSO));
     if (ret == NULL) {
         DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/dso/dso_win32.c b/crypto/dso/dso_win32.c
index e671672..2499fc1 100644
--- a/crypto/dso/dso_win32.c
+++ b/crypto/dso/dso_win32.c
@@ -168,7 +168,7 @@ static int win32_load(DSO *dso)
         ERR_add_error_data(3, "filename(", filename, ")");
         goto err;
     }
-    p = (HINSTANCE *) OPENSSL_malloc(sizeof(HINSTANCE));
+    p = OPENSSL_malloc(sizeof(HINSTANCE));
     if (p == NULL) {
         DSOerr(DSO_F_WIN32_LOAD, ERR_R_MALLOC_FAILURE);
         goto err;
diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c
index 65c3d56..5a7b0b7 100644
--- a/crypto/ec/ec_ameth.c
+++ b/crypto/ec/ec_ameth.c
@@ -324,7 +324,7 @@ static int eckey_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
         ECerr(EC_F_ECKEY_PRIV_ENCODE, ERR_R_EC_LIB);
         return 0;
     }
-    ep = (unsigned char *)OPENSSL_malloc(eplen);
+    ep = OPENSSL_malloc(eplen);
     if (!ep) {
         EC_KEY_set_enc_flags(ec_key, old_flags);
         ECerr(EC_F_ECKEY_PRIV_ENCODE, ERR_R_MALLOC_FAILURE);
diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c
index a74ccf7..b73263d 100644
--- a/crypto/ec/ec_key.c
+++ b/crypto/ec/ec_key.c
@@ -69,7 +69,7 @@ EC_KEY *EC_KEY_new(void)
 {
     EC_KEY *ret;
 
-    ret = (EC_KEY *)OPENSSL_malloc(sizeof(EC_KEY));
+    ret = OPENSSL_malloc(sizeof(EC_KEY));
     if (ret == NULL) {
         ECerr(EC_F_EC_KEY_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c
index 243b539..979b454 100644
--- a/crypto/ec/ec_mult.c
+++ b/crypto/ec/ec_mult.c
@@ -100,7 +100,7 @@ static EC_PRE_COMP *ec_pre_comp_new(const EC_GROUP *group)
     if (!group)
         return NULL;
 
-    ret = (EC_PRE_COMP *)OPENSSL_malloc(sizeof(EC_PRE_COMP));
+    ret = OPENSSL_malloc(sizeof(EC_PRE_COMP));
     if (!ret) {
         ECerr(EC_F_EC_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
         return ret;
diff --git a/crypto/ec/ec_print.c b/crypto/ec/ec_print.c
index 7c34694..5ae85cc 100644
--- a/crypto/ec/ec_print.c
+++ b/crypto/ec/ec_print.c
@@ -143,7 +143,7 @@ char *EC_POINT_point2hex(const EC_GROUP *group,
         return NULL;
     }
 
-    ret = (char *)OPENSSL_malloc(buf_len * 2 + 2);
+    ret = OPENSSL_malloc(buf_len * 2 + 2);
     if (ret == NULL) {
         OPENSSL_free(buf);
         return NULL;
diff --git a/crypto/ec/ecp_nistp224.c b/crypto/ec/ecp_nistp224.c
index 6269cce..5afe71c 100644
--- a/crypto/ec/ecp_nistp224.c
+++ b/crypto/ec/ecp_nistp224.c
@@ -1200,7 +1200,7 @@ static void batch_mul(felem x_out, felem y_out, felem z_out,
 static NISTP224_PRE_COMP *nistp224_pre_comp_new()
 {
     NISTP224_PRE_COMP *ret = NULL;
-    ret = (NISTP224_PRE_COMP *) OPENSSL_malloc(sizeof *ret);
+    ret = OPENSSL_malloc(sizeof *ret);
     if (!ret) {
         ECerr(EC_F_NISTP224_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
         return ret;
diff --git a/crypto/ec/ecp_nistp256.c b/crypto/ec/ecp_nistp256.c
index b42e96a..2f394bf 100644
--- a/crypto/ec/ecp_nistp256.c
+++ b/crypto/ec/ecp_nistp256.c
@@ -1815,7 +1815,7 @@ const EC_METHOD *EC_GFp_nistp256_method(void)
 static NISTP256_PRE_COMP *nistp256_pre_comp_new()
 {
     NISTP256_PRE_COMP *ret = NULL;
-    ret = (NISTP256_PRE_COMP *) OPENSSL_malloc(sizeof *ret);
+    ret = OPENSSL_malloc(sizeof *ret);
     if (!ret) {
         ECerr(EC_F_NISTP256_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
         return ret;
diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c
index 2e4a651..b2fe653 100644
--- a/crypto/ec/ecp_nistp521.c
+++ b/crypto/ec/ecp_nistp521.c
@@ -1644,7 +1644,7 @@ const EC_METHOD *EC_GFp_nistp521_method(void)
 static NISTP521_PRE_COMP *nistp521_pre_comp_new()
 {
     NISTP521_PRE_COMP *ret = NULL;
-    ret = (NISTP521_PRE_COMP *) OPENSSL_malloc(sizeof(NISTP521_PRE_COMP));
+    ret = OPENSSL_malloc(sizeof(NISTP521_PRE_COMP));
     if (!ret) {
         ECerr(EC_F_NISTP521_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
         return ret;
diff --git a/crypto/ec/ecp_nistz256.c b/crypto/ec/ecp_nistz256.c
index 6937314..c527797 100644
--- a/crypto/ec/ecp_nistz256.c
+++ b/crypto/ec/ecp_nistz256.c
@@ -1416,7 +1416,7 @@ static EC_PRE_COMP *ecp_nistz256_pre_comp_new(const EC_GROUP *group)
     if (!group)
         return NULL;
 
-    ret = (EC_PRE_COMP *)OPENSSL_malloc(sizeof(EC_PRE_COMP));
+    ret = OPENSSL_malloc(sizeof(EC_PRE_COMP));
 
     if (!ret) {
         ECerr(EC_F_ECP_NISTZ256_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
diff --git a/crypto/ecdh/ech_lib.c b/crypto/ecdh/ech_lib.c
index 5147368..7b57ec4 100644
--- a/crypto/ecdh/ech_lib.c
+++ b/crypto/ecdh/ech_lib.c
@@ -117,7 +117,7 @@ static ECDH_DATA *ECDH_DATA_new_method(ENGINE *engine)
 {
     ECDH_DATA *ret;
 
-    ret = (ECDH_DATA *)OPENSSL_malloc(sizeof(ECDH_DATA));
+    ret = OPENSSL_malloc(sizeof(ECDH_DATA));
     if (ret == NULL) {
         ECDHerr(ECDH_F_ECDH_DATA_NEW_METHOD, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/ecdsa/ecs_lib.c b/crypto/ecdsa/ecs_lib.c
index 67e521f..cdb7b60 100644
--- a/crypto/ecdsa/ecs_lib.c
+++ b/crypto/ecdsa/ecs_lib.c
@@ -105,7 +105,7 @@ static ECDSA_DATA *ECDSA_DATA_new_method(ENGINE *engine)
 {
     ECDSA_DATA *ret;
 
-    ret = (ECDSA_DATA *)OPENSSL_malloc(sizeof(ECDSA_DATA));
+    ret = OPENSSL_malloc(sizeof(ECDSA_DATA));
     if (ret == NULL) {
         ECDSAerr(ECDSA_F_ECDSA_DATA_NEW_METHOD, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
index d005e01..a3be0d7 100644
--- a/crypto/engine/eng_cryptodev.c
+++ b/crypto/engine/eng_cryptodev.c
@@ -1045,7 +1045,7 @@ static int crparam2bn(struct crparam *crp, BIGNUM *a)
     if (bytes == 0)
         return (-1);
 
-    if ((pd = (u_int8_t *) OPENSSL_malloc(bytes)) == NULL)
+    if ((pd = OPENSSL_malloc(bytes)) == NULL)
         return (-1);
 
     for (i = 0; i < bytes; i++)
diff --git a/crypto/engine/eng_lib.c b/crypto/engine/eng_lib.c
index dc2abd2..6083440 100644
--- a/crypto/engine/eng_lib.c
+++ b/crypto/engine/eng_lib.c
@@ -66,7 +66,7 @@ ENGINE *ENGINE_new(void)
 {
     ENGINE *ret;
 
-    ret = (ENGINE *)OPENSSL_malloc(sizeof(ENGINE));
+    ret = OPENSSL_malloc(sizeof(ENGINE));
     if (ret == NULL) {
         ENGINEerr(ENGINE_F_ENGINE_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
diff --git a/crypto/err/err.c b/crypto/err/err.c
index b078442..4752148 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -886,7 +886,7 @@ ERR_STATE *ERR_get_state(void)
 
     /* ret == the error state, if NULL, make a new one */
     if (ret == NULL) {
-        ret = (ERR_STATE *)OPENSSL_malloc(sizeof(ERR_STATE));
+        ret = OPENSSL_malloc(sizeof(ERR_STATE));
         if (ret == NULL)
             return (&fallback);
         CRYPTO_THREADID_cpy(&ret->tid, &tid);
diff --git a/crypto/evp/bio_b64.c b/crypto/evp/bio_b64.c
index 8cbbf02..fe772fc 100644
--- a/crypto/evp/bio_b64.c
+++ b/crypto/evp/bio_b64.c
@@ -115,7 +115,7 @@ static int b64_new(BIO *bi)
 {
     BIO_B64_CTX *ctx;
 
-    ctx = (BIO_B64_CTX *)OPENSSL_malloc(sizeof(BIO_B64_CTX));
+    ctx = OPENSSL_malloc(sizeof(BIO_B64_CTX));
     if (ctx == NULL)
         return (0);
 
diff --git a/crypto/evp/bio_enc.c b/crypto/evp/bio_enc.c
index faaed4d..4409a91 100644
--- a/crypto/evp/bio_enc.c
+++ b/crypto/evp/bio_enc.c
@@ -112,7 +112,7 @@ static int enc_new(BIO *bi)
 {
     BIO_ENC_CTX *ctx;
 
-    ctx = (BIO_ENC_CTX *)OPENSSL_malloc(sizeof(BIO_ENC_CTX));
+    ctx = OPENSSL_malloc(sizeof(BIO_ENC_CTX));
     if (ctx == NULL)
         return (0);
     EVP_CIPHER_CTX_init(&ctx->cipher);
diff --git a/crypto/evp/bio_ok.c b/crypto/evp/bio_ok.c
index ffdde6c..1aab200 100644
--- a/crypto/evp/bio_ok.c
+++ b/crypto/evp/bio_ok.c
@@ -176,7 +176,7 @@ static int ok_new(BIO *bi)
 {
     BIO_OK_CTX *ctx;
 
-    ctx = (BIO_OK_CTX *)OPENSSL_malloc(sizeof(BIO_OK_CTX));
+    ctx = OPENSSL_malloc(sizeof(BIO_OK_CTX));
     if (ctx == NULL)
         return (0);
 
diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c
index 7db9511..00fa72d 100644
--- a/crypto/evp/evp_pbe.c
+++ b/crypto/evp/evp_pbe.c
@@ -228,7 +228,7 @@ int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,
     EVP_PBE_CTL *pbe_tmp;
     if (!pbe_algs)
         pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp);
-    if (!(pbe_tmp = (EVP_PBE_CTL *)OPENSSL_malloc(sizeof(EVP_PBE_CTL)))) {
+    if (!(pbe_tmp = OPENSSL_malloc(sizeof(EVP_PBE_CTL)))) {
         EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE);
         return 0;
     }
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c
index fb8f175..c9e971e 100644
--- a/crypto/evp/p_lib.c
+++ b/crypto/evp/p_lib.c
@@ -185,7 +185,7 @@ EVP_PKEY *EVP_PKEY_new(void)
 {
     EVP_PKEY *ret;
 
-    ret = (EVP_PKEY *)OPENSSL_malloc(sizeof(EVP_PKEY));
+    ret = OPENSSL_malloc(sizeof(EVP_PKEY));
     if (ret == NULL) {
         EVPerr(EVP_F_EVP_PKEY_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/evp/p_open.c b/crypto/evp/p_open.c
index 229eb64..adaa42f 100644
--- a/crypto/evp/p_open.c
+++ b/crypto/evp/p_open.c
@@ -88,7 +88,7 @@ int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
     }
 
     size = RSA_size(priv->pkey.rsa);
-    key = (unsigned char *)OPENSSL_malloc(size + 2);
+    key = OPENSSL_malloc(size + 2);
     if (key == NULL) {
         /* ERROR */
         EVPerr(EVP_F_EVP_OPENINIT, ERR_R_MALLOC_FAILURE);
diff --git a/crypto/ex_data.c b/crypto/ex_data.c
index d55985b..6a567c9 100644
--- a/crypto/ex_data.c
+++ b/crypto/ex_data.c
@@ -350,8 +350,7 @@ static int def_add_index(EX_CLASS_ITEM *item, long argl, void *argp,
                          CRYPTO_EX_free *free_func)
 {
     int toret = -1;
-    CRYPTO_EX_DATA_FUNCS *a =
-        (CRYPTO_EX_DATA_FUNCS *)OPENSSL_malloc(sizeof(CRYPTO_EX_DATA_FUNCS));
+    CRYPTO_EX_DATA_FUNCS *a = OPENSSL_malloc(sizeof(CRYPTO_EX_DATA_FUNCS));
     if (!a) {
         CRYPTOerr(CRYPTO_F_DEF_ADD_INDEX, ERR_R_MALLOC_FAILURE);
         return -1;
diff --git a/crypto/lhash/lhash.c b/crypto/lhash/lhash.c
index 5e9bfb8..ac3b5f6 100644
--- a/crypto/lhash/lhash.c
+++ b/crypto/lhash/lhash.c
@@ -188,7 +188,7 @@ void *lh_insert(_LHASH *lh, void *data)
     rn = getrn(lh, data, &hash);
 
     if (*rn == NULL) {
-        if ((nn = (LHASH_NODE *)OPENSSL_malloc(sizeof(LHASH_NODE))) == NULL) {
+        if ((nn = OPENSSL_malloc(sizeof(LHASH_NODE))) == NULL) {
             lh->error++;
             return (NULL);
         }
@@ -325,15 +325,13 @@ static void expand(_LHASH *lh)
 
     if ((lh->p) >= lh->pmax) {
         j = (int)lh->num_alloc_nodes * 2;
-        n = (LHASH_NODE **)OPENSSL_realloc(lh->b,
-                                           (int)(sizeof(LHASH_NODE *) * j));
+        n = OPENSSL_realloc(lh->b, (int)(sizeof(LHASH_NODE *) * j));
         if (n == NULL) {
-/*                      fputs("realloc error in lhash",stderr); */
+            /* fputs("realloc error in lhash",stderr); */
             lh->error++;
             lh->p = 0;
             return;
         }
-        /* else */
         for (i = (int)lh->num_alloc_nodes; i < j; i++) /* 26/02/92 eay */
             n[i] = NULL;        /* 02/03/92 eay */
         lh->pmax = lh->num_alloc_nodes;
@@ -351,11 +349,10 @@ static void contract(_LHASH *lh)
     np = lh->b[lh->p + lh->pmax - 1];
     lh->b[lh->p + lh->pmax - 1] = NULL; /* 24/07-92 - eay - weird but :-( */
     if (lh->p == 0) {
-        n = (LHASH_NODE **)OPENSSL_realloc(lh->b,
-                                           (unsigned int)(sizeof(LHASH_NODE *)
-                                                          * lh->pmax));
+        n = OPENSSL_realloc(lh->b,
+                            (unsigned int)(sizeof(LHASH_NODE *) * lh->pmax));
         if (n == NULL) {
-/*                      fputs("realloc error in lhash",stderr); */
+            /* fputs("realloc error in lhash",stderr); */
             lh->error++;
             return;
         }
diff --git a/crypto/lock.c b/crypto/lock.c
index c718878..cc5f47a 100644
--- a/crypto/lock.c
+++ b/crypto/lock.c
@@ -251,7 +251,7 @@ int CRYPTO_get_new_dynlockid(void)
     }
     CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
 
-    pointer = (CRYPTO_dynlock *) OPENSSL_malloc(sizeof(CRYPTO_dynlock));
+    pointer = OPENSSL_malloc(sizeof(CRYPTO_dynlock));
     if (pointer == NULL) {
         CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE);
         return (0);
diff --git a/crypto/mem.c b/crypto/mem.c
index 2251d57..afdce77 100644
--- a/crypto/mem.c
+++ b/crypto/mem.c
@@ -447,7 +447,7 @@ void *CRYPTO_remalloc(void *a, int num, const char *file, int line)
 {
     if (a != NULL)
         OPENSSL_free(a);
-    a = (char *)OPENSSL_malloc(num);
+    a = OPENSSL_malloc(num);
     return (a);
 }
 
diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c
index 36593ed..402df01 100644
--- a/crypto/mem_dbg.c
+++ b/crypto/mem_dbg.c
@@ -394,7 +394,7 @@ int CRYPTO_push_info_(const char *info, const char *file, int line)
     if (is_MemCheck_on()) {
         MemCheck_off();         /* obtain MALLOC2 lock */
 
-        if ((ami = (APP_INFO *)OPENSSL_malloc(sizeof(APP_INFO))) == NULL) {
+        if ((ami = OPENSSL_malloc(sizeof(APP_INFO))) == NULL) {
             ret = 0;
             goto err;
         }
@@ -478,7 +478,7 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
 
         if (is_MemCheck_on()) {
             MemCheck_off();     /* make sure we hold MALLOC2 lock */
-            if ((m = (MEM *)OPENSSL_malloc(sizeof(MEM))) == NULL) {
+            if ((m = OPENSSL_malloc(sizeof(MEM))) == NULL) {
                 OPENSSL_free(addr);
                 MemCheck_on();  /* release MALLOC2 lock if num_disabled drops
                                  * to 0 */
diff --git a/crypto/modes/gcm128.c b/crypto/modes/gcm128.c
index 1d1b0d9..4ac28b3 100644
--- a/crypto/modes/gcm128.c
+++ b/crypto/modes/gcm128.c
@@ -1701,7 +1701,7 @@ GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block)
 {
     GCM128_CONTEXT *ret;
 
-    if ((ret = (GCM128_CONTEXT *)OPENSSL_malloc(sizeof(GCM128_CONTEXT))))
+    if ((ret = OPENSSL_malloc(sizeof(GCM128_CONTEXT))))
         CRYPTO_gcm128_init(ret, key, block);
 
     return ret;
diff --git a/crypto/modes/ocb128.c b/crypto/modes/ocb128.c
index cbcb7f6..0d82e50 100644
--- a/crypto/modes/ocb128.c
+++ b/crypto/modes/ocb128.c
@@ -210,7 +210,7 @@ OCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec,
     OCB128_CONTEXT *octx;
     int ret;
 
-    if ((octx = (OCB128_CONTEXT *)OPENSSL_malloc(sizeof(OCB128_CONTEXT)))) {
+    if ((octx = OPENSSL_malloc(sizeof(OCB128_CONTEXT)))) {
         ret = CRYPTO_ocb128_init(octx, keyenc, keydec, encrypt, decrypt);
         if (ret)
             return octx;
diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c
index fa8709f..1fa6426 100644
--- a/crypto/objects/o_names.c
+++ b/crypto/objects/o_names.c
@@ -187,7 +187,7 @@ int OBJ_NAME_add(const char *name, int type, const char *data)
     alias = type & OBJ_NAME_ALIAS;
     type &= ~OBJ_NAME_ALIAS;
 
-    onp = (OBJ_NAME *)OPENSSL_malloc(sizeof(OBJ_NAME));
+    onp = OPENSSL_malloc(sizeof(OBJ_NAME));
     if (onp == NULL) {
         /* ERROR */
         return (0);
diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c
index 5c861d1..376169c 100644
--- a/crypto/objects/obj_dat.c
+++ b/crypto/objects/obj_dat.c
@@ -255,21 +255,19 @@ int OBJ_add_object(const ASN1_OBJECT *obj)
             return (0);
     if ((o = OBJ_dup(obj)) == NULL)
         goto err;
-    if (!(ao[ADDED_NID] = (ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ))))
+    if (!(ao[ADDED_NID] = OPENSSL_malloc(sizeof(ADDED_OBJ))))
         goto err2;
     if ((o->length != 0) && (obj->data != NULL))
         if (!
-            (ao[ADDED_DATA] = (ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ))))
+            (ao[ADDED_DATA] = OPENSSL_malloc(sizeof(ADDED_OBJ))))
             goto err2;
     if (o->sn != NULL)
         if (!
-            (ao[ADDED_SNAME] =
-             (ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ))))
+            (ao[ADDED_SNAME] = OPENSSL_malloc(sizeof(ADDED_OBJ))))
             goto err2;
     if (o->ln != NULL)
         if (!
-            (ao[ADDED_LNAME] =
-             (ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ))))
+            (ao[ADDED_LNAME] = OPENSSL_malloc(sizeof(ADDED_OBJ))))
             goto err2;
 
     for (i = ADDED_DATA; i <= ADDED_NID; i++) {
@@ -450,7 +448,7 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
     /* Work out total size */
     j = ASN1_object_size(0, i, V_ASN1_OBJECT);
 
-    if ((buf = (unsigned char *)OPENSSL_malloc(j)) == NULL)
+    if ((buf = OPENSSL_malloc(j)) == NULL)
         return NULL;
 
     p = buf;
@@ -766,7 +764,7 @@ int OBJ_create(const char *oid, const char *sn, const char *ln)
     if (i <= 0)
         return (0);
 
-    if ((buf = (unsigned char *)OPENSSL_malloc(i)) == NULL) {
+    if ((buf = OPENSSL_malloc(i)) == NULL) {
         OBJerr(OBJ_F_OBJ_CREATE, ERR_R_MALLOC_FAILURE);
         return (0);
     }
diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c
index 70e6a70..431e368 100644
--- a/crypto/pem/pem_lib.c
+++ b/crypto/pem/pem_lib.c
@@ -361,7 +361,7 @@ int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp,
     }
     /* dzise + 8 bytes are needed */
     /* actually it needs the cipher block size extra... */
-    data = (unsigned char *)OPENSSL_malloc((unsigned int)dsize + 20);
+    data = OPENSSL_malloc((unsigned int)dsize + 20);
     if (data == NULL) {
         PEMerr(PEM_F_PEM_ASN1_WRITE_BIO, ERR_R_MALLOC_FAILURE);
         goto err;
diff --git a/crypto/pem/pem_seal.c b/crypto/pem/pem_seal.c
index e82ab6f..374273d 100644
--- a/crypto/pem/pem_seal.c
+++ b/crypto/pem/pem_seal.c
@@ -85,7 +85,7 @@ int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type,
         if (j > max)
             max = j;
     }
-    s = (char *)OPENSSL_malloc(max * 2);
+    s = OPENSSL_malloc(max * 2);
     if (s == NULL) {
         PEMerr(PEM_F_PEM_SEALINIT, ERR_R_MALLOC_FAILURE);
         goto err;
@@ -159,7 +159,7 @@ int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl,
     i = RSA_size(priv->pkey.rsa);
     if (i < 100)
         i = 100;
-    s = (unsigned char *)OPENSSL_malloc(i * 2);
+    s = OPENSSL_malloc(i * 2);
     if (s == NULL) {
         PEMerr(PEM_F_PEM_SEALFINAL, ERR_R_MALLOC_FAILURE);
         goto err;
diff --git a/crypto/pem/pem_sign.c b/crypto/pem/pem_sign.c
index a3d5c17..87cc727 100644
--- a/crypto/pem/pem_sign.c
+++ b/crypto/pem/pem_sign.c
@@ -81,7 +81,7 @@ int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
     int i, ret = 0;
     unsigned int m_len;
 
-    m = (unsigned char *)OPENSSL_malloc(EVP_PKEY_size(pkey) + 2);
+    m = OPENSSL_malloc(EVP_PKEY_size(pkey) + 2);
     if (m == NULL) {
         PEMerr(PEM_F_PEM_SIGNFINAL, ERR_R_MALLOC_FAILURE);
         goto err;
diff --git a/crypto/pqueue/pqueue.c b/crypto/pqueue/pqueue.c
index 675ac60..a4af9f9 100644
--- a/crypto/pqueue/pqueue.c
+++ b/crypto/pqueue/pqueue.c
@@ -68,7 +68,7 @@ typedef struct _pqueue {
 
 pitem *pitem_new(unsigned char *prio64be, void *data)
 {
-    pitem *item = (pitem *)OPENSSL_malloc(sizeof(pitem));
+    pitem *item = OPENSSL_malloc(sizeof(pitem));
     if (item == NULL)
         return NULL;
 
@@ -90,7 +90,7 @@ void pitem_free(pitem *item)
 
 pqueue_s *pqueue_new()
 {
-    pqueue_s *pq = (pqueue_s *)OPENSSL_malloc(sizeof(pqueue_s));
+    pqueue_s *pq = OPENSSL_malloc(sizeof(pqueue_s));
     if (pq == NULL)
         return NULL;
 
diff --git a/crypto/rsa/rsa_ameth.c b/crypto/rsa/rsa_ameth.c
index 379bf4c..4e02531 100644
--- a/crypto/rsa/rsa_ameth.c
+++ b/crypto/rsa/rsa_ameth.c
@@ -206,7 +206,7 @@ static int do_rsa_print(BIO *bp, const RSA *x, int off, int priv)
         update_buflen(x->iqmp, &buf_len);
     }
 
-    m = (unsigned char *)OPENSSL_malloc(buf_len + 10);
+    m = OPENSSL_malloc(buf_len + 10);
     if (m == NULL) {
         RSAerr(RSA_F_DO_RSA_PRINT, ERR_R_MALLOC_FAILURE);
         goto err;
diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c
index 57ba1cb..5b4ce73 100644
--- a/crypto/rsa/rsa_lib.c
+++ b/crypto/rsa/rsa_lib.c
@@ -127,7 +127,7 @@ RSA *RSA_new_method(ENGINE *engine)
 {
     RSA *ret;
 
-    ret = (RSA *)OPENSSL_malloc(sizeof(RSA));
+    ret = OPENSSL_malloc(sizeof(RSA));
     if (ret == NULL) {
         RSAerr(RSA_F_RSA_NEW_METHOD, ERR_R_MALLOC_FAILURE);
         return NULL;
diff --git a/crypto/rsa/rsa_saos.c b/crypto/rsa/rsa_saos.c
index 0f15f00..80709f5 100644
--- a/crypto/rsa/rsa_saos.c
+++ b/crypto/rsa/rsa_saos.c
@@ -83,7 +83,7 @@ int RSA_sign_ASN1_OCTET_STRING(int type,
                RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY);
         return (0);
     }
-    s = (unsigned char *)OPENSSL_malloc((unsigned int)j + 1);
+    s = OPENSSL_malloc((unsigned int)j + 1);
     if (s == NULL) {
         RSAerr(RSA_F_RSA_SIGN_ASN1_OCTET_STRING, ERR_R_MALLOC_FAILURE);
         return (0);
@@ -117,7 +117,7 @@ int RSA_verify_ASN1_OCTET_STRING(int dtype,
         return (0);
     }
 
-    s = (unsigned char *)OPENSSL_malloc((unsigned int)siglen);
+    s = OPENSSL_malloc((unsigned int)siglen);
     if (s == NULL) {
         RSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING, ERR_R_MALLOC_FAILURE);
         goto err;
diff --git a/crypto/rsa/rsa_sign.c b/crypto/rsa/rsa_sign.c
index a521d11..ec1575a 100644
--- a/crypto/rsa/rsa_sign.c
+++ b/crypto/rsa/rsa_sign.c
@@ -116,7 +116,7 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
         return (0);
     }
     if (type != NID_md5_sha1) {
-        tmps = (unsigned char *)OPENSSL_malloc((unsigned int)j + 1);
+        tmps = OPENSSL_malloc((unsigned int)j + 1);
         if (tmps == NULL) {
             RSAerr(RSA_F_RSA_SIGN, ERR_R_MALLOC_FAILURE);
             return (0);
@@ -181,7 +181,7 @@ int int_rsa_verify(int dtype, const unsigned char *m,
         return 1;
     }
 
-    s = (unsigned char *)OPENSSL_malloc((unsigned int)siglen);
+    s = OPENSSL_malloc((unsigned int)siglen);
     if (s == NULL) {
         RSAerr(RSA_F_INT_RSA_VERIFY, ERR_R_MALLOC_FAILURE);
         goto err;
diff --git a/crypto/srp/srp_vfy.c b/crypto/srp/srp_vfy.c
index 82b9a77..e8bdbf5 100644
--- a/crypto/srp/srp_vfy.c
+++ b/crypto/srp/srp_vfy.c
@@ -249,7 +249,7 @@ static int SRP_user_pwd_set_sv_BN(SRP_user_pwd *vinfo, BIGNUM *s, BIGNUM *v)
 
 SRP_VBASE *SRP_VBASE_new(char *seed_key)
 {
-    SRP_VBASE *vb = (SRP_VBASE *)OPENSSL_malloc(sizeof(SRP_VBASE));
+    SRP_VBASE *vb = OPENSSL_malloc(sizeof(SRP_VBASE));
 
     if (vb == NULL)
         return NULL;
@@ -283,9 +283,8 @@ static SRP_gN_cache *SRP_gN_new_init(const char *ch)
 {
     unsigned char tmp[MAX_LEN];
     int len;
+    SRP_gN_cache *newgN = OPENSSL_malloc(sizeof(SRP_gN_cache));
 
-    SRP_gN_cache *newgN =
-        (SRP_gN_cache *)OPENSSL_malloc(sizeof(SRP_gN_cache));
     if (newgN == NULL)
         return NULL;
 
@@ -391,7 +390,7 @@ int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)
              * we add this couple in the internal Stack
              */
 
-            if ((gN = (SRP_gN *) OPENSSL_malloc(sizeof(SRP_gN))) == NULL)
+            if ((gN = OPENSSL_malloc(sizeof(SRP_gN))) == NULL)
                 goto err;
 
             if (!(gN->id = BUF_strdup(pp[DB_srpid]))
diff --git a/crypto/stack/stack.c b/crypto/stack/stack.c
index 7d97c2c..d4ac91e 100644
--- a/crypto/stack/stack.c
+++ b/crypto/stack/stack.c
@@ -93,9 +93,8 @@ _STACK *sk_dup(_STACK *sk)
 
     if ((ret = sk_new(sk->comp)) == NULL)
         goto err;
-    s = (char **)OPENSSL_realloc((char *)ret->data,
-                                 (unsigned int)sizeof(char *) *
-                                 sk->num_alloc);
+    s = OPENSSL_realloc((char *)ret->data,
+                        (unsigned int)sizeof(char *) * sk->num_alloc);
     if (s == NULL)
         goto err;
     ret->data = s;
diff --git a/crypto/store/str_lib.c b/crypto/store/str_lib.c
index d683fd8..1a4f237 100644
--- a/crypto/store/str_lib.c
+++ b/crypto/store/str_lib.c
@@ -109,7 +109,7 @@ STORE *STORE_new_method(const STORE_METHOD *method)
         return NULL;
     }
 
-    ret = (STORE *)OPENSSL_malloc(sizeof(STORE));
+    ret = OPENSSL_malloc(sizeof(STORE));
     if (ret == NULL) {
         STOREerr(STORE_F_STORE_NEW_METHOD, ERR_R_MALLOC_FAILURE);
         return NULL;
@@ -1206,7 +1206,7 @@ struct STORE_attr_info_st {
 
 STORE_ATTR_INFO *STORE_ATTR_INFO_new(void)
 {
-    return (STORE_ATTR_INFO *)OPENSSL_malloc(sizeof(STORE_ATTR_INFO));
+    return OPENSSL_malloc(sizeof(STORE_ATTR_INFO));
 }
 
 static void STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs,
diff --git a/crypto/store/str_mem.c b/crypto/store/str_mem.c
index 8edd0eb..f949b34 100644
--- a/crypto/store/str_mem.c
+++ b/crypto/store/str_mem.c
@@ -244,8 +244,7 @@ static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type,
                             OPENSSL_ITEM attributes[],
                             OPENSSL_ITEM parameters[])
 {
-    struct mem_ctx_st *context =
-        (struct mem_ctx_st *)OPENSSL_malloc(sizeof(struct mem_ctx_st));
+    struct mem_ctx_st *context = OPENSSL_malloc(sizeof(struct mem_ctx_st));
     void *attribute_context = NULL;
     STORE_ATTR_INFO *attrs = NULL;
 
diff --git a/crypto/store/str_meth.c b/crypto/store/str_meth.c
index d83a6de..781b160 100644
--- a/crypto/store/str_meth.c
+++ b/crypto/store/str_meth.c
@@ -63,8 +63,7 @@
 
 STORE_METHOD *STORE_create_method(char *name)
 {
-    STORE_METHOD *store_method =
-        (STORE_METHOD *)OPENSSL_malloc(sizeof(STORE_METHOD));
+    STORE_METHOD *store_method = OPENSSL_malloc(sizeof(STORE_METHOD));
 
     if (store_method) {
         memset(store_method, 0, sizeof(*store_method));
diff --git a/crypto/ts/ts_rsp_sign.c b/crypto/ts/ts_rsp_sign.c
index 037ab64..a8d683b 100644
--- a/crypto/ts/ts_rsp_sign.c
+++ b/crypto/ts/ts_rsp_sign.c
@@ -169,7 +169,7 @@ TS_RESP_CTX *TS_RESP_CTX_new()
 {
     TS_RESP_CTX *ctx;
 
-    if (!(ctx = (TS_RESP_CTX *)OPENSSL_malloc(sizeof(TS_RESP_CTX)))) {
+    if (!(ctx = OPENSSL_malloc(sizeof(TS_RESP_CTX)))) {
         TSerr(TS_F_TS_RESP_CTX_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
     }
@@ -919,7 +919,7 @@ static int ESS_add_signing_cert(PKCS7_SIGNER_INFO *si, ESS_SIGNING_CERT *sc)
     int len;
 
     len = i2d_ESS_SIGNING_CERT(sc, NULL);
-    if (!(pp = (unsigned char *)OPENSSL_malloc(len))) {
+    if (!(pp = OPENSSL_malloc(len))) {
         TSerr(TS_F_ESS_ADD_SIGNING_CERT, ERR_R_MALLOC_FAILURE);
         goto err;
     }
diff --git a/crypto/ts/ts_verify_ctx.c b/crypto/ts/ts_verify_ctx.c
index 3e6fcb5..f328c33 100644
--- a/crypto/ts/ts_verify_ctx.c
+++ b/crypto/ts/ts_verify_ctx.c
@@ -63,8 +63,8 @@
 
 TS_VERIFY_CTX *TS_VERIFY_CTX_new(void)
 {
-    TS_VERIFY_CTX *ctx =
-        (TS_VERIFY_CTX *)OPENSSL_malloc(sizeof(TS_VERIFY_CTX));
+    TS_VERIFY_CTX *ctx = OPENSSL_malloc(sizeof(TS_VERIFY_CTX));
+
     if (ctx)
         memset(ctx, 0, sizeof(TS_VERIFY_CTX));
     else
diff --git a/crypto/ui/ui_lib.c b/crypto/ui/ui_lib.c
index 06e6cd8..d2732f5 100644
--- a/crypto/ui/ui_lib.c
+++ b/crypto/ui/ui_lib.c
@@ -74,9 +74,8 @@ UI *UI_new(void)
 
 UI *UI_new_method(const UI_METHOD *method)
 {
-    UI *ret;
+    UI *ret = OPENSSL_malloc(sizeof(UI));
 
-    ret = (UI *)OPENSSL_malloc(sizeof(UI));
     if (ret == NULL) {
         UIerr(UI_F_UI_NEW_METHOD, ERR_R_MALLOC_FAILURE);
         return NULL;
@@ -142,7 +141,7 @@ static UI_STRING *general_allocate_prompt(UI *ui, const char *prompt,
     } else if ((type == UIT_PROMPT || type == UIT_VERIFY
                 || type == UIT_BOOLEAN) && result_buf == NULL) {
         UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER);
-    } else if ((ret = (UI_STRING *)OPENSSL_malloc(sizeof(UI_STRING)))) {
+    } else if ((ret = OPENSSL_malloc(sizeof(UI_STRING)))) {
         ret->out_string = prompt;
         ret->flags = prompt_freeable ? OUT_STRING_FREEABLE : 0;
         ret->input_flags = input_flags;
@@ -410,7 +409,7 @@ char *UI_construct_prompt(UI *ui, const char *object_desc,
             len += sizeof(prompt2) - 1 + strlen(object_name);
         len += sizeof(prompt3) - 1;
 
-        prompt = (char *)OPENSSL_malloc(len + 1);
+        prompt = OPENSSL_malloc(len + 1);
         if (prompt == NULL)
             return NULL;
         BUF_strlcpy(prompt, prompt1, len + 1);
@@ -587,7 +586,7 @@ const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth)
 
 UI_METHOD *UI_create_method(char *name)
 {
-    UI_METHOD *ui_method = (UI_METHOD *)OPENSSL_malloc(sizeof(UI_METHOD));
+    UI_METHOD *ui_method = OPENSSL_malloc(sizeof(UI_METHOD));
 
     if (ui_method) {
         memset(ui_method, 0, sizeof(*ui_method));
diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c
index 80444ff..b30fa30 100644
--- a/crypto/x509/by_dir.c
+++ b/crypto/x509/by_dir.c
@@ -148,7 +148,7 @@ static int new_dir(X509_LOOKUP *lu)
 {
     BY_DIR *a;
 
-    if ((a = (BY_DIR *)OPENSSL_malloc(sizeof(BY_DIR))) == NULL)
+    if ((a = OPENSSL_malloc(sizeof(BY_DIR))) == NULL)
         return (0);
     if ((a->buffer = BUF_MEM_new()) == NULL) {
         OPENSSL_free(a);
diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c
index f77e59d..08bbc39 100644
--- a/crypto/x509/x509_lu.c
+++ b/crypto/x509/x509_lu.c
@@ -67,7 +67,7 @@ X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method)
 {
     X509_LOOKUP *ret;
 
-    ret = (X509_LOOKUP *)OPENSSL_malloc(sizeof(X509_LOOKUP));
+    ret = OPENSSL_malloc(sizeof(X509_LOOKUP));
     if (ret == NULL)
         return NULL;
 
@@ -184,7 +184,7 @@ X509_STORE *X509_STORE_new(void)
 {
     X509_STORE *ret;
 
-    if ((ret = (X509_STORE *)OPENSSL_malloc(sizeof(X509_STORE))) == NULL)
+    if ((ret = OPENSSL_malloc(sizeof(X509_STORE))) == NULL)
         return NULL;
     ret->objs = sk_X509_OBJECT_new(x509_object_cmp);
     ret->cache = 1;
@@ -341,7 +341,7 @@ int X509_STORE_add_cert(X509_STORE *ctx, X509 *x)
 
     if (x == NULL)
         return 0;
-    obj = (X509_OBJECT *)OPENSSL_malloc(sizeof(X509_OBJECT));
+    obj = OPENSSL_malloc(sizeof(X509_OBJECT));
     if (obj == NULL) {
         X509err(X509_F_X509_STORE_ADD_CERT, ERR_R_MALLOC_FAILURE);
         return 0;
@@ -374,7 +374,7 @@ int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x)
 
     if (x == NULL)
         return 0;
-    obj = (X509_OBJECT *)OPENSSL_malloc(sizeof(X509_OBJECT));
+    obj = OPENSSL_malloc(sizeof(X509_OBJECT));
     if (obj == NULL) {
         X509err(X509_F_X509_STORE_ADD_CRL, ERR_R_MALLOC_FAILURE);
         return 0;
diff --git a/crypto/x509/x509_req.c b/crypto/x509/x509_req.c
index 682c2c2..e01fc79 100644
--- a/crypto/x509/x509_req.c
+++ b/crypto/x509/x509_req.c
@@ -83,7 +83,7 @@ X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md)
     ri = ret->req_info;
 
     ri->version->length = 1;
-    ri->version->data = (unsigned char *)OPENSSL_malloc(1);
+    ri->version->data = OPENSSL_malloc(1);
     if (ri->version->data == NULL)
         goto err;
     ri->version->data[0] = 0;   /* version == 0 */
diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
index 9cf39db..85dc714 100644
--- a/crypto/x509/x509_vfy.c
+++ b/crypto/x509/x509_vfy.c
@@ -2218,7 +2218,8 @@ int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
 X509_STORE_CTX *X509_STORE_CTX_new(void)
 {
     X509_STORE_CTX *ctx;
-    ctx = (X509_STORE_CTX *)OPENSSL_malloc(sizeof(X509_STORE_CTX));
+
+    ctx = OPENSSL_malloc(sizeof(X509_STORE_CTX));
     if (!ctx) {
         X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
diff --git a/crypto/x509v3/v3_lib.c b/crypto/x509v3/v3_lib.c
index 7e3e984..3396ff1 100644
--- a/crypto/x509v3/v3_lib.c
+++ b/crypto/x509v3/v3_lib.c
@@ -140,9 +140,7 @@ int X509V3_EXT_add_alias(int nid_to, int nid_from)
                   X509V3_R_EXTENSION_NOT_FOUND);
         return 0;
     }
-    if (!
-        (tmpext =
-         (X509V3_EXT_METHOD *)OPENSSL_malloc(sizeof(X509V3_EXT_METHOD)))) {
+    if (!(tmpext = OPENSSL_malloc(sizeof(X509V3_EXT_METHOD)))) {
         X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS, ERR_R_MALLOC_FAILURE);
         return 0;
     }
diff --git a/crypto/x509v3/v3_utl.c b/crypto/x509v3/v3_utl.c
index cd7a980..aa3a4de 100644
--- a/crypto/x509v3/v3_utl.c
+++ b/crypto/x509v3/v3_utl.c
@@ -88,7 +88,7 @@ int X509V3_add_value(const char *name, const char *value,
         goto err;
     if (value && !(tvalue = BUF_strdup(value)))
         goto err;
-    if (!(vtmp = (CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE))))
+    if (!(vtmp = OPENSSL_malloc(sizeof(CONF_VALUE))))
         goto err;
     if (!*extlist && !(*extlist = sk_CONF_VALUE_new_null()))
         goto err;
diff --git a/demos/b64.c b/demos/b64.c
index fcc6956..2fa4e98 100644
--- a/demos/b64.c
+++ b/demos/b64.c
@@ -169,7 +169,7 @@ char **argv;
     }
 
     strbuf = OPENSSL_malloc(SIZE);
-    buff = (unsigned char *)OPENSSL_malloc(EVP_ENCODE_LENGTH(bsize));
+    buff = OPENSSL_malloc(EVP_ENCODE_LENGTH(bsize));
     if ((buff == NULL) || (strbuf == NULL)) {
         BIO_printf(bio_err, "OPENSSL_malloc failure\n");
         goto end;
diff --git a/engines/ccgost/gost_crypt.c b/engines/ccgost/gost_crypt.c
index 6c95497..5f50fcc 100644
--- a/engines/ccgost/gost_crypt.c
+++ b/engines/ccgost/gost_crypt.c
@@ -446,7 +446,7 @@ int gost89_set_asn1_parameters(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params)
     gcp->enc_param_set = OBJ_nid2obj(c->paramNID);
 
     len = i2d_GOST_CIPHER_PARAMS(gcp, NULL);
-    p = buf = (unsigned char *)OPENSSL_malloc(len);
+    p = buf = OPENSSL_malloc(len);
     if (!buf) {
         GOST_CIPHER_PARAMS_free(gcp);
         GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS, ERR_R_MALLOC_FAILURE);
diff --git a/engines/e_cswift.c b/engines/e_cswift.c
index db94bf2..adab4d4 100644
--- a/engines/e_cswift.c
+++ b/engines/e_cswift.c
@@ -586,7 +586,7 @@ int cswift_bn_32copy(SW_LARGENUMBER *out, const BIGNUM *in)
     while (((out->nbytes = (numbytes + mod)) % 32)) {
         mod++;
     }
-    out->value = (unsigned char *)OPENSSL_malloc(out->nbytes);
+    out->value = OPENSSL_malloc(out->nbytes);
     if (!out->value) {
         return 0;
     }
diff --git a/ssl/bio_ssl.c b/ssl/bio_ssl.c
index 473b3ff..da98ea0 100644
--- a/ssl/bio_ssl.c
+++ b/ssl/bio_ssl.c
@@ -103,7 +103,7 @@ static int ssl_new(BIO *bi)
 {
     BIO_SSL *bs;
 
-    bs = (BIO_SSL *)OPENSSL_malloc(sizeof(BIO_SSL));
+    bs = OPENSSL_malloc(sizeof(BIO_SSL));
     if (bs == NULL) {
         BIOerr(BIO_F_SSL_NEW, ERR_R_MALLOC_FAILURE);
         return (0);
diff --git a/ssl/d1_both.c b/ssl/d1_both.c
index c3552e9..2a76474 100644
--- a/ssl/d1_both.c
+++ b/ssl/d1_both.c
@@ -170,12 +170,12 @@ static hm_fragment *dtls1_hm_fragment_new(unsigned long frag_len,
     unsigned char *buf = NULL;
     unsigned char *bitmask = NULL;
 
-    frag = (hm_fragment *)OPENSSL_malloc(sizeof(hm_fragment));
+    frag = OPENSSL_malloc(sizeof(hm_fragment));
     if (frag == NULL)
         return NULL;
 
     if (frag_len) {
-        buf = (unsigned char *)OPENSSL_malloc(frag_len);
+        buf = OPENSSL_malloc(frag_len);
         if (buf == NULL) {
             OPENSSL_free(frag);
             return NULL;
@@ -187,8 +187,7 @@ static hm_fragment *dtls1_hm_fragment_new(unsigned long frag_len,
 
     /* Initialize reassembly bitmask if necessary */
     if (reassembly) {
-        bitmask =
-            (unsigned char *)OPENSSL_malloc(RSMBLY_BITMASK_SIZE(frag_len));
+        bitmask = OPENSSL_malloc(RSMBLY_BITMASK_SIZE(frag_len));
         if (bitmask == NULL) {
             if (buf != NULL)
                 OPENSSL_free(buf);
diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c
index d6401b4..4daa296 100644
--- a/ssl/ssl_cert.c
+++ b/ssl/ssl_cert.c
@@ -184,7 +184,7 @@ CERT *ssl_cert_new(void)
 {
     CERT *ret;
 
-    ret = (CERT *)OPENSSL_malloc(sizeof(CERT));
+    ret = OPENSSL_malloc(sizeof(CERT));
     if (ret == NULL) {
         SSLerr(SSL_F_SSL_CERT_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
@@ -205,7 +205,7 @@ CERT *ssl_cert_dup(CERT *cert)
     CERT *ret;
     int i;
 
-    ret = (CERT *)OPENSSL_malloc(sizeof(CERT));
+    ret = OPENSSL_malloc(sizeof(CERT));
     if (ret == NULL) {
         SSLerr(SSL_F_SSL_CERT_DUP, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c
index 580098a..14decbc 100644
--- a/ssl/ssl_ciph.c
+++ b/ssl/ssl_ciph.c
@@ -499,7 +499,7 @@ static void load_builtin_compressions(void)
             MemCheck_off();
             ssl_comp_methods = sk_SSL_COMP_new(sk_comp_cmp);
             if (ssl_comp_methods != NULL) {
-                comp = (SSL_COMP *)OPENSSL_malloc(sizeof(SSL_COMP));
+                comp = OPENSSL_malloc(sizeof(SSL_COMP));
                 if (comp != NULL) {
                     comp->method = COMP_zlib();
                     if (comp->method && comp->method->type == NID_undef)
@@ -1452,8 +1452,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, STACK
     fprintf(stderr, "ssl_create_cipher_list() for %d ciphers\n",
             num_of_ciphers);
 #endif                          /* KSSL_DEBUG */
-    co_list =
-        (CIPHER_ORDER *)OPENSSL_malloc(sizeof(CIPHER_ORDER) * num_of_ciphers);
+    co_list = OPENSSL_malloc(sizeof(CIPHER_ORDER) * num_of_ciphers);
     if (co_list == NULL) {
         SSLerr(SSL_F_SSL_CREATE_CIPHER_LIST, ERR_R_MALLOC_FAILURE);
         return (NULL);          /* Failure */
@@ -1935,7 +1934,7 @@ int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm)
     }
 
     MemCheck_off();
-    comp = (SSL_COMP *)OPENSSL_malloc(sizeof(SSL_COMP));
+    comp = OPENSSL_malloc(sizeof(SSL_COMP));
     if (comp == NULL) {
         MemCheck_on();
         SSLerr(SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD, ERR_R_MALLOC_FAILURE);
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 35a3c9d..73eafdb 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -276,7 +276,7 @@ SSL *SSL_new(SSL_CTX *ctx)
         return (NULL);
     }
 
-    s = (SSL *)OPENSSL_malloc(sizeof(SSL));
+    s = OPENSSL_malloc(sizeof(SSL));
     if (s == NULL)
         goto err;
     memset(s, 0, sizeof(SSL));
@@ -1868,7 +1868,7 @@ SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth)
         SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_X509_VERIFICATION_SETUP_PROBLEMS);
         goto err;
     }
-    ret = (SSL_CTX *)OPENSSL_malloc(sizeof(SSL_CTX));
+    ret = OPENSSL_malloc(sizeof(SSL_CTX));
     if (ret == NULL)
         goto err;
 
diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c
index 483c778..51f30fb 100644
--- a/ssl/ssl_sess.c
+++ b/ssl/ssl_sess.c
@@ -193,7 +193,7 @@ SSL_SESSION *SSL_SESSION_new(void)
 {
     SSL_SESSION *ss;
 
-    ss = (SSL_SESSION *)OPENSSL_malloc(sizeof(SSL_SESSION));
+    ss = OPENSSL_malloc(sizeof(SSL_SESSION));
     if (ss == NULL) {
         SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);
         return (0);
@@ -786,7 +786,7 @@ int SSL_set_session(SSL *s, SSL_SESSION *session)
         if (s->kssl_ctx && !s->kssl_ctx->client_princ &&
             session->krb5_client_princ_len > 0) {
             s->kssl_ctx->client_princ =
-                (char *)OPENSSL_malloc(session->krb5_client_princ_len + 1);
+                OPENSSL_malloc(session->krb5_client_princ_len + 1);
             if (s->kssl_ctx->client_princ == NULL) {
                 SSLerr(SSL_F_SSL_SET_SESSION, ERR_R_MALLOC_FAILURE);
                 return (0);
diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c
index 6e926d4..1f58ed0 100644
--- a/ssl/t1_enc.c
+++ b/ssl/t1_enc.c
@@ -649,7 +649,7 @@ int tls1_setup_key_block(SSL *s)
 
     ssl3_cleanup_key_block(s);
 
-    if ((p1 = (unsigned char *)OPENSSL_malloc(num)) == NULL) {
+    if ((p1 = OPENSSL_malloc(num)) == NULL) {
         SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK, ERR_R_MALLOC_FAILURE);
         goto err;
     }
@@ -657,7 +657,7 @@ int tls1_setup_key_block(SSL *s)
     s->s3->tmp.key_block_length = num;
     s->s3->tmp.key_block = p1;
 
-    if ((p2 = (unsigned char *)OPENSSL_malloc(num)) == NULL) {
+    if ((p2 = OPENSSL_malloc(num)) == NULL) {
         SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK, ERR_R_MALLOC_FAILURE);
         OPENSSL_free(p1);
         goto err;
diff --git a/test/dhtest.c b/test/dhtest.c
index 6c063da..35bd298 100644
--- a/test/dhtest.c
+++ b/test/dhtest.c
@@ -165,7 +165,7 @@ int main(int argc, char *argv[])
     BIO_puts(out, "\n");
 
     alen = DH_size(a);
-    abuf = (unsigned char *)OPENSSL_malloc(alen);
+    abuf = OPENSSL_malloc(alen);
     aout = DH_compute_key(abuf, b->pub_key, a);
 
     BIO_puts(out, "key1 =");
@@ -176,7 +176,7 @@ int main(int argc, char *argv[])
     BIO_puts(out, "\n");
 
     blen = DH_size(b);
-    bbuf = (unsigned char *)OPENSSL_malloc(blen);
+    bbuf = OPENSSL_malloc(blen);
     bout = DH_compute_key(bbuf, a->pub_key, b);
 
     BIO_puts(out, "key2 =");
diff --git a/test/ecdhtest.c b/test/ecdhtest.c
index a89177e..5c451e5 100644
--- a/test/ecdhtest.c
+++ b/test/ecdhtest.c
@@ -201,7 +201,7 @@ static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out)
 # endif
 
     alen = KDF1_SHA1_len;
-    abuf = (unsigned char *)OPENSSL_malloc(alen);
+    abuf = OPENSSL_malloc(alen);
     aout =
         ECDH_compute_key(abuf, alen, EC_KEY_get0_public_key(b), a, KDF1_SHA1);
 
@@ -218,7 +218,7 @@ static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out)
 # endif
 
     blen = KDF1_SHA1_len;
-    bbuf = (unsigned char *)OPENSSL_malloc(blen);
+    bbuf = OPENSSL_malloc(blen);
     bout =
         ECDH_compute_key(bbuf, blen, EC_KEY_get0_public_key(a), b, KDF1_SHA1);
 


More information about the openssl-commits mailing list