[PATCH] block-sha1/sha1.c: silence compiler complaints by casting void* to uintptr_t
- From
Brandon Casey <casey@nrlssc.navy.mil>
- Date
- Aug 14, 2009, 22:52 UTC
- Message-ID
- <_-0l9qI_nKm-VVtKlL5hzen4bhcyRmiZ1z4jSmKK1LwECXueziRDzSTyacEehOkoqsfYIaEUlds@cipher.nrlssc.navy.mil>
- In-Reply-To
- <alpine.LFD.2.00.0908130017080.10633@xanadu.home>
From: Brandon Casey <drafnel@gmail.com>
Some compilers produce errors when arithmetic is attempted on pointers to void. So cast to uintptr_t when performing arithmetic on void pointers.
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> ---
This, on top of Nico's last patch "block-sha1: more good unaligned memory access candidates", allows this series to compile and run successfully on Sun Sparc and IRIX MIPS for me.
It produces no differences on Linux using gcc. gcc 3.4.6 and 4.1.2 produce an identical binary for me on x86 and x86-64 with and without this change. Any conceivable negative effects on other arch's?
-brandon
block-sha1/sha1.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/block-sha1/sha1.c b/block-sha1/sha1.c index e5a1007..ccaba9e 100644 --- a/block-sha1/sha1.c +++ b/block-sha1/sha1.c @@ -246,14 +246,14 @@ void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, unsigned long len) memcpy(lenW + (char *)ctx->W, data, left); lenW = (lenW + left) & 63; len -= left; - data += left; + data = (const void*) ((uintptr_t) data + left); if (lenW) return; blk_SHA1_Block(ctx, ctx->W); } while (len >= 64) { blk_SHA1_Block(ctx, data); - data += 64; + data = (const void*) ((uintptr_t) data + 64); len -= 64; } if (len)
-- 1.6.4