free NULL cleanup.
[openssl.git] / crypto / ecdh / ecdhtest.c
index 04b0cf30d09bd3c9cc26266ae61965ca8f9af9c0..a89177e4353c519daed7604a99d5b9b5e66076aa 100644 (file)
@@ -73,7 +73,7 @@
 
 #include "../e_os.h"
 
-#include <openssl/opensslconf.h> /* for OPENSSL_NO_ECDH */
+#include <openssl/opensslconf.h> /* for OPENSSL_NO_EC */
 #include <openssl/crypto.h>
 #include <openssl/bio.h>
 #include <openssl/bn.h>
@@ -82,7 +82,7 @@
 #include <openssl/sha.h>
 #include <openssl/err.h>
 
-#ifdef OPENSSL_NO_ECDH
+#ifdef OPENSSL_NO_EC
 int main(int argc, char *argv[])
 {
     printf("No ECDH support\n");
@@ -92,10 +92,6 @@ int main(int argc, char *argv[])
 # include <openssl/ec.h>
 # include <openssl/ecdh.h>
 
-# if 0
-static void cb(int p, int n, void *arg);
-# endif
-
 static const char rnd_seed[] =
     "string to make the random number generator think it has entropy";
 
@@ -294,10 +290,8 @@ static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out)
         BN_free(x_b);
     if (y_b)
         BN_free(y_b);
-    if (b)
-        EC_KEY_free(b);
-    if (a)
-        EC_KEY_free(a);
+    EC_KEY_free(b);
+    EC_KEY_free(a);
     return (ret);
 }
 
@@ -398,12 +392,10 @@ static EC_KEY *mk_eckey(int nid, const unsigned char *p, size_t plen)
  err:
     if (priv)
         BN_clear_free(priv);
-    if (pub)
-        EC_POINT_free(pub);
+    EC_POINT_free(pub);
     if (ok)
         return k;
-    else if (k)
-        EC_KEY_free(k);
+    EC_KEY_free(k);
     return NULL;
 }
 
@@ -444,10 +436,8 @@ static int ecdh_kat(BIO *out, const char *cname, int nid,
         goto err;
     rv = 1;
  err:
-    if (key1)
-        EC_KEY_free(key1);
-    if (key2)
-        EC_KEY_free(key2);
+    EC_KEY_free(key1);
+    EC_KEY_free(key2);
     if (Ztmp)
         OPENSSL_free(Ztmp);
     if (rv)
@@ -543,24 +533,5 @@ int main(int argc, char *argv[])
     ERR_remove_thread_state(NULL);
     CRYPTO_mem_leaks_fp(stderr);
     EXIT(ret);
-    return (ret);
 }
-
-# if 0
-static void cb(int p, int n, void *arg)
-{
-    char c = '*';
-
-    if (p == 0)
-        c = '.';
-    if (p == 1)
-        c = '+';
-    if (p == 2)
-        c = '*';
-    if (p == 3)
-        c = '\n';
-    BIO_write((BIO *)arg, &c, 1);
-    (void)BIO_flush((BIO *)arg);
-}
-# endif
 #endif