1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

Use union to avoid casts in code to store results of hashsum computations

This commit is contained in:
Ulrich Drepper
2011-07-19 16:53:43 -04:00
parent e0e7228480
commit 7dc6bd90c5
7 changed files with 47 additions and 23 deletions

View File

@ -253,11 +253,9 @@ __sha512_finish_ctx (ctx, resbuf)
memcpy (&ctx->buffer[bytes], fillbuf, pad);
/* Put the 128-bit file length in *bits* at the end of the buffer. */
*(uint64_t *) &ctx->buffer[bytes + pad + 8]
= SWAP (ctx->total[TOTAL128_low] << 3);
*(uint64_t *) &ctx->buffer[bytes + pad]
= SWAP ((ctx->total[TOTAL128_high] << 3) |
(ctx->total[TOTAL128_low] >> 61));
ctx->buffer64[(bytes + pad + 8) / 8] = SWAP (ctx->total[TOTAL128_low] << 3);
ctx->buffer64[(bytes + pad) / 8] = SWAP ((ctx->total[TOTAL128_high] << 3) |
(ctx->total[TOTAL128_low] >> 61));
/* Process last bytes. */
sha512_process_block (ctx->buffer, bytes + pad + 16, ctx);