[PATCH 5/5] crypto/sha1.c: final cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We don't need j nor t2.  Simplify the code a bit by reusing t and
incrementing the 'out' pointer (it is a bit easier on the compiler
as it reduce register pressure).

Signed-off-by: Nicolas Pitre <[email protected]>

Index: linux-2.6/crypto/sha1.c
===================================================================
--- linux-2.6.orig/crypto/sha1.c
+++ linux-2.6/crypto/sha1.c
@@ -76,7 +76,7 @@
 {
 	struct sha1_ctx *sctx = ctx;
 	u64 count = sctx->count;
-	u32 i, j, index, padlen, t;
+	u32 i, index, padlen, t;
 	u8 bits[8];
 	static const u8 padding[64] = { 0x80, };
 
@@ -99,12 +99,13 @@
 	sha1_update(sctx, bits, sizeof bits); 
 
 	/* Store state in digest */
-	for (i = j = 0; i < 5; i++, j += 4) {
-		u32 t2 = sctx->state[i];
-		out[j+3] = t2 & 0xff; t2>>=8;
-		out[j+2] = t2 & 0xff; t2>>=8;
-		out[j+1] = t2 & 0xff; t2>>=8;
-		out[j  ] = t2 & 0xff;
+	for (i = 0; i < 5; i++) {
+		t = sctx->state[i];
+		out[3] = t & 0xff; t>>=8;
+		out[2] = t & 0xff; t>>=8;
+		out[1] = t & 0xff; t>>=8;
+		out[0] = t & 0xff;
+		out += 4;
 	}
 
 	/* Wipe context */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux