fix problems found by coverity: remove useless code
diff --git a/apps/apps.c b/apps/apps.c
index be710a6..77ef5df 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -1734,10 +1734,7 @@
 		goto err;
 		}
 	if ((tmpdb = TXT_DB_read(in,DB_NUMBER)) == NULL)
-		{
-		if (tmpdb != NULL) TXT_DB_free(tmpdb);
 		goto err;
-		}
 
 #ifndef OPENSSL_SYS_VMS
 	BIO_snprintf(buf[0], sizeof buf[0], "%s.attr", dbfile);
diff --git a/apps/engine.c b/apps/engine.c
index 25c8617..9a6dc0d 100644
--- a/apps/engine.c
+++ b/apps/engine.c
@@ -148,11 +148,6 @@
 
 	if(flags & ENGINE_CMD_FLAG_NUMERIC)
 		{
-		if(started)
-			{
-			BIO_printf(bio_out, "|");
-			err = 1;
-			}
 		BIO_printf(bio_out, "NUMERIC");
 		started = 1;
 		}
diff --git a/apps/req.c b/apps/req.c
index f58e65e..14bb0e0 100644
--- a/apps/req.c
+++ b/apps/req.c
@@ -797,8 +797,6 @@
 
 		app_RAND_write_file(randfile, bio_err);
 
-		if (pkey == NULL) goto end;
-
 		if (keyout == NULL)
 			{
 			keyout=NCONF_get_string(req_conf,SECTION,KEYFILE);
diff --git a/apps/rsa.c b/apps/rsa.c
index 1e2cd2f..3166c6a 100644
--- a/apps/rsa.c
+++ b/apps/rsa.c
@@ -282,7 +282,7 @@
 				passin, e, "Private Key");
 
 		if (pkey != NULL)
-		rsa = pkey == NULL ? NULL : EVP_PKEY_get1_RSA(pkey);
+			rsa = EVP_PKEY_get1_RSA(pkey);
 		EVP_PKEY_free(pkey);
 	}
 
diff --git a/apps/s_client.c b/apps/s_client.c
index 4eac434..fed0122 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -348,7 +348,7 @@
 int MAIN(int argc, char **argv)
 	{
 	int off=0;
-	SSL *con=NULL,*con2=NULL;
+	SSL *con=NULL;
 	X509_STORE *store = NULL;
 	int s,k,width,state=0;
 	char *cbuf=NULL,*sbuf=NULL,*mbuf=NULL;
@@ -1239,7 +1239,6 @@
 end:
 	if(prexit) print_stuff(bio_c_out,con,1);
 	if (con != NULL) SSL_free(con);
-	if (con2 != NULL) SSL_free(con2);
 	if (ctx != NULL) SSL_CTX_free(ctx);
 	if (cert)
 		X509_free(cert);
diff --git a/apps/s_socket.c b/apps/s_socket.c
index 4a922e1..d9321a0 100644
--- a/apps/s_socket.c
+++ b/apps/s_socket.c
@@ -231,13 +231,11 @@
 int init_client(int *sock, char *host, int port, int type)
 	{
 	unsigned char ip[4];
-	short p=0;
 
 	if (!host_ip(host,&(ip[0])))
 		{
 		return(0);
 		}
-	if (p != 0) port=p;
 	return(init_client_ip(sock,ip,port,type));
 	}
 
diff --git a/crypto/asn1/a_object.c b/crypto/asn1/a_object.c
index a36356e..6a421a6 100644
--- a/crypto/asn1/a_object.c
+++ b/crypto/asn1/a_object.c
@@ -280,8 +280,6 @@
 	return ret;
 err:
 	ASN1err(ASN1_F_D2I_ASN1_OBJECT,i);
-	if ((ret != NULL) && ((a == NULL) || (*a != ret)))
-		ASN1_OBJECT_free(ret);
 	return(NULL);
 }
 ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
diff --git a/crypto/asn1/asn1_gen.c b/crypto/asn1/asn1_gen.c
index aaa2c7e..e21c05e 100644
--- a/crypto/asn1/asn1_gen.c
+++ b/crypto/asn1/asn1_gen.c
@@ -439,7 +439,7 @@
 
 static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf)
 	{
-	ASN1_TYPE *ret = NULL, *typ = NULL;
+	ASN1_TYPE *ret = NULL;
 	STACK_OF(ASN1_TYPE) *sk = NULL;
 	STACK_OF(CONF_VALUE) *sect = NULL;
 	unsigned char *der = NULL, *p;
@@ -455,11 +455,10 @@
 			goto bad;
 		for (i = 0; i < sk_CONF_VALUE_num(sect); i++)
 			{
-			typ = ASN1_generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf);
+			ASN1_TYPE *typ = ASN1_generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf);
 			if (!typ)
 				goto bad;
 			sk_ASN1_TYPE_push(sk, typ);
-			typ = NULL;
 			}
 		}
 
@@ -498,8 +497,6 @@
 
 	if (sk)
 		sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
-	if (typ)
-		ASN1_TYPE_free(typ);
 	if (sect)
 		X509V3_section_free(cnf, sect);
 
diff --git a/crypto/asn1/asn1_par.c b/crypto/asn1/asn1_par.c
index 501b62a..938a791 100644
--- a/crypto/asn1/asn1_par.c
+++ b/crypto/asn1/asn1_par.c
@@ -70,9 +70,8 @@
 	     int indent)
 	{
 	static const char fmt[]="%-18s";
-	static const char fmt2[]="%2d %-15s";
 	char str[128];
-	const char *p,*p2=NULL;
+	const char *p;
 
 	if (constructed & V_ASN1_CONSTRUCTED)
 		p="cons: ";
@@ -93,14 +92,8 @@
 	else
 		p = ASN1_tag2str(tag);
 
-	if (p2 != NULL)
-		{
-		if (BIO_printf(bp,fmt2,tag,p2) <= 0) goto err;
-		}
-	else
-		{
-		if (BIO_printf(bp,fmt,p) <= 0) goto err;
-		}
+	if (BIO_printf(bp,fmt,p) <= 0)
+		goto err;
 	return(1);
 err:
 	return(0);
diff --git a/crypto/asn1/t_x509.c b/crypto/asn1/t_x509.c
index 7256866..8e7c076 100644
--- a/crypto/asn1/t_x509.c
+++ b/crypto/asn1/t_x509.c
@@ -111,7 +111,6 @@
 	ASN1_INTEGER *bs;
 	EVP_PKEY *pkey=NULL;
 	const char *neg;
-	ASN1_STRING *str=NULL;
 
 	if((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {
 			mlch = '\n';
@@ -259,7 +258,6 @@
 		}
 	ret=1;
 err:
-	if (str != NULL) ASN1_STRING_free(str);
 	if (m != NULL) OPENSSL_free(m);
 	return(ret);
 	}
diff --git a/crypto/asn1/tasn_new.c b/crypto/asn1/tasn_new.c
index 083f885..95e7de2 100644
--- a/crypto/asn1/tasn_new.c
+++ b/crypto/asn1/tasn_new.c
@@ -345,10 +345,7 @@
 		return 1;
 
 		case V_ASN1_BOOLEAN:
-		if (it)
-			*(ASN1_BOOLEAN *)pval = it->size;
-		else
-			*(ASN1_BOOLEAN *)pval = -1;
+		*(ASN1_BOOLEAN *)pval = it->size;
 		return 1;
 
 		case V_ASN1_NULL:
diff --git a/crypto/dsa/dsa_ossl.c b/crypto/dsa/dsa_ossl.c
index 3fd8a35..9d90178 100644
--- a/crypto/dsa/dsa_ossl.c
+++ b/crypto/dsa/dsa_ossl.c
@@ -281,8 +281,8 @@
 	if (!ret)
 		{
 		DSAerr(DSA_F_DSA_SIGN_SETUP,ERR_R_BN_LIB);
-		if (kinv != NULL) BN_clear_free(kinv);
-		if (r != NULL) BN_clear_free(r);
+		if (r != NULL)
+			BN_clear_free(r);
 		}
 	if (ctx_in == NULL) BN_CTX_free(ctx);
 	if (kinv != NULL) BN_clear_free(kinv);
diff --git a/crypto/dsa/dsatest.c b/crypto/dsa/dsatest.c
index 912317b..5a699ca 100644
--- a/crypto/dsa/dsatest.c
+++ b/crypto/dsa/dsatest.c
@@ -169,7 +169,6 @@
 		}
 	BIO_printf(bio_err,"\ncounter=%d h=%ld\n",counter,h);
 		
-	if (dsa == NULL) goto end;
 	DSA_print(bio_err,dsa,0);
 	if (counter != 105) 
 		{
diff --git a/crypto/dso/dso_dlfcn.c b/crypto/dso/dso_dlfcn.c
index d0552c4..c5edaec 100644
--- a/crypto/dso/dso_dlfcn.c
+++ b/crypto/dso/dso_dlfcn.c
@@ -325,7 +325,7 @@
 		{
 		int spec2len, len;
 
-		spec2len = (filespec2 ? strlen(filespec2) : 0);
+		spec2len = strlen(filespec2);
 		len = spec2len + (filespec1 ? strlen(filespec1) : 0);
 
 		if(filespec2 && filespec2[spec2len - 1] == '/')
diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c
index e0d8d28..dd7da0f 100644
--- a/crypto/ec/ec_lib.c
+++ b/crypto/ec/ec_lib.c
@@ -740,7 +740,7 @@
 
 	if (point->meth->point_clear_finish != 0)
 		point->meth->point_clear_finish(point);
-	else if (point->meth != NULL && point->meth->point_finish != 0)
+	else if (point->meth->point_finish != 0)
 		point->meth->point_finish(point);
 	OPENSSL_cleanse(point, sizeof *point);
 	OPENSSL_free(point);
diff --git a/engines/e_4758cca.c b/engines/e_4758cca.c
index 0f1dae7..6bab385 100644
--- a/engines/e_4758cca.c
+++ b/engines/e_4758cca.c
@@ -482,8 +482,6 @@
 err:
 	if (keyToken)
 		OPENSSL_free(keyToken);
-	if (res)
-		EVP_PKEY_free(res);
 	if (rtmp)
 		RSA_free(rtmp);
 	return NULL;
@@ -560,8 +558,6 @@
 err:
 	if (keyToken)
 		OPENSSL_free(keyToken);
-	if (res)
-		EVP_PKEY_free(res);
 	if (rtmp)
 		RSA_free(rtmp);
 	return NULL;
diff --git a/ssl/bio_ssl.c b/ssl/bio_ssl.c
index 420deb7..da6dfd2 100644
--- a/ssl/bio_ssl.c
+++ b/ssl/bio_ssl.c
@@ -543,7 +543,6 @@
 	return(ret);
 err:
 	if (con != NULL) BIO_free(con);
-	if (ret != NULL) BIO_free(ret);
 	return(NULL);
 	}