Junio C Hamano <gitster@xxxxxxxxx> writes: >> [1/3]: add collision-detecting sha1 implementation >> [2/3]: sha1dc: adjust header includes for git >> [3/3]: Makefile: add USE_SHA1DC knob > > I was lazy so I fetched the above and then added this on top before > I start to play with it. > > -- >8 -- > From: Junio C Hamano <gitster@xxxxxxxxx> > Date: Tue, 28 Feb 2017 10:39:25 -0800 > Subject: [PATCH] sha1dc: resurrect LICENSE file In a way similar to 8415558f55 ("sha1dc: avoid c99 declaration-after-statement", 2017-02-24), we would want this on top. -- >8 -- Subject: sha1dc: avoid 'for' loop initial decl We write this: type i; for (i = initial; i < limit; i++) instead of this: for (type i = initial; i < limit; i++) the latter of which is from c99. Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- sha1dc/sha1.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sha1dc/sha1.c b/sha1dc/sha1.c index f4e261ae7a..6569b403e9 100644 --- a/sha1dc/sha1.c +++ b/sha1dc/sha1.c @@ -41,7 +41,8 @@ void sha1_message_expansion(uint32_t W[80]) { - for (unsigned i = 16; i < 80; ++i) + unsigned i; + for (i = 16; i < 80; ++i) W[i] = rotate_left(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1); } @@ -49,9 +50,10 @@ void sha1_compression(uint32_t ihv[5], const uint32_t m[16]) { uint32_t W[80]; uint32_t a, b, c, d, e; + unsigned i; memcpy(W, m, 16 * 4); - for (unsigned i = 16; i < 80; ++i) + for (i = 16; i < 80; ++i) W[i] = rotate_left(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1); a = ihv[0];