summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2015-11-16 09:21:20 +0100
committerDaniel Mack <daniel@zonque.org>2015-11-16 15:20:29 +0100
commitdbe81cbd2a93088236a2e4e41eeb33378940f7b9 (patch)
tree8aec120af6f424803074d35827fbfb5048d8a9cf /src/test
parent8dd85afe761885a9c47173cdafd1b7f9b36d08e6 (diff)
siphash24: change result argument to uint64_t
Change the "out" parameter from uint8_t[8] to uint64_t. On architectures which enforce pointer alignment this fixes crashes when we previously cast an unaligned array to uint64_t*, and on others this should at least improve performance as the compiler now aligns these properly. This also simplifies the code in most cases by getting rid of typecasts. The only place which we can't change is struct duid's en.id, as that is _packed_ and public API, so we can't enforce alignment of the "id" field and have to use memcpy instead.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-siphash24.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/test/test-siphash24.c b/src/test/test-siphash24.c
index 2402da6a6f..e5a989cdad 100644
--- a/src/test/test-siphash24.c
+++ b/src/test/test-siphash24.c
@@ -34,7 +34,7 @@ int main(int argc, char *argv[]) {
uint64_t out = 0;
unsigned i, j;
- siphash24((uint8_t *)&out, in, sizeof(in), key);
+ siphash24(&out, in, sizeof(in), key);
assert_se(out == htole64(0xa129ca6149be45e5));
/* verify the internal state as given in the above paper */
@@ -48,7 +48,7 @@ int main(int argc, char *argv[]) {
assert_se(state.v1 == 0x0d52f6f62a4f59a4);
assert_se(state.v2 == 0x634cb3577b01fd3d);
assert_se(state.v3 == 0xa5224d6f55c7d9c8);
- siphash24_finalize((uint8_t*)&out, &state);
+ siphash24_finalize(&out, &state);
assert_se(out == htole64(0xa129ca6149be45e5));
assert_se(state.v0 == 0xf6bcd53893fecff1);
assert_se(state.v1 == 0x54b9964c7ea0d937);
@@ -63,7 +63,7 @@ int main(int argc, char *argv[]) {
siphash24_compress(in, i, &state);
siphash24_compress(&in[i], j - i, &state);
siphash24_compress(&in[j], sizeof(in) - j, &state);
- siphash24_finalize((uint8_t*)&out, &state);
+ siphash24_finalize(&out, &state);
assert_se(out == htole64(0xa129ca6149be45e5));
}
}