aboutsummaryrefslogtreecommitdiff
path: root/crypt/sha256.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-07-19 16:53:43 -0400
committerUlrich Drepper <drepper@gmail.com>2011-07-19 16:53:43 -0400
commit7dc6bd90c569c49807462b0740b18e32fab4d8b7 (patch)
tree1b6b4a3df6408992625f329206dbe98619589a17 /crypt/sha256.c
parente0e722848005e335132015a64a09cad7f7a12073 (diff)
downloadglibc-7dc6bd90c569c49807462b0740b18e32fab4d8b7.zip
glibc-7dc6bd90c569c49807462b0740b18e32fab4d8b7.tar.gz
glibc-7dc6bd90c569c49807462b0740b18e32fab4d8b7.tar.bz2
Use union to avoid casts in code to store results of hashsum computations
Diffstat (limited to 'crypt/sha256.c')
-rw-r--r--crypt/sha256.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/crypt/sha256.c b/crypt/sha256.c
index 1a3aca6..c00cfe2 100644
--- a/crypt/sha256.c
+++ b/crypt/sha256.c
@@ -222,13 +222,11 @@ __sha256_finish_ctx (ctx, resbuf)
/* Put the 64-bit file length in *bits* at the end of the buffer. */
#ifdef _STRING_ARCH_unaligned
- *(uint64_t *) &ctx->buffer[bytes + pad] = SWAP64 (ctx->total64 << 3);
+ ctx->buffer64[(bytes + pad) / 8] = SWAP64 (ctx->total64 << 3);
#else
- *(uint32_t *) &ctx->buffer[bytes + pad + 4]
- = SWAP (ctx->total[TOTAL64_low] << 3);
- *(uint32_t *) &ctx->buffer[bytes + pad]
- = SWAP ((ctx->total[TOTAL64_high] << 3) |
- (ctx->total[TOTAL64_low] >> 29));
+ ctx->buffer32[(bytes + pad + 4) / 4] = SWAP (ctx->total[TOTAL64_low] << 3);
+ ctx->buffer32[(bytes + pad) / 4] = SWAP ((ctx->total[TOTAL64_high] << 3) |
+ (ctx->total[TOTAL64_low] >> 29));
#endif
/* Process last bytes. */