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 | |
parent | 3e47caff4830d2a117eda15b57a5feab89b846ae (diff) |
remove malloc casts
Following ANSI C rules, remove the casts from calls to
OPENSSL_malloc and OPENSSL_realloc.
Reviewed-by: Richard Levitte <levitte@openssl.org>
114 files changed, 191 insertions, 226 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 61a64d44 |