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
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2015-04-22 20:50:28 +0300
committerAdam Langley <agl@google.com>2015-05-05 02:05:17 +0300
commit22ccc2d8f1e0a3d19b98324d502322db8d89624f (patch)
tree634d6618b5a8d25cbddb5e080840f09a58657027 /crypto/dsa
parentde95d262ab448f8582b8192c3a94e9c10acdb771 (diff)
Remove unnecessary NULL checks, part 1.
First batch of the alphabet. Change-Id: If4e60f4fbb69e04eb4b70aa1b2240e329251bfa5 Reviewed-on: https://boringssl-review.googlesource.com/4514 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/dsa')
-rw-r--r--crypto/dsa/dsa.c48
-rw-r--r--crypto/dsa/dsa_impl.c45
-rw-r--r--crypto/dsa/dsa_test.c8
3 files changed, 26 insertions, 75 deletions
diff --git a/crypto/dsa/dsa.c b/crypto/dsa/dsa.c
index 78e41549..e8e3d732 100644
--- a/crypto/dsa/dsa.c
+++ b/crypto/dsa/dsa.c
@@ -134,27 +134,13 @@ void DSA_free(DSA *dsa) {
CRYPTO_free_ex_data(&g_ex_data_class, dsa, &dsa->ex_data);
- if (dsa->p != NULL) {
- BN_clear_free(dsa->p);
- }
- if (dsa->q != NULL) {
- BN_clear_free(dsa->q);
- }
- if (dsa->g != NULL) {
- BN_clear_free(dsa->g);
- }
- if (dsa->pub_key != NULL) {
- BN_clear_free(dsa->pub_key);
- }
- if (dsa->priv_key != NULL) {
- BN_clear_free(dsa->priv_key);
- }
- if (dsa->kinv != NULL) {
- BN_clear_free(dsa->kinv);
- }
- if (dsa->r != NULL) {
- BN_clear_free(dsa->r);
- }
+ BN_clear_free(dsa->p);
+ BN_clear_free(dsa->q);
+ BN_clear_free(dsa->g);
+ BN_clear_free(dsa->pub_key);
+ BN_clear_free(dsa->priv_key);
+ BN_clear_free(dsa->kinv);
+ BN_clear_free(dsa->r);
CRYPTO_MUTEX_cleanup(&dsa->method_mont_p_lock);
OPENSSL_free(dsa);
}
@@ -198,12 +184,8 @@ void DSA_SIG_free(DSA_SIG *sig) {
return;
}
- if (sig->r) {
- BN_free(sig->r);
- }
- if (sig->s) {
- BN_free(sig->s);
- }
+ BN_free(sig->r);
+ BN_free(sig->s);
OPENSSL_free(sig);
}
@@ -282,12 +264,8 @@ int DSA_check_signature(int *out_valid, const uint8_t *digest,
ret = DSA_do_check_signature(out_valid, digest, digest_len, s, dsa);
err:
- if (der != NULL) {
- OPENSSL_free(der);
- }
- if (s) {
- DSA_SIG_free(s);
- }
+ OPENSSL_free(der);
+ DSA_SIG_free(s);
return ret;
}
@@ -365,8 +343,6 @@ DH *DSA_dup_DH(const DSA *r) {
return ret;
err:
- if (ret != NULL) {
- DH_free(ret);
- }
+ DH_free(ret);
return NULL;
}
diff --git a/crypto/dsa/dsa_impl.c b/crypto/dsa/dsa_impl.c
index c4df80bd..b7e1fd82 100644
--- a/crypto/dsa/dsa_impl.c
+++ b/crypto/dsa/dsa_impl.c
@@ -162,14 +162,10 @@ static int sign_setup(const DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
goto err;
}
- if (*kinvp != NULL) {
- BN_clear_free(*kinvp);
- }
+ BN_clear_free(*kinvp);
*kinvp = kinv;
kinv = NULL;
- if (*rp != NULL) {
- BN_clear_free(*rp);
- }
+ BN_clear_free(*rp);
*rp = r;
ret = 1;
@@ -277,15 +273,10 @@ err:
BN_free(r);
BN_free(s);
}
- if (ctx != NULL) {
- BN_CTX_free(ctx);
- }
+ BN_CTX_free(ctx);
BN_clear_free(&m);
BN_clear_free(&xr);
- if (kinv != NULL) {
- /* dsa->kinv is NULL now if we used it */
- BN_clear_free(kinv);
- }
+ BN_clear_free(kinv);
return ret;
}
@@ -392,9 +383,7 @@ err:
if (ret != 1) {
OPENSSL_PUT_ERROR(DSA, verify, ERR_R_BN_LIB);
}
- if (ctx != NULL) {
- BN_CTX_free(ctx);
- }
+ BN_CTX_free(ctx);
BN_free(&u1);
BN_free(&u2);
BN_free(&t1);
@@ -447,15 +436,13 @@ static int keygen(DSA *dsa) {
ok = 1;
err:
- if (pub_key != NULL && dsa->pub_key == NULL) {
+ if (dsa->pub_key == NULL) {
BN_free(pub_key);
}
- if (priv_key != NULL && dsa->priv_key == NULL) {
+ if (dsa->priv_key == NULL) {
BN_free(priv_key);
}
- if (ctx != NULL) {
- BN_CTX_free(ctx);
- }
+ BN_CTX_free(ctx);
return ok;
}
@@ -706,15 +693,9 @@ end:
err:
if (ok) {
- if (ret->p) {
- BN_free(ret->p);
- }
- if (ret->q) {
- BN_free(ret->q);
- }
- if (ret->g) {
- BN_free(ret->g);
- }
+ BN_free(ret->p);
+ BN_free(ret->q);
+ BN_free(ret->g);
ret->p = BN_dup(p);
ret->q = BN_dup(q);
ret->g = BN_dup(g);
@@ -735,9 +716,7 @@ err:
BN_CTX_free(ctx);
}
- if (mont != NULL) {
- BN_MONT_CTX_free(mont);
- }
+ BN_MONT_CTX_free(mont);
return ok;
}
diff --git a/crypto/dsa/dsa_test.c b/crypto/dsa/dsa_test.c
index 83ecf25d..9b70dbee 100644
--- a/crypto/dsa/dsa_test.c
+++ b/crypto/dsa/dsa_test.c
@@ -247,9 +247,7 @@ static int test_generate(FILE *out) {
}
end:
- if (dsa != NULL) {
- DSA_free(dsa);
- }
+ DSA_free(dsa);
return ok;
}
@@ -271,9 +269,7 @@ static int test_verify(const uint8_t *sig, size_t sig_len, int expect) {
ERR_clear_error();
end:
- if (dsa != NULL) {
- DSA_free(dsa);
- }
+ DSA_free(dsa);
return ok;
}