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 /apps | |
parent | 3e47caff4830d2a117eda15b57a5feab89b846ae (diff) | |
download | openssl-b196e7d936fb377d9c5b305748ac25ff0e53ef6d.tar.gz |
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 'apps')
-rw-r--r-- | apps/apps.c | 7 | ||||
-rw-r--r-- | apps/ca.c | 21 | ||||
-rw-r--r-- | apps/dgst.c | 2 | ||||
-rw-r--r-- | apps/dhparam.c | 2 | ||||
-rw-r--r-- | apps/dsaparam.c | 2 | ||||
-rw-r--r-- | apps/ecparam.c | 3 | ||||
-rw-r--r-- | apps/enc.c | 2 | ||||
-rw-r--r-- | apps/rsa.c | 2 | ||||
-rw-r--r-- | apps/s_client.c | 2 | ||||
-rw-r--r-- | apps/s_server.c | 4 | ||||
-rw-r--r-- | apps/s_socket.c | 2 | ||||
-rw-r--r-- | apps/speed.c | 6 | ||||
-rw-r--r-- | apps/srp.c | 3 | ||||
-rw-r--r-- | apps/vms_decc_init.c | 2 |
14 files changed, 26 insertions, 34 deletions
diff --git a/apps/apps.c b/apps/apps.c index 462e2b650c..66e37962a6 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); @@ -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 adfa2a63ba..106e939fbf 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 6e51c0b82e..e7fa7ae26f 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 f7365b92d0..5aa6e2ccfc 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 049fc78092..f316793cd3 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 61a64d4469..794fce1f3d 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 8e93dd2f97..c8b05e60ce 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 431a1069d7..9181c759b8 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 e12db0c866..fb6fd3dbf7 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 4c440dc50a..050426a0a4 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 57587053cc..7dfdda8bf5 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 c62d55de2b..0acbb8ac85 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 3c953aa361..1717dae37e 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]; |