aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2013-06-19 11:45:05 -0400
committerMike Frysinger <vapier@gentoo.org>2013-06-19 11:49:15 -0400
commitf6205c6ab786f14e3515dfc0bfdb958ada8ed0e9 (patch)
treeeb9a33aa6a18faf1b292949ecf4a132e7cce76a1
parentfea25880212dd934c7e17fce8a299f9184933f6b (diff)
downloadbusybox-w32-f6205c6ab786f14e3515dfc0bfdb958ada8ed0e9.tar.gz
busybox-w32-f6205c6ab786f14e3515dfc0bfdb958ada8ed0e9.tar.bz2
busybox-w32-f6205c6ab786f14e3515dfc0bfdb958ada8ed0e9.zip
md5/sha512: fix strict aliasing warnings
If the target can tolerate these issues, then gcc is smart enough to generate the same code (x86_64 produces the same code). If the target can't, then it needs the memcpy anyways. libbb/hash_md5_sha.c: In function 'common64_end': libbb/hash_md5_sha.c:87:4: warning: dereferencing type-punned pointer will break strict-aliasing rules *(uint64_t *) (&ctx->wbuffer[64 - 8]) = t; libbb/hash_md5_sha.c: In function 'sha512_end': libbb/hash_md5_sha.c:886:4: warning: dereferencing type-punned pointer will break strict-aliasing rules *(uint64_t *) (&ctx->wbuffer[128 - 8]) = t; libbb/hash_md5_sha.c:889:4: warning: dereferencing type-punned pointer will break strict-aliasing rules *(uint64_t *) (&ctx->wbuffer[128 - 16]) = t; Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--libbb/hash_md5_sha.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c
index b4d955e5a..e10cb391d 100644
--- a/libbb/hash_md5_sha.c
+++ b/libbb/hash_md5_sha.c
@@ -84,7 +84,7 @@ static void FAST_FUNC common64_end(md5_ctx_t *ctx, int swap_needed)
84 if (swap_needed) 84 if (swap_needed)
85 t = bb_bswap_64(t); 85 t = bb_bswap_64(t);
86 /* wbuffer is suitably aligned for this */ 86 /* wbuffer is suitably aligned for this */
87 *(uint64_t *) (&ctx->wbuffer[64 - 8]) = t; 87 memcpy(&ctx->wbuffer[64 - 8], &t, sizeof(t));
88 } 88 }
89 ctx->process_block(ctx); 89 ctx->process_block(ctx);
90 if (remaining >= 8) 90 if (remaining >= 8)
@@ -883,10 +883,10 @@ void FAST_FUNC sha512_end(sha512_ctx_t *ctx, void *resbuf)
883 uint64_t t; 883 uint64_t t;
884 t = ctx->total64[0] << 3; 884 t = ctx->total64[0] << 3;
885 t = SWAP_BE64(t); 885 t = SWAP_BE64(t);
886 *(uint64_t *) (&ctx->wbuffer[128 - 8]) = t; 886 memcpy(&ctx->wbuffer[128 - 8], &t, sizeof(t));
887 t = (ctx->total64[1] << 3) | (ctx->total64[0] >> 61); 887 t = (ctx->total64[1] << 3) | (ctx->total64[0] >> 61);
888 t = SWAP_BE64(t); 888 t = SWAP_BE64(t);
889 *(uint64_t *) (&ctx->wbuffer[128 - 16]) = t; 889 memcpy(&ctx->wbuffer[128 - 16], &t, sizeof(t));
890 } 890 }
891 sha512_process_block128(ctx); 891 sha512_process_block128(ctx);
892 if (remaining >= 16) 892 if (remaining >= 16)