From dbe81cbd2a93088236a2e4e41eeb33378940f7b9 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 16 Nov 2015 09:21:20 +0100 Subject: 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. --- src/libsystemd-network/sd-ipv4ll.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libsystemd-network/sd-ipv4ll.c') diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c index 0d915e20e7..e69b1864d7 100644 --- a/src/libsystemd-network/sd-ipv4ll.c +++ b/src/libsystemd-network/sd-ipv4ll.c @@ -143,15 +143,15 @@ int sd_ipv4ll_set_mac(sd_ipv4ll *ll, const struct ether_addr *addr) { assert_return(ll, -EINVAL); if (!ll->random_data) { - uint8_t seed[8]; + uint64_t seed; /* If no random data is set, generate some from the MAC */ - siphash24(seed, &addr->ether_addr_octet, + siphash24(&seed, &addr->ether_addr_octet, ETH_ALEN, HASH_KEY.bytes); assert_cc(sizeof(unsigned) <= 8); - r = sd_ipv4ll_set_address_seed(ll, *(unsigned*)seed); + r = sd_ipv4ll_set_address_seed(ll, (unsigned)seed); if (r < 0) return r; } -- cgit v1.2.3-54-g00ecf