From 06cf881a3a10d5af3c1255c08cfd0c6ddb5f1cc3 Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Sun, 8 Feb 2015 18:48:09 -0500 Subject: [PATCH] Final (for me, for now) dead code cleanup This is a final pass looking for '#if 0'/'#if 1' controls and removing the appropriate pieces. Reviewed-by: Andy Polyakov --- crypto/bn/bn_add.c | 21 --------------------- crypto/bn/bn_lib.c | 23 ---------------------- crypto/bn/bn_mod.c | 8 -------- crypto/bn/bn_rand.c | 4 ---- crypto/bn/bn_recp.c | 2 -- crypto/ocsp/ocsp_ext.c | 43 ------------------------------------------ crypto/x509/x509_vfy.c | 6 ------ 7 files changed, 107 deletions(-) diff --git a/crypto/bn/bn_add.c b/crypto/bn/bn_add.c index f569a7efde..e09451d88b 100644 --- a/crypto/bn/bn_add.c +++ b/crypto/bn/bn_add.c @@ -222,28 +222,7 @@ int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) break; } } -#if 0 memcpy(rp, ap, sizeof(*rp) * (max - i)); -#else - if (rp != ap) { - for (;;) { - if (!dif--) - break; - rp[0] = ap[0]; - if (!dif--) - break; - rp[1] = ap[1]; - if (!dif--) - break; - rp[2] = ap[2]; - if (!dif--) - break; - rp[3] = ap[3]; - rp += 4; - ap += 4; - } - } -#endif r->top = max; r->neg = 0; diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c index c742db6f1f..c3164fa8aa 100644 --- a/crypto/bn/bn_lib.c +++ b/crypto/bn/bn_lib.c @@ -384,29 +384,6 @@ BIGNUM *bn_expand2(BIGNUM *b, int words) b->dmax = words; } -/* None of this should be necessary because of what b->top means! */ -#if 0 - /* - * NB: bn_wexpand() calls this only if the BIGNUM really has to grow - */ - if (b->top < b->dmax) { - int i; - BN_ULONG *A = &(b->d[b->top]); - for (i = (b->dmax - b->top) >> 3; i > 0; i--, A += 8) { - A[0] = 0; - A[1] = 0; - A[2] = 0; - A[3] = 0; - A[4] = 0; - A[5] = 0; - A[6] = 0; - A[7] = 0; - } - for (i = (b->dmax - b->top) & 7; i > 0; i--, A++) - A[0] = 0; - assert(A == &(b->d[b->dmax])); - } -#endif bn_check_top(b); return b; } diff --git a/crypto/bn/bn_mod.c b/crypto/bn/bn_mod.c index ffbce890cf..e0ed47816a 100644 --- a/crypto/bn/bn_mod.c +++ b/crypto/bn/bn_mod.c @@ -116,14 +116,6 @@ #include "cryptlib.h" #include "bn_lcl.h" -#if 0 /* now just a #define */ -int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx) -{ - return (BN_div(NULL, rem, m, d, ctx)); - /* note that rem->neg == m->neg (unless the remainder is zero) */ -} -#endif - int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx) { /* diff --git a/crypto/bn/bn_rand.c b/crypto/bn/bn_rand.c index ecdce9ff14..9488454c12 100644 --- a/crypto/bn/bn_rand.c +++ b/crypto/bn/bn_rand.c @@ -149,7 +149,6 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) goto err; } -#if 1 if (pseudorand == 2) { /* * generate patterns that are more likely to trigger BN library bugs @@ -167,7 +166,6 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) buf[i] = 255; } } -#endif if (top != -1) { if (top) { @@ -206,12 +204,10 @@ int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom) return bnrand(1, rnd, bits, top, bottom); } -#if 1 int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom) { return bnrand(2, rnd, bits, top, bottom); } -#endif /* random number r: 0 <= r < range */ static int bn_rand_range(int pseudo, BIGNUM *r, const BIGNUM *range) diff --git a/crypto/bn/bn_recp.c b/crypto/bn/bn_recp.c index db5660bd13..4f94408b5d 100644 --- a/crypto/bn/bn_recp.c +++ b/crypto/bn/bn_recp.c @@ -195,7 +195,6 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, goto err; r->neg = 0; -#if 1 j = 0; while (BN_ucmp(r, &(recp->N)) >= 0) { if (j++ > 2) { @@ -207,7 +206,6 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, if (!BN_add_word(d, 1)) goto err; } -#endif r->neg = BN_is_zero(r) ? 0 : m->neg; d->neg = m->neg ^ recp->N.neg; diff --git a/crypto/ocsp/ocsp_ext.c b/crypto/ocsp/ocsp_ext.c index 849cb2f762..ce31b1b832 100644 --- a/crypto/ocsp/ocsp_ext.c +++ b/crypto/ocsp/ocsp_ext.c @@ -287,49 +287,6 @@ int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc) } /* also CRL Entry Extensions */ -#if 0 -ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, i2d_of_void *i2d, - void *data, STACK_OF(ASN1_OBJECT) *sk) -{ - int i; - unsigned char *p, *b = NULL; - - if (data) { - if ((i = i2d(data, NULL)) <= 0) - goto err; - if (!(b = p = OPENSSL_malloc((unsigned int)i))) - goto err; - if (i2d(data, &p) <= 0) - goto err; - } else if (sk) { - if ((i = i2d_ASN1_SET_OF_ASN1_OBJECT(sk, NULL, - (I2D_OF(ASN1_OBJECT)) i2d, - V_ASN1_SEQUENCE, - V_ASN1_UNIVERSAL, - IS_SEQUENCE)) <= 0) - goto err; - if (!(b = p = OPENSSL_malloc((unsigned int)i))) - goto err; - if (i2d_ASN1_SET_OF_ASN1_OBJECT(sk, &p, (I2D_OF(ASN1_OBJECT)) i2d, - V_ASN1_SEQUENCE, - V_ASN1_UNIVERSAL, IS_SEQUENCE) <= 0) - goto err; - } else { - OCSPerr(OCSP_F_ASN1_STRING_ENCODE, OCSP_R_BAD_DATA); - goto err; - } - if (!s && !(s = ASN1_STRING_new())) - goto err; - if (!(ASN1_STRING_set(s, b, i))) - goto err; - OPENSSL_free(b); - return s; - err: - if (b) - OPENSSL_free(b); - return NULL; -} -#endif /* Nonce handling functions */ diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c index 22c1f6859f..7e3bca76e7 100644 --- a/crypto/x509/x509_vfy.c +++ b/crypto/x509/x509_vfy.c @@ -145,12 +145,6 @@ static int null_callback(int ok, X509_STORE_CTX *e) return ok; } -#if 0 -static int x509_subject_cmp(X509 **a, X509 **b) -{ - return X509_subject_name_cmp(*a, *b); -} -#endif /* Return 1 is a certificate is self signed */ static int cert_self_signed(X509 *x) { -- 2.40.0