aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2015-01-29 21:38:57 -0500
committerRich Salz <rsalz@openssl.org>2015-01-29 21:38:57 -0500
commit4d428cd2504c7ef03bc9672ecf2862eaedb3d87e (patch)
tree2d640a824dd024e3a15db293eb8eb29e06fa3bdd
parent33fc38ff8e2cb8723f7b116de3f8923c4f4eb9d5 (diff)
downloadopenssl-4d428cd2504c7ef03bc9672ecf2862eaedb3d87e.tar.gz
Dead code removal: #if 0 bio, comp, rand
The start of removing dead code. A remaining #if 0 in bss_conn.c needs more thought. Reviewed-by: Richard Levitte <levitte@openssl.org>
-rw-r--r--crypto/bio/b_sock.c220
-rw-r--r--crypto/bio/bf_buff.c4
-rw-r--r--crypto/bio/bf_lbuf.c21
-rw-r--r--crypto/bio/bss_dgram.c42
-rw-r--r--crypto/bio/bss_sock.c6
-rw-r--r--crypto/comp/c_zlib.c113
-rw-r--r--crypto/rand/rand_win.c10
7 files changed, 12 insertions, 404 deletions
diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c
index 7f7a68c2a8..ca485d9c19 100644
--- a/crypto/bio/b_sock.c
+++ b/crypto/bio/b_sock.c
@@ -94,23 +94,7 @@ static int wsa_init_done = 0;
# define WSAAPI
# endif
-# if 0
-static unsigned long BIO_ghbn_hits = 0L;
-static unsigned long BIO_ghbn_miss = 0L;
-
-# define GHBN_NUM 4
-static struct ghbn_cache_st {
- char name[129];
- struct hostent *ent;
- unsigned long order;
-} ghbn_cache[GHBN_NUM];
-# endif
-
static int get_ip(const char *str, unsigned char *ip);
-# if 0
-static void ghbn_free(struct hostent *a);
-static struct hostent *ghbn_dup(struct hostent *a);
-# endif
int BIO_get_host_ip(const char *str, unsigned char *ip)
{
int i;
@@ -207,10 +191,6 @@ int BIO_get_port(const char *str, unsigned short *port_ptr)
*port_ptr = 21;
else if (strcmp(str, "gopher") == 0)
*port_ptr = 70;
-# if 0
- else if (strcmp(str, "wais") == 0)
- *port_ptr = 21;
-# endif
else {
SYSerr(SYS_F_GETSERVBYNAME, get_last_socket_error());
ERR_add_error_data(3, "service='", str, "'");
@@ -244,208 +224,16 @@ int BIO_sock_error(int sock)
return (j);
}
-# if 0
-long BIO_ghbn_ctrl(int cmd, int iarg, char *parg)
-{
- int i;
- char **p;
-
- switch (cmd) {
- case BIO_GHBN_CTRL_HITS:
- return (BIO_ghbn_hits);
- /* break; */
- case BIO_GHBN_CTRL_MISSES:
- return (BIO_ghbn_miss);
- /* break; */
- case BIO_GHBN_CTRL_CACHE_SIZE:
- return (GHBN_NUM);
- /* break; */
- case BIO_GHBN_CTRL_GET_ENTRY:
- if ((iarg >= 0) && (iarg < GHBN_NUM) && (ghbn_cache[iarg].order > 0)) {
- p = (char **)parg;
- if (p == NULL)
- return (0);
- *p = ghbn_cache[iarg].name;
- ghbn_cache[iarg].name[128] = '\0';
- return (1);
- }
- return (0);
- /* break; */
- case BIO_GHBN_CTRL_FLUSH:
- for (i = 0; i < GHBN_NUM; i++)
- ghbn_cache[i].order = 0;
- break;
- default:
- return (0);
- }
- return (1);
-}
-# endif
-
-# if 0
-static struct hostent *ghbn_dup(struct hostent *a)
-{
- struct hostent *ret;
- int i, j;
-
- MemCheck_off();
- ret = (struct hostent *)OPENSSL_malloc(sizeof(struct hostent));
- if (ret == NULL)
- return (NULL);
- memset(ret, 0, sizeof(struct hostent));
-
- for (i = 0; a->h_aliases[i] != NULL; i++) ;
- i++;
- ret->h_aliases = (char **)OPENSSL_malloc(i * sizeof(char *));
- if (ret->h_aliases == NULL)
- goto err;
- memset(ret->h_aliases, 0, i * sizeof(char *));
-
- for (i = 0; a->h_addr_list[i] != NULL; i++) ;
- i++;
- ret->h_addr_list = (char **)OPENSSL_malloc(i * sizeof(char *));
- if (ret->h_addr_list == NULL)
- goto err;
- memset(ret->h_addr_list, 0, i * sizeof(char *));
-
- j = strlen(a->h_name) + 1;
- if ((ret->h_name = OPENSSL_malloc(j)) == NULL)
- goto err;
- memcpy((char *)ret->h_name, a->h_name, j);
- for (i = 0; a->h_aliases[i] != NULL; i++) {
- j = strlen(a->h_aliases[i]) + 1;
- if ((ret->h_aliases[i] = OPENSSL_malloc(j)) == NULL)
- goto err;
- memcpy(ret->h_aliases[i], a->h_aliases[i], j);
- }
- ret->h_length = a->h_length;
- ret->h_addrtype = a->h_addrtype;
- for (i = 0; a->h_addr_list[i] != NULL; i++) {
- if ((ret->h_addr_list[i] = OPENSSL_malloc(a->h_length)) == NULL)
- goto err;
- memcpy(ret->h_addr_list[i], a->h_addr_list[i], a->h_length);
- }
- if (0) {
- err:
- if (ret != NULL)
- ghbn_free(ret);
- ret = NULL;
- }
- MemCheck_on();
- return (ret);
-}
-
-static void ghbn_free(struct hostent *a)
-{
- int i;
-
- if (a == NULL)
- return;
-
- if (a->h_aliases != NULL) {
- for (i = 0; a->h_aliases[i] != NULL; i++)
- OPENSSL_free(a->h_aliases[i]);
- OPENSSL_free(a->h_aliases);
- }
- if (a->h_addr_list != NULL) {
- for (i = 0; a->h_addr_list[i] != NULL; i++)
- OPENSSL_free(a->h_addr_list[i]);
- OPENSSL_free(a->h_addr_list);
- }
- if (a->h_name != NULL)
- OPENSSL_free(a->h_name);
- OPENSSL_free(a);
-}
-
-# endif
-
struct hostent *BIO_gethostbyname(const char *name)
{
-# if 1
/*
* Caching gethostbyname() results forever is wrong, so we have to let
* the true gethostbyname() worry about this
*/
-# if (defined(NETWARE_BSDSOCK) && !defined(__NOVELL_LIBC__))
+# if (defined(NETWARE_BSDSOCK) && !defined(__NOVELL_LIBC__))
return gethostbyname((char *)name);
-# else
- return gethostbyname(name);
-# endif
# else
- struct hostent *ret;
- int i, lowi = 0, j;
- unsigned long low = (unsigned long)-1;
-
-# if 0
- /*
- * It doesn't make sense to use locking here: The function interface is
- * not thread-safe, because threads can never be sure when some other
- * thread destroys the data they were given a pointer to.
- */
- CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME);
-# endif
- j = strlen(name);
- if (j < 128) {
- for (i = 0; i < GHBN_NUM; i++) {
- if (low > ghbn_cache[i].order) {
- low = ghbn_cache[i].order;
- lowi = i;
- }
- if (ghbn_cache[i].order > 0) {
- if (strncmp(name, ghbn_cache[i].name, 128) == 0)
- break;
- }
- }
- } else
- i = GHBN_NUM;
-
- if (i == GHBN_NUM) { /* no hit */
- BIO_ghbn_miss++;
- /*
- * Note: under VMS with SOCKETSHR, it seems like the first parameter
- * is 'char *', instead of 'const char *'
- */
-# ifndef CONST_STRICT
- ret = gethostbyname((char *)name);
-# else
- ret = gethostbyname(name);
-# endif
-
- if (ret == NULL)
- goto end;
- if (j > 128) { /* too big to cache */
-# if 0
- /*
- * If we were trying to make this function thread-safe (which is
- * bound to fail), we'd have to give up in this case (or allocate
- * more memory).
- */
- ret = NULL;
-# endif
- goto end;
- }
-
- /* else add to cache */
- if (ghbn_cache[lowi].ent != NULL)
- ghbn_free(ghbn_cache[lowi].ent); /* XXX not thread-safe */
- ghbn_cache[lowi].name[0] = '\0';
-
- if ((ret = ghbn_cache[lowi].ent = ghbn_dup(ret)) == NULL) {
- BIOerr(BIO_F_BIO_GETHOSTBYNAME, ERR_R_MALLOC_FAILURE);
- goto end;
- }
- strncpy(ghbn_cache[lowi].name, name, 128);
- ghbn_cache[lowi].order = BIO_ghbn_miss + BIO_ghbn_hits;
- } else {
- BIO_ghbn_hits++;
- ret = ghbn_cache[i].ent;
- ghbn_cache[i].order = BIO_ghbn_miss + BIO_ghbn_hits;
- }
- end:
-# if 0
- CRYPTO_w_unlock(CRYPTO_LOCK_GETHOSTBYNAME);
-# endif
- return (ret);
+ return gethostbyname(name);
# endif
}
@@ -505,10 +293,6 @@ void BIO_sock_cleanup(void)
# ifdef OPENSSL_SYS_WINDOWS
if (wsa_init_done) {
wsa_init_done = 0;
-# if 0 /* this call is claimed to be non-present in
- * Winsock2 */
- WSACancelBlockingCall();
-# endif
WSACleanup();
}
# elif defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK)
diff --git a/crypto/bio/bf_buff.c b/crypto/bio/bf_buff.c
index 478fa16a07..0e998d656a 100644
--- a/crypto/bio/bf_buff.c
+++ b/crypto/bio/bf_buff.c
@@ -414,10 +414,6 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
if (ctx->obuf_len > 0) {
r = BIO_write(b->next_bio,
&(ctx->obuf[ctx->obuf_off]), ctx->obuf_len);
-#if 0
- fprintf(stderr, "FLUSH [%3d] %3d -> %3d\n", ctx->obuf_off,
- ctx->obuf_len, r);
-#endif
BIO_copy_next_retry(b);
if (r <= 0)
return ((long)r);
diff --git a/crypto/bio/bf_lbuf.c b/crypto/bio/bf_lbuf.c
index 46d0d5a1e6..3b75b7efc8 100644
--- a/crypto/bio/bf_lbuf.c
+++ b/crypto/bio/bf_lbuf.c
@@ -198,25 +198,16 @@ static int linebuffer_write(BIO *b, const char *in, int inl)
num += i;
}
}
-#if 0
- BIO_write(b->next_bio, "<*<", 3);
-#endif
i = BIO_write(b->next_bio, ctx->obuf, ctx->obuf_len);
if (i <= 0) {
ctx->obuf_len = orig_olen;
BIO_copy_next_retry(b);
-#if 0
- BIO_write(b->next_bio, ">*>", 3);
-#endif
if (i < 0)
return ((num > 0) ? num : i);
if (i == 0)
return (num);
}
-#if 0
- BIO_write(b->next_bio, ">*>", 3);
-#endif
if (i < ctx->obuf_len)
memmove(ctx->obuf, ctx->obuf + i, ctx->obuf_len - i);
ctx->obuf_len -= i;
@@ -227,23 +218,14 @@ static int linebuffer_write(BIO *b, const char *in, int inl)
* if a NL was found and there is anything to write.
*/
if ((foundnl || p - in > ctx->obuf_size) && p - in > 0) {
-#if 0
- BIO_write(b->next_bio, "<*<", 3);
-#endif
i = BIO_write(b->next_bio, in, p - in);
if (i <= 0) {
BIO_copy_next_retry(b);
-#if 0
- BIO_write(b->next_bio, ">*>", 3);
-#endif
if (i < 0)
return ((num > 0) ? num : i);
if (i == 0)
return (num);
}
-#if 0
- BIO_write(b->next_bio, ">*>", 3);
-#endif
num += i;
in += i;
inl -= i;
@@ -330,9 +312,6 @@ static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr)
BIO_clear_retry_flags(b);
if (ctx->obuf_len > 0) {
r = BIO_write(b->next_bio, ctx->obuf, ctx->obuf_len);
-#if 0
- fprintf(stderr, "FLUSH %3d -> %3d\n", ctx->obuf_len, r);
-#endif
BIO_copy_next_retry(b);
if (r <= 0)
return ((long)r);
diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c
index 737359722a..0767809025 100644
--- a/crypto/bio/bss_dgram.c
+++ b/crypto/bio/bss_dgram.c
@@ -449,13 +449,6 @@ static int dgram_write(BIO *b, const char *in, int inl)
if (BIO_dgram_should_retry(ret)) {
BIO_set_retry_write(b);
data->_errno = get_last_socket_error();
-
-# if 0 /* higher layers are responsible for querying
- * MTU, if necessary */
- if (data->_errno == EMSGSIZE)
- /* retrieve the new MTU */
- BIO_ctrl(b, BIO_CTRL_DGRAM_QUERY_MTU, 0, NULL);
-# endif
}
}
return (ret);
@@ -559,28 +552,19 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
break;
case BIO_CTRL_DGRAM_CONNECT:
to = (struct sockaddr *)ptr;
-# if 0
- if (connect(b->num, to, sizeof(struct sockaddr)) < 0) {
- perror("connect");
- ret = 0;
- } else {
-# endif
- switch (to->sa_family) {
- case AF_INET:
- memcpy(&data->peer, to, sizeof(data->peer.sa_in));
- break;
+ switch (to->sa_family) {
+ case AF_INET:
+ memcpy(&data->peer, to, sizeof(data->peer.sa_in));
+ break;
# if OPENSSL_USE_IPV6
- case AF_INET6:
- memcpy(&data->peer, to, sizeof(data->peer.sa_in6));
- break;
+ case AF_INET6:
+ memcpy(&data->peer, to, sizeof(data->peer.sa_in6));
+ break;
# endif
- default:
- memcpy(&data->peer, to, sizeof(data->peer.sa));
- break;
- }
-# if 0
+ default:
+ memcpy(&data->peer, to, sizeof(data->peer.sa));
+ break;
}
-# endif
break;
/* (Linux)kernel sets DF bit on outgoing IP packets */
case BIO_CTRL_DGRAM_MTU_DISCOVER:
@@ -1992,12 +1976,6 @@ int BIO_dgram_non_fatal_error(int err)
# if defined(WSAEWOULDBLOCK)
case WSAEWOULDBLOCK:
# endif
-
-# if 0 /* This appears to always be an error */
-# if defined(WSAENOTCONN)
- case WSAENOTCONN:
-# endif
-# endif
# endif
# ifdef EWOULDBLOCK
diff --git a/crypto/bio/bss_sock.c b/crypto/bio/bss_sock.c
index 6194d2c031..5a73e81315 100644
--- a/crypto/bio/bss_sock.c
+++ b/crypto/bio/bss_sock.c
@@ -233,12 +233,6 @@ int BIO_sock_non_fatal_error(int err)
# if defined(WSAEWOULDBLOCK)
case WSAEWOULDBLOCK:
# endif
-
-# if 0 /* This appears to always be an error */
-# if defined(WSAENOTCONN)
- case WSAENOTCONN:
-# endif
-# endif
# endif
# ifdef EWOULDBLOCK
diff --git a/crypto/comp/c_zlib.c b/crypto/comp/c_zlib.c
index 6731af8b0d..c3b064cc6e 100644
--- a/crypto/comp/c_zlib.c
+++ b/crypto/comp/c_zlib.c
@@ -49,28 +49,6 @@ static void zlib_zfree(void *opaque, void *address)
OPENSSL_free(address);
}
-# if 0
-static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out,
- unsigned int olen, unsigned char *in,
- unsigned int ilen);
-static int zlib_expand_block(COMP_CTX *ctx, unsigned char *out,
- unsigned int olen, unsigned char *in,
- unsigned int ilen);
-
-static int zz_uncompress(Bytef *dest, uLongf * destLen, const Bytef *source,
- uLong sourceLen);
-
-static COMP_METHOD zlib_stateless_method = {
- NID_zlib_compression,
- LN_zlib_compression,
- NULL,
- NULL,
- zlib_compress_block,
- zlib_expand_block,
- NULL,
- NULL,
-};
-# endif
static COMP_METHOD zlib_stateful_method = {
NID_zlib_compression,
@@ -247,97 +225,6 @@ static int zlib_stateful_expand_block(COMP_CTX *ctx, unsigned char *out,
return olen - state->istream.avail_out;
}
-# if 0
-static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out,
- unsigned int olen, unsigned char *in,
- unsigned int ilen)
-{
- unsigned long l;
- int i;
- int clear = 1;
-
- if (ilen > 128) {
- out[0] = 1;
- l = olen - 1;
- i = compress(&(out[1]), &l, in, (unsigned long)ilen);
- if (i != Z_OK)
- return (-1);
- if (ilen > l) {
- clear = 0;
- l++;
- }
- }
- if (clear) {
- out[0] = 0;
- memcpy(&(out[1]), in, ilen);
- l = ilen + 1;
- }
-# ifdef DEBUG_ZLIB
- fprintf(stderr, "compress(%4d)->%4d %s\n",
- ilen, (int)l, (clear) ? "clear" : "zlib");
-# endif
- return ((int)l);
-}
-
-static int zlib_expand_block(COMP_CTX *ctx, unsigned char *out,
- unsigned int olen, unsigned char *in,
- unsigned int ilen)
-{
- unsigned long l;
- int i;
-
- if (in[0]) {
- l = olen;
- i = zz_uncompress(out, &l, &(in[1]), (unsigned long)ilen - 1);
- if (i != Z_OK)
- return (-1);
- } else {
- memcpy(out, &(in[1]), ilen - 1);
- l = ilen - 1;
- }
-# ifdef DEBUG_ZLIB
- fprintf(stderr, "expand (%4d)->%4d %s\n",
- ilen, (int)l, in[0] ? "zlib" : "clear");
-# endif
- return ((int)l);
-}
-
-static int zz_uncompress(Bytef *dest, uLongf * destLen, const Bytef *source,
- uLong sourceLen)
-{
- z_stream stream;
- int err;
-
- stream.next_in = (Bytef *)source;
- stream.avail_in = (uInt) sourceLen;
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong) stream.avail_in != sourceLen)
- return Z_BUF_ERROR;
-
- stream.next_out = dest;
- stream.avail_out = (uInt) * destLen;
- if ((uLong) stream.avail_out != *destLen)
- return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func) 0;
- stream.zfree = (free_func) 0;
-
- err = inflateInit_(&stream, ZLIB_VERSION, sizeof(z_stream));
- if (err != Z_OK)
- return err;
-
- err = inflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- inflateEnd(&stream);
- return err;
- }
- *destLen = stream.total_out;
-
- err = inflateEnd(&stream);
- return err;
-}
-# endif
-
#endif
COMP_METHOD *COMP_zlib(void)
diff --git a/crypto/rand/rand_win.c b/crypto/rand/rand_win.c
index 06670ae017..eeb5e9cda6 100644
--- a/crypto/rand/rand_win.c
+++ b/crypto/rand/rand_win.c
@@ -303,9 +303,6 @@ int RAND_poll(void)
if (gen(hProvider, sizeof(buf), buf) != 0) {
RAND_add(buf, sizeof(buf), 0);
good = 1;
-# if 0
- printf("randomness from PROV_RSA_FULL\n");
-# endif
}
release(hProvider, 0);
}
@@ -315,9 +312,6 @@ int RAND_poll(void)
if (gen(hProvider, sizeof(buf), buf) != 0) {
RAND_add(buf, sizeof(buf), sizeof(buf));
good = 1;
-# if 0
- printf("randomness from PROV_INTEL_SEC\n");
-# endif
}
release(hProvider, 0);
}
@@ -573,10 +567,6 @@ int RAND_poll(void)
w = GetCurrentProcessId();
RAND_add(&w, sizeof(w), 1);
-# if 0
- printf("Exiting RAND_poll\n");
-# endif
-
return (1);
}