Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorBrian Smith <brian@briansmith.org>2016-02-07 22:36:04 +0300
committerDavid Benjamin <davidben@google.com>2016-02-12 01:07:56 +0300
commit5ba06897be4fb001113f6e8ea2398538dbbb88f2 (patch)
treef880255fcbb4de630e0827e02ae741d155b9b5c9 /crypto
parent46a4d6d7051775589180e46b3974b2c94dc9f2d7 (diff)
Don't cast |OPENSSL_malloc|/|OPENSSL_realloc| result.
C has implicit conversion of |void *| to other pointer types so these casts are unnecessary. Clean them up to make the code easier to read and to make it easier to find dangerous casts. Change-Id: I26988a672e8ed4d69c75cfbb284413999b475464 Reviewed-on: https://boringssl-review.googlesource.com/7102 Reviewed-by: David Benjamin <davidben@google.com>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/bio/buffer.c6
-rw-r--r--crypto/bn/bn.c2
-rw-r--r--crypto/bn/convert.c7
-rw-r--r--crypto/bn/exponentiation.c2
-rw-r--r--crypto/dh/dh.c2
-rw-r--r--crypto/dsa/dsa.c2
-rw-r--r--crypto/ec/ec_key.c2
-rw-r--r--crypto/evp/p_dsa_asn1.c2
-rw-r--r--crypto/evp/p_ec_asn1.c2
-rw-r--r--crypto/evp/p_rsa_asn1.c2
-rw-r--r--crypto/modes/gcm.c2
-rw-r--r--crypto/rsa/rsa.c2
12 files changed, 16 insertions, 17 deletions
diff --git a/crypto/bio/buffer.c b/crypto/bio/buffer.c
index 9d0cb3c0..15574510 100644
--- a/crypto/bio/buffer.c
+++ b/crypto/bio/buffer.c
@@ -100,7 +100,7 @@ static int buffer_new(BIO *bio) {
if (ctx->ibuf == NULL) {
goto err1;
}
- ctx->obuf = (char *)OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
+ ctx->obuf = OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
if (ctx->obuf == NULL) {
goto err2;
}
@@ -340,13 +340,13 @@ 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(ibs);
+ p1 = OPENSSL_malloc(ibs);
if (p1 == NULL) {
goto malloc_error;
}
}
if (obs > DEFAULT_BUFFER_SIZE && obs != ctx->obuf_size) {
- p2 = (char *)OPENSSL_malloc(obs);
+ p2 = OPENSSL_malloc(obs);
if (p2 == NULL) {
if (p1 != ctx->ibuf) {
OPENSSL_free(p1);
diff --git a/crypto/bn/bn.c b/crypto/bn/bn.c
index 543c1482..2263701f 100644
--- a/crypto/bn/bn.c
+++ b/crypto/bn/bn.c
@@ -295,7 +295,7 @@ BIGNUM *bn_wexpand(BIGNUM *bn, size_t words) {
return NULL;
}
- a = (BN_ULONG *)OPENSSL_malloc(sizeof(BN_ULONG) * words);
+ a = OPENSSL_malloc(sizeof(BN_ULONG) * words);
if (a == NULL) {
OPENSSL_PUT_ERROR(BN, ERR_R_MALLOC_FAILURE);
return NULL;
diff --git a/crypto/bn/convert.c b/crypto/bn/convert.c
index 1f7af64b..542f523f 100644
--- a/crypto/bn/convert.c
+++ b/crypto/bn/convert.c
@@ -208,7 +208,7 @@ char *BN_bn2hex(const BIGNUM *bn) {
char *buf;
char *p;
- buf = (char *)OPENSSL_malloc(bn->top * BN_BYTES * 2 + 2);
+ buf = OPENSSL_malloc(bn->top * BN_BYTES * 2 + 2);
if (buf == NULL) {
OPENSSL_PUT_ERROR(BN, ERR_R_MALLOC_FAILURE);
return NULL;
@@ -385,9 +385,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)) {
OPENSSL_PUT_ERROR(BN, ERR_R_MALLOC_FAILURE);
goto err;
diff --git a/crypto/bn/exponentiation.c b/crypto/bn/exponentiation.c
index 72a8db4b..f7100ac3 100644
--- a/crypto/bn/exponentiation.c
+++ b/crypto/bn/exponentiation.c
@@ -954,7 +954,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
} else
#endif
{
- if ((powerbufFree = (unsigned char *)OPENSSL_malloc(
+ if ((powerbufFree = OPENSSL_malloc(
powerbufLen + MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) == NULL) {
goto err;
}
diff --git a/crypto/dh/dh.c b/crypto/dh/dh.c
index bf6196ce..aed8720b 100644
--- a/crypto/dh/dh.c
+++ b/crypto/dh/dh.c
@@ -74,7 +74,7 @@
static CRYPTO_EX_DATA_CLASS g_ex_data_class = CRYPTO_EX_DATA_CLASS_INIT;
DH *DH_new(void) {
- DH *dh = (DH *)OPENSSL_malloc(sizeof(DH));
+ DH *dh = OPENSSL_malloc(sizeof(DH));
if (dh == NULL) {
OPENSSL_PUT_ERROR(DH, ERR_R_MALLOC_FAILURE);
return NULL;
diff --git a/crypto/dsa/dsa.c b/crypto/dsa/dsa.c
index ebe55e84..1e446920 100644
--- a/crypto/dsa/dsa.c
+++ b/crypto/dsa/dsa.c
@@ -86,7 +86,7 @@
static CRYPTO_EX_DATA_CLASS g_ex_data_class = CRYPTO_EX_DATA_CLASS_INIT;
DSA *DSA_new(void) {
- DSA *dsa = (DSA *)OPENSSL_malloc(sizeof(DSA));
+ DSA *dsa = OPENSSL_malloc(sizeof(DSA));
if (dsa == NULL) {
OPENSSL_PUT_ERROR(DSA, ERR_R_MALLOC_FAILURE);
return NULL;
diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c
index d3bf4c61..5b015f50 100644
--- a/crypto/ec/ec_key.c
+++ b/crypto/ec/ec_key.c
@@ -85,7 +85,7 @@ static CRYPTO_EX_DATA_CLASS g_ex_data_class = CRYPTO_EX_DATA_CLASS_INIT;
EC_KEY *EC_KEY_new(void) { return EC_KEY_new_method(NULL); }
EC_KEY *EC_KEY_new_method(const ENGINE *engine) {
- EC_KEY *ret = (EC_KEY *)OPENSSL_malloc(sizeof(EC_KEY));
+ EC_KEY *ret = OPENSSL_malloc(sizeof(EC_KEY));
if (ret == NULL) {
OPENSSL_PUT_ERROR(EC, ERR_R_MALLOC_FAILURE);
return NULL;
diff --git a/crypto/evp/p_dsa_asn1.c b/crypto/evp/p_dsa_asn1.c
index ea75e58c..a876eef4 100644
--- a/crypto/evp/p_dsa_asn1.c
+++ b/crypto/evp/p_dsa_asn1.c
@@ -436,7 +436,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 = (uint8_t *)OPENSSL_malloc(buf_len + 10);
+ m = OPENSSL_malloc(buf_len + 10);
if (m == NULL) {
OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE);
goto err;
diff --git a/crypto/evp/p_ec_asn1.c b/crypto/evp/p_ec_asn1.c
index e12508db..e093c183 100644
--- a/crypto/evp/p_ec_asn1.c
+++ b/crypto/evp/p_ec_asn1.c
@@ -279,7 +279,7 @@ static int eckey_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) {
OPENSSL_PUT_ERROR(EVP, ERR_R_EC_LIB);
return 0;
}
- ep = (uint8_t *)OPENSSL_malloc(eplen);
+ ep = OPENSSL_malloc(eplen);
if (!ep) {
EC_KEY_set_enc_flags(ec_key, old_flags);
OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE);
diff --git a/crypto/evp/p_rsa_asn1.c b/crypto/evp/p_rsa_asn1.c
index 8556b5ad..70f0b763 100644
--- a/crypto/evp/p_rsa_asn1.c
+++ b/crypto/evp/p_rsa_asn1.c
@@ -216,7 +216,7 @@ static int do_rsa_print(BIO *out, const RSA *rsa, int off,
}
}
- m = (uint8_t *)OPENSSL_malloc(buf_len + 10);
+ m = OPENSSL_malloc(buf_len + 10);
if (m == NULL) {
OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE);
goto err;
diff --git a/crypto/modes/gcm.c b/crypto/modes/gcm.c
index 65451a6c..2519b19f 100644
--- a/crypto/modes/gcm.c
+++ b/crypto/modes/gcm.c
@@ -408,7 +408,7 @@ void gcm_ghash_neon(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp,
GCM128_CONTEXT *CRYPTO_gcm128_new(const void *key, block128_f block) {
GCM128_CONTEXT *ret;
- ret = (GCM128_CONTEXT *)OPENSSL_malloc(sizeof(GCM128_CONTEXT));
+ ret = OPENSSL_malloc(sizeof(GCM128_CONTEXT));
if (ret != NULL) {
CRYPTO_gcm128_init(ret, key, block);
}
diff --git a/crypto/rsa/rsa.c b/crypto/rsa/rsa.c
index 6c28ad76..9ffea1f2 100644
--- a/crypto/rsa/rsa.c
+++ b/crypto/rsa/rsa.c
@@ -76,7 +76,7 @@ static CRYPTO_EX_DATA_CLASS g_ex_data_class = CRYPTO_EX_DATA_CLASS_INIT;
RSA *RSA_new(void) { return RSA_new_method(NULL); }
RSA *RSA_new_method(const ENGINE *engine) {
- RSA *rsa = (RSA *)OPENSSL_malloc(sizeof(RSA));
+ RSA *rsa = OPENSSL_malloc(sizeof(RSA));
if (rsa == NULL) {
OPENSSL_PUT_ERROR(RSA, ERR_R_MALLOC_FAILURE);
return NULL;