]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Live code cleanup: remove #if 1 stuff
authorRich Salz <rsalz@openssl.org>
Fri, 6 Feb 2015 15:54:20 +0000 (10:54 -0500)
committerRich Salz <rsalz@openssl.org>
Fri, 6 Feb 2015 15:54:20 +0000 (10:54 -0500)
For code bracketed by "#if 1" then remove the alternate
"#else .. #endif" lines.

Reviewed-by: Andy Polyakov <appro@openssl.org>
apps/s_client.c
apps/s_server.c
apps/speed.c
apps/x509.c
crypto/bio/bf_nbio.c
crypto/conf/conf_def.c
crypto/ec/ec_mult.c
crypto/ec/ectest.c
crypto/rand/rand_win.c
engines/e_padlock.c

index 325dbf11b39dcb55dc6f6f327e4a5e005ef4296d..1607c6e4388fb91d03866751b2af77f592011756 100644 (file)
@@ -1872,17 +1872,7 @@ int MAIN(int argc, char **argv)
                 }
             }
 #endif
-#if 1
             k = SSL_read(con, sbuf, 1024 /* BUFSIZZ */ );
-#else
-/* Demo for pending and peek :-) */
-            k = SSL_read(con, sbuf, 16);
-            {
-                char zbuf[10240];
-                printf("read=%d pending=%d peek=%d\n", k, SSL_pending(con),
-                       SSL_peek(con, zbuf, 10240));
-            }
-#endif
 
             switch (SSL_get_error(con, k)) {
             case SSL_ERROR_NONE:
index 5537fdea0f73824d8b5a86a652b85e061698563e..573bc873bf8ab99c208a2965827eef9abd90c727 100644 (file)
@@ -1878,7 +1878,6 @@ int MAIN(int argc, char *argv[])
             goto end;
     }
 #ifndef OPENSSL_NO_RSA
-# if 1
     if (!no_tmp_rsa) {
         SSL_CTX_set_tmp_rsa_callback(ctx, tmp_rsa_cb);
 #  ifndef OPENSSL_NO_TLSEXT
@@ -1886,31 +1885,6 @@ int MAIN(int argc, char *argv[])
             SSL_CTX_set_tmp_rsa_callback(ctx2, tmp_rsa_cb);
 #  endif
     }
-# else
-    if (!no_tmp_rsa && SSL_CTX_need_tmp_RSA(ctx)) {
-        RSA *rsa;
-
-        BIO_printf(bio_s_out, "Generating temp (512 bit) RSA key...");
-        BIO_flush(bio_s_out);
-
-        rsa = RSA_generate_key(512, RSA_F4, NULL);
-
-        if (!SSL_CTX_set_tmp_rsa(ctx, rsa)) {
-            ERR_print_errors(bio_err);
-            goto end;
-        }
-#  ifndef OPENSSL_NO_TLSEXT
-        if (ctx2) {
-            if (!SSL_CTX_set_tmp_rsa(ctx2, rsa)) {
-                ERR_print_errors(bio_err);
-                goto end;
-            }
-        }
-#  endif
-        RSA_free(rsa);
-        BIO_printf(bio_s_out, "\n");
-    }
-# endif
 #endif
 
     if (no_resume_ephemeral) {
@@ -2488,11 +2462,7 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
  err:
     if (con != NULL) {
         BIO_printf(bio_s_out, "shutting down SSL\n");
-#if 1
         SSL_set_shutdown(con, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);
-#else
-        SSL_shutdown(con);
-#endif
         SSL_free(con);
     }
     BIO_printf(bio_s_out, "CONNECTION CLOSED\n");
@@ -3051,16 +3021,8 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context)
             break;
     }
  end:
-#if 1
     /* make sure we re-use sessions */
     SSL_set_shutdown(con, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);
-#else
-    /* This kills performance */
-    /*
-     * SSL_shutdown(con); A shutdown gets sent in the BIO_free_all(io)
-     * procession
-     */
-#endif
 
  err:
 
index 6ba7a2ece723aa0f075650c1ef406e2b2d26e838..ee9d2de7069c0a7673aa5416f3bca69db0df4523 100644 (file)
@@ -2028,7 +2028,6 @@ int MAIN(int argc, char **argv)
             rsa_count = count;
         }
 
-# if 1
         ret = RSA_verify(NID_md5_sha1, buf, 36, buf2, rsa_num, rsa_key[j]);
         if (ret <= 0) {
             BIO_printf(bio_err,
@@ -2056,7 +2055,6 @@ int MAIN(int argc, char **argv)
                        count, rsa_bits[j], d);
             rsa_results[j][1] = d / (double)count;
         }
-# endif
 
         if (rsa_count <= 1) {
             /* if longer than 10s, don't do any more */
@@ -2162,9 +2160,8 @@ int MAIN(int argc, char **argv)
             ERR_print_errors(bio_err);
             rsa_count = 1;
         } else {
-# if 1
             EC_KEY_precompute_mult(ecdsa[j], NULL);
-# endif
+
             /* Perform ECDSA signature test */
             EC_KEY_generate_key(ecdsa[j]);
             ret = ECDSA_sign(0, buf, 20, ecdsasig, &ecdsasiglen, ecdsa[j]);
index 4248bdb8fa010dd41f064ddde674f5c3b104599f..4b08c181ee9359221b8093e48fd5d6a46cef03d0 100644 (file)
@@ -469,13 +469,6 @@ int MAIN(int argc, char **argv)
             CA_createserial = ++num;
         else if (strcmp(*argv, "-clrext") == 0)
             clrext = 1;
-#if 1                           /* stay backwards-compatible with 0.9.5; this
-                                 * should go away soon */
-        else if (strcmp(*argv, "-crlext") == 0) {
-            BIO_printf(bio_err, "use -clrext instead of -crlext\n");
-            clrext = 1;
-        }
-#endif
         else if (strcmp(*argv, "-ocspid") == 0)
             ocspid = ++num;
         else if (strcmp(*argv, "-badsig") == 0)
index da88a8a1bfbdbb1eb12fda451aede4699bab02a5..3af58bd38f4cd7da4139de3e66a877d5e434dc2e 100644 (file)
@@ -127,10 +127,8 @@ static int nbiof_free(BIO *a)
 static int nbiof_read(BIO *b, char *out, int outl)
 {
     int ret = 0;
-#if 1
     int num;
     unsigned char n;
-#endif
 
     if (out == NULL)
         return (0);
@@ -138,7 +136,6 @@ static int nbiof_read(BIO *b, char *out, int outl)
         return (0);
 
     BIO_clear_retry_flags(b);
-#if 1
     RAND_pseudo_bytes(&n, 1);
     num = (n & 0x07);
 
@@ -148,9 +145,7 @@ static int nbiof_read(BIO *b, char *out, int outl)
     if (num == 0) {
         ret = -1;
         BIO_set_retry_read(b);
-    } else
-#endif
-    {
+    } else {
         ret = BIO_read(b->next_bio, out, outl);
         if (ret < 0)
             BIO_copy_next_retry(b);
@@ -173,7 +168,6 @@ static int nbiof_write(BIO *b, const char *in, int inl)
 
     BIO_clear_retry_flags(b);
 
-#if 1
     if (nt->lwn > 0) {
         num = nt->lwn;
         nt->lwn = 0;
@@ -188,9 +182,7 @@ static int nbiof_write(BIO *b, const char *in, int inl)
     if (num == 0) {
         ret = -1;
         BIO_set_retry_write(b);
-    } else
-#endif
-    {
+    } else {
         ret = BIO_write(b->next_bio, in, inl);
         if (ret < 0) {
             BIO_copy_next_retry(b);
index 5e226705edcff8d134d021a2ae1be804da44a4c5..59053e85bde5857721aa5661ebe864827a532549 100644 (file)
@@ -384,25 +384,10 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
                 }
             } else
                 tv = sv;
-#if 1
             if (_CONF_add_string(conf, tv, v) == 0) {
                 CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
                 goto err;
             }
-#else
-            v->section = tv->section;
-            if (!sk_CONF_VALUE_push(ts, v)) {
-                CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
-                goto err;
-            }
-            vv = (CONF_VALUE *)lh_insert(conf->data, v);
-            if (vv != NULL) {
-                sk_CONF_VALUE_delete_ptr(ts, vv);
-                OPENSSL_free(vv->name);
-                OPENSSL_free(vv->value);
-                OPENSSL_free(vv);
-            }
-#endif
             v = NULL;
         }
     }
index fe87c418aab6a21932f379ece0b079b44b5e4300..16b37db671c8d46cd1c8473b93081df6487d17cb 100644 (file)
@@ -496,11 +496,8 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
         }
     }
 
-#if 1                           /* optional; EC_window_bits_for_scalar_size
-                                 * assumes we do this step */
     if (!EC_POINTs_make_affine(group, num_val, val, ctx))
         goto err;
-#endif
 
     r_is_at_infinity = 1;
 
index fc04f3b3e1580060e9fa77581f06f5aaa97cb6f0..2290c8e24191aa97fd8920cc08331db9dd893f4a 100644 (file)
@@ -239,11 +239,9 @@ static void prime_field_tests(void)
     size_t i, len;
     int k;
 
-# if 1                          /* optional */
     ctx = BN_CTX_new();
     if (!ctx)
         ABORT;
-# endif
 
     p = BN_new();
     a = BN_new();
@@ -945,11 +943,9 @@ static void char2_field_tests(void)
     size_t i, len;
     int k;
 
-#  if 1                         /* optional */
     ctx = BN_CTX_new();
     if (!ctx)
         ABORT;
-#  endif
 
     p = BN_new();
     a = BN_new();
index eeb5e9cda6d18711e18326674bbc87573cd392e4..1de39bb2ec592a105f668a8daa6caafca0c91af2 100644 (file)
@@ -182,7 +182,6 @@ typedef BOOL(WINAPI *MODULE32) (HANDLE, LPMODULEENTRY32);
 
 #  include <lmcons.h>
 #  include <lmstats.h>
-#  if 1
 /*
  * The NET API is Unicode only.  It requires the use of the UNICODE macro.
  * When UNICODE is defined LPTSTR becomes LPWSTR.  LMSTR was was added to the
@@ -193,7 +192,6 @@ typedef BOOL(WINAPI *MODULE32) (HANDLE, LPMODULEENTRY32);
 typedef NET_API_STATUS(NET_API_FUNCTION *NETSTATGET)
  (LPWSTR, LPWSTR, DWORD, DWORD, LPBYTE *);
 typedef NET_API_STATUS(NET_API_FUNCTION *NETFREE) (LPBYTE);
-#  endif                        /* 1 */
 # endif                         /* !OPENSSL_SYS_WINCE */
 
 int RAND_poll(void)
index 85f393834155063fb4756f9b3019a8e9e634e76b..9acca7d9184f53c472c3824a844ec6a310dbf147 100644 (file)
@@ -159,10 +159,11 @@ static int padlock_bind_helper(ENGINE *e)
     /* Check available features */
     padlock_available();
 
-#   if 1                        /* disable RNG for now, see commentary in
-                                 * vicinity of RNG code */
+    /*
+     * RNG is currently disabled for reasons discussed in commentary just
+     * before padlock_rand_bytes function.
+     */
     padlock_use_rng = 0;
-#   endif
 
     /* Generate a nice engine name with available features */
     BIO_snprintf(padlock_name, sizeof(padlock_name),