GH365: Missing #ifdef rename.
[openssl.git] / engines / e_cswift.c
index db94bf2a64ab9af32e2292d3085f5a0c503ea93e..5553794998d2d29e36f30eefe9bac7f1cd465033 100644 (file)
@@ -338,8 +338,7 @@ static const char *get_CSWIFT_LIBNAME(void)
 
 static void free_CSWIFT_LIBNAME(void)
 {
-    if (CSWIFT_LIBNAME)
-        OPENSSL_free((void *)CSWIFT_LIBNAME);
+    OPENSSL_free(CSWIFT_LIBNAME);
     CSWIFT_LIBNAME = NULL;
 }
 
@@ -405,14 +404,12 @@ static int cswift_init(ENGINE *e)
         CSWIFTerr(CSWIFT_F_CSWIFT_INIT, CSWIFT_R_NOT_LOADED);
         goto err;
     }
-    if (!(p1 = (t_swAcquireAccContext *)
-          DSO_bind_func(cswift_dso, CSWIFT_F1)) ||
-        !(p2 = (t_swAttachKeyParam *)
-          DSO_bind_func(cswift_dso, CSWIFT_F2)) ||
-        !(p3 = (t_swSimpleRequest *)
-          DSO_bind_func(cswift_dso, CSWIFT_F3)) ||
-        !(p4 = (t_swReleaseAccContext *)
-          DSO_bind_func(cswift_dso, CSWIFT_F4))) {
+
+#define BINDIT(t, name) (t *)DSO_bind_func(cswift_dso, name)
+    if ((p1 = BINDIT(t_swAcquireAccContext, CSWIFT_F1)) == NULL
+        || (p2 = BINDIT(t_swAttachKeyParam, CSWIFT_F2)) == NULL
+        || (p3 = BINDIT(t_swSimpleRequest *) DSO_bind_func(cswift_dso, CSWIFT_F3)) == NULL
+        || (p4 = BINDIT(t_swReleaseAccContext *) DSO_bind_func(cswift_dso, CSWIFT_F4)) == NULL) {
         CSWIFTerr(CSWIFT_F_CSWIFT_INIT, CSWIFT_R_NOT_LOADED);
         goto err;
     }
@@ -432,10 +429,8 @@ static int cswift_init(ENGINE *e)
     /* Everything's fine. */
     return 1;
  err:
-    if (cswift_dso) {
-        DSO_free(cswift_dso);
-        cswift_dso = NULL;
-    }
+    DSO_free(cswift_dso);
+    cswift_dso = NULL;
     p_CSwift_AcquireAccContext = NULL;
     p_CSwift_AttachKeyParam = NULL;
     p_CSwift_SimpleRequest = NULL;
@@ -586,7 +581,7 @@ int cswift_bn_32copy(SW_LARGENUMBER *out, const BIGNUM *in)
     while (((out->nbytes = (numbytes + mod)) % 32)) {
         mod++;
     }
-    out->value = (unsigned char *)OPENSSL_malloc(out->nbytes);
+    out->value = OPENSSL_malloc(out->nbytes);
     if (!out->value) {
         return 0;
     }
@@ -707,20 +702,13 @@ static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
     BN_bin2bn((unsigned char *)result->d, res.nbytes, r);
     to_return = 1;
  err:
-    if (sw_param.up.crt.p.value)
-        OPENSSL_free(sw_param.up.crt.p.value);
-    if (sw_param.up.crt.q.value)
-        OPENSSL_free(sw_param.up.crt.q.value);
-    if (sw_param.up.crt.dmp1.value)
-        OPENSSL_free(sw_param.up.crt.dmp1.value);
-    if (sw_param.up.crt.dmq1.value)
-        OPENSSL_free(sw_param.up.crt.dmq1.value);
-    if (sw_param.up.crt.iqmp.value)
-        OPENSSL_free(sw_param.up.crt.iqmp.value);
-    if (result)
-        BN_free(result);
-    if (argument)
-        BN_free(argument);
+    OPENSSL_free(sw_param.up.crt.p.value);
+    OPENSSL_free(sw_param.up.crt.q.value);
+    OPENSSL_free(sw_param.up.crt.dmp1.value);
+    OPENSSL_free(sw_param.up.crt.dmq1.value);
+    OPENSSL_free(sw_param.up.crt.iqmp.value);
+    BN_free(result);
+    BN_free(argument);
     if (acquired)
         release_context(hac);
     return to_return;
@@ -877,10 +865,9 @@ static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa)
  err:
     if (acquired)
         release_context(hac);
-    if (ctx) {
+    if (ctx)
         BN_CTX_end(ctx);
-        BN_CTX_free(ctx);
-    }
+    BN_CTX_free(ctx);
     return to_return;
 }
 
@@ -980,10 +967,9 @@ static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len,
  err:
     if (acquired)
         release_context(hac);
-    if (ctx) {
+    if (ctx)
         BN_CTX_end(ctx);
-        BN_CTX_free(ctx);
-    }
+    BN_CTX_free(ctx);
     return to_return;
 }
 #  endif