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/udev/net/link-config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/udev') diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index 776674e994..77d9bf995a 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -354,14 +354,14 @@ static int get_mac(struct udev_device *device, bool want_random, if (want_random) random_bytes(mac->ether_addr_octet, ETH_ALEN); else { - uint8_t result[8]; + uint64_t result; - r = net_get_unique_predictable_data(device, result); + r = net_get_unique_predictable_data(device, &result); if (r < 0) return r; assert_cc(ETH_ALEN <= sizeof(result)); - memcpy(mac->ether_addr_octet, result, ETH_ALEN); + memcpy(mac->ether_addr_octet, &result, ETH_ALEN); } /* see eth_random_addr in the kernel */ -- cgit v1.2.3-54-g00ecf