From fdc2a18856ce9690d412a7c357c72f69832ec54c Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 15 Mar 2008 15:24:39 +0100 Subject: [PATCH] sha1.c, md5.c: Hoist a redundant expression. * lib/sha1.c (sha1_process_bytes): AND-off the low bits in "ctx->buflen" only once, before calling *_process_block. * lib/md5.c (md5_process_bytes): Likewise. --- ChangeLog | 7 +++++++ lib/md5.c | 4 ++-- lib/sha1.c | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a58f63785..97d711f4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-03-15 Jim Meyering + + sha1.c, md5.c: Hoist a redundant expression. + * lib/sha1.c (sha1_process_bytes): AND-off the low bits in + "ctx->buflen" only once, before calling *_process_block. + * lib/md5.c (md5_process_bytes): Likewise. + 2008-03-14 Eric Blake Bump copyright year in files generated by gnulib-tool. diff --git a/lib/md5.c b/lib/md5.c index 2213dc120..ce02a2621 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -230,9 +230,9 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) if (ctx->buflen > 64) { - md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx); - ctx->buflen &= 63; + md5_process_block (ctx->buffer, ctx->buflen, ctx); + /* The regions in the following copy operation cannot overlap. */ memcpy (ctx->buffer, &((char *) ctx->buffer)[(left_over + add) & ~63], diff --git a/lib/sha1.c b/lib/sha1.c index 9c6c7ae39..67d5c964c 100644 --- a/lib/sha1.c +++ b/lib/sha1.c @@ -217,9 +217,9 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) if (ctx->buflen > 64) { - sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx); - ctx->buflen &= 63; + sha1_process_block (ctx->buffer, ctx->buflen, ctx); + /* The regions in the following copy operation cannot overlap. */ memcpy (ctx->buffer, &((char *) ctx->buffer)[(left_over + add) & ~63], -- 2.11.0