Re: [PATCH 2/3] sha1: clean pointer arithmetic

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

 



Yann Droneaud <ydroneaud@xxxxxxxxxx> writes:

> One memcpy() argument is computed from a pointer added to an integer:
> eg. int + pointer. It's unusal.
> Let's write it in the correct order: pointer + offset.

Meh.

Both are correct.  Aren't ctx->w[lenW] and lenW[ctx-w] both correct,
even?


>
> Signed-off-by: Yann Droneaud <ydroneaud@xxxxxxxxxx>
> ---
>  block-sha1/sha1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block-sha1/sha1.c b/block-sha1/sha1.c
> index c1af112..a7c4470 100644
> --- a/block-sha1/sha1.c
> +++ b/block-sha1/sha1.c
> @@ -246,7 +246,7 @@ void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, unsigned long len)
>  		unsigned int left = 64 - lenW;
>  		if (len < left)
>  			left = len;
> -		memcpy(lenW + (char *)ctx->W, data, left);
> +		memcpy((char *)ctx->W + lenW, data, left);
>  		lenW = (lenW + left) & 63;
>  		if (lenW)
>  			return;
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]