]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[apr] Scan-build: Fix multiple dead assignments in sha2.c 358/head
authorAndrey Volk <andywolk@gmail.com>
Thu, 13 Feb 2020 21:54:22 +0000 (01:54 +0400)
committerAndrey Volk <andywolk@gmail.com>
Thu, 13 Feb 2020 22:51:32 +0000 (02:51 +0400)
libs/apr/random/unix/sha2.c

index 169afd5a78f8a1e5beb40c8b16da559a3bffe189..b8bd241d85ff886e6f49d1a7c43e105fa9228dc6 100644 (file)
@@ -444,6 +444,16 @@ void apr__SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
 
         /* Clean up */
         a = b = c = d = e = f = g = h = T1 = T2 = 0;
+        assert(a==0);
+        assert(b==0);
+        assert(c==0);
+        assert(d==0);
+        assert(e==0);
+        assert(f==0);
+        assert(g==0);
+        assert(h==0);
+        assert(T1==0);
+        assert(T2==0);
 }
 
 #endif /* SHA2_UNROLL_TRANSFORM */
@@ -478,6 +488,8 @@ void apr__SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len)
                         context->bitcount += len << 3;
                         /* Clean up: */
                         usedspace = freespace = 0;
+                        assert(usedspace==0);
+                        assert(freespace==0);
                         return;
                 }
         }
@@ -495,6 +507,8 @@ void apr__SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len)
         }
         /* Clean up: */
         usedspace = freespace = 0;
+        assert(usedspace==0);
+        assert(freespace==0);
 }
 
 void apr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
@@ -559,6 +573,7 @@ void apr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
         /* Clean up state data: */
         MEMSET_BZERO(context, sizeof(*context));
         usedspace = 0;
+        assert(usedspace==0);
 }
 
 char *apr__SHA256_End(SHA256_CTX* context, char buffer[]) {
@@ -768,6 +783,16 @@ void apr__SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
 
         /* Clean up */
         a = b = c = d = e = f = g = h = T1 = T2 = 0;
+        assert(a==0);
+        assert(b==0);
+        assert(c==0);
+        assert(d==0);
+        assert(e==0);
+        assert(f==0);
+        assert(g==0);
+        assert(h==0);
+        assert(T1==0);
+        assert(T2==0);
 }
 
 #endif /* SHA2_UNROLL_TRANSFORM */
@@ -802,6 +827,8 @@ void apr__SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len)
                         ADDINC128(context->bitcount, len << 3);
                         /* Clean up: */
                         usedspace = freespace = 0;
+                        assert(usedspace==0);
+                        assert(freespace==0);
                         return;
                 }
         }
@@ -819,6 +846,8 @@ void apr__SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len)
         }
         /* Clean up: */
         usedspace = freespace = 0;
+        assert(usedspace==0);
+        assert(freespace==0);
 }
 
 void apr__SHA512_Last(SHA512_CTX* context) {