git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/3] sha1: update pointer and remaining length after subfunction call

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 12, 2012, 18:35 UTC
Message-ID
<7vhar3ccmr.fsf@alter.siamese.dyndns.org>
In-Reply-To
<e6f0051409811fc57385ae712d3256772044bf09.1347442430.git.ydroneaud@opteya.com>
Yann Droneaud <ydroneaud@opteya.com> writes:
Show 29 quoted lines
> There's no need to update the pointer and remaining length before
> leaving or calling the SHA1 sub function.
>
> Additionnaly, the partial block code could be looking more like
> the full block handling branch.
>
> Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
> ---
>  block-sha1/sha1.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block-sha1/sha1.c b/block-sha1/sha1.c
> index a8d4bf9..c1af112 100644
> --- a/block-sha1/sha1.c
> +++ b/block-sha1/sha1.c
> @@ -248,11 +248,11 @@ void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, unsigned long len)
>  			left = len;
>  		memcpy(lenW + (char *)ctx->W, data, left);
>  		lenW = (lenW + left) & 63;
> -		len -= left;
> -		data = ((const char *)data + left);
>  		if (lenW)
>  			return;
>  		blk_SHA1_Block(ctx, ctx->W);
> +		data = ((const char *)data + left);
> +		len -= left;
>  	}
>  	while (len >= 64) {
>  		blk_SHA1_Block(ctx, data);

It is not wrong per-se, but doesn't the compiler optimize it out if this is worth doing? Just being curious.

Previous: Yann DroneaudNext: Yann Droneaud
Message 3 of 14 in “Janitor minor fixes on SHA1”
  1. 0/3 Janitor minor fixes on SHA1Yann Droneaud, Sep 12, 2012
  2. 1/3 sha1: update pointer and remaining length after subfunction callYann Droneaud, Sep 12, 2012
  3. Junio C HamanoSep 12, 2012
  4. 2/3 sha1: clean pointer arithmeticYann Droneaud, Sep 12, 2012
  5. Junio C HamanoSep 12, 2012
  6. Yann DroneaudSep 12, 2012
  7. Bruce KorbSep 12, 2012
  8. 3/3 sha1: use char type for temporary work bufferYann Droneaud, Sep 12, 2012
  9. Jeff KingSep 12, 2012
  10. Yann DroneaudSep 12, 2012
  11. Jeff KingSep 12, 2012
  12. Yann DroneaudSep 13, 2012
  13. Junio C HamanoSep 12, 2012
  14. Yann DroneaudSep 12, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.