Shush some dead assignments.

Appease clang scan-build a bit. I'm not sure it's actually worth silencing all
of them because some of them look like preserving invariants between local
variables, but some are clearly pointless or can be restructured slightly.

Change-Id: I0bc81e2589bb402ff3ef0182d7a8921e31b85052
Reviewed-on: https://boringssl-review.googlesource.com/2205
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/asn1/tasn_dec.c b/crypto/asn1/tasn_dec.c
index 80c8b7d..69bacec 100644
--- a/crypto/asn1/tasn_dec.c
+++ b/crypto/asn1/tasn_dec.c
@@ -599,14 +599,13 @@
 	{
 	int flags, aclass;
 	int ret;
-	const unsigned char *p, *q;
+	const unsigned char *p;
 	if (!val)
 		return 0;
 	flags = tt->flags;
 	aclass = flags & ASN1_TFLG_TAG_CLASS;
 
 	p = *in;
-	q = p;
 
 	if (flags & ASN1_TFLG_SK_MASK)
 		{
@@ -663,7 +662,7 @@
 		while(len > 0)
 			{
 			ASN1_VALUE *skfield;
-			q = p;
+			const unsigned char *q = p;
 			/* See if EOC found */
 			if (asn1_check_eoc(&p, len))
 				{
diff --git a/crypto/bn/exponentiation.c b/crypto/bn/exponentiation.c
index ca09c64..afc4287 100644
--- a/crypto/bn/exponentiation.c
+++ b/crypto/bn/exponentiation.c
@@ -416,7 +416,7 @@
 
 static int mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
                         const BIGNUM *m, BN_CTX *ctx) {
-  int i, j, bits, ret = 0, wstart, wend, window, wvalue;
+  int i, j, bits, ret = 0, wstart, window;
   int start = 1;
   BIGNUM *aa;
   /* Table of variables obtained from 'ctx' */
@@ -485,15 +485,16 @@
   start = 1; /* This is used to avoid multiplication etc
               * when there is only the value '1' in the
               * buffer. */
-  wvalue = 0;        /* The 'value' of the window */
   wstart = bits - 1; /* The top bit of the window */
-  wend = 0;          /* The bottom bit of the window */
 
   if (!BN_one(r)) {
     goto err;
   }
 
   for (;;) {
+    int wvalue; /* The 'value' of the window */
+    int wend; /* The bottom bit of the window */
+
     if (BN_is_bit_set(p, wstart) == 0) {
       if (!start) {
         if (!BN_mod_mul_reciprocal(r, r, r, &recp, ctx)) {
@@ -542,7 +543,6 @@
 
     /* move the 'window' down further */
     wstart -= wend + 1;
-    wvalue = 0;
     start = 0;
     if (wstart < 0) {
       break;
@@ -601,7 +601,7 @@
 
 int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
                     const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) {
-  int i, j, bits, ret = 0, wstart, wend, window, wvalue;
+  int i, j, bits, ret = 0, wstart, window;
   int start = 1;
   BIGNUM *d, *r;
   const BIGNUM *aa;
@@ -680,9 +680,7 @@
   start = 1; /* This is used to avoid multiplication etc
               * when there is only the value '1' in the
               * buffer. */
-  wvalue = 0;        /* The 'value' of the window */
   wstart = bits - 1; /* The top bit of the window */
-  wend = 0;          /* The bottom bit of the window */
 
   j = m->top; /* borrow j */
   if (m->d[j - 1] & (((BN_ULONG)1) << (BN_BITS2 - 1))) {
@@ -701,6 +699,9 @@
   }
 
   for (;;) {
+    int wvalue; /* The 'value' of the window */
+    int wend; /* The bottom bit of the window */
+
     if (BN_is_bit_set(p, wstart) == 0) {
       if (!start) {
         if (!BN_mod_mul_montgomery(r, r, r, mont, ctx))
@@ -716,7 +717,6 @@
     /* We now have wstart on a 'set' bit, we now need to work out how bit a
      * window to do.  To do this we need to scan forward until the last set bit
      * before the end of the window */
-    j = wstart;
     wvalue = 1;
     wend = 0;
     for (i = 1; i < window; i++) {
@@ -748,7 +748,6 @@
 
     /* move the 'window' down further */
     wstart -= wend + 1;
-    wvalue = 0;
     start = 0;
     if (wstart < 0) {
       break;
diff --git a/crypto/cipher/e_rc2.c b/crypto/cipher/e_rc2.c
index c26c94e..46cf360 100644
--- a/crypto/cipher/e_rc2.c
+++ b/crypto/cipher/e_rc2.c
@@ -279,7 +279,6 @@
     l2c(xor0, iv);
     l2c(xor1, iv);
   }
-  tin0 = tin1 = tout0 = tout1 = xor0 = xor1 = 0;
   tin[0] = tin[1] = 0;
 }
 
diff --git a/crypto/ec/wnaf.c b/crypto/ec/wnaf.c
index 2fed4a5..cac7234 100644
--- a/crypto/ec/wnaf.c
+++ b/crypto/ec/wnaf.c
@@ -443,8 +443,8 @@
          * as the wNAF belonging to the generator,
          * so wNAF splitting will not buy us anything. */
 
-        numblocks = 1;
-        totalnum = num + 1; /* don't use wNAF splitting */
+        numblocks = 1; /* don't use wNAF splitting */
+        totalnum = num + numblocks;
         wNAF[num] = tmp_wNAF;
         wNAF[num + 1] = NULL;
         wNAF_len[num] = tmp_len;
diff --git a/crypto/x509/t_crl.c b/crypto/x509/t_crl.c
index f2b2ee2..93a7afb 100644
--- a/crypto/x509/t_crl.c
+++ b/crypto/x509/t_crl.c
@@ -91,7 +91,6 @@
 	BIO_printf(out, "Certificate Revocation List (CRL):\n");
 	l = X509_CRL_get_version(x);
 	BIO_printf(out, "%8sVersion %lu (0x%lx)\n", "", l+1, l);
-	i = OBJ_obj2nid(x->sig_alg->algorithm);
 	X509_signature_print(out, x->sig_alg, NULL);
 	p=X509_NAME_oneline(X509_CRL_get_issuer(x),NULL,0);
 	BIO_printf(out,"%8sIssuer: %s\n","",p);