summaryrefslogtreecommitdiff
path: root/src/adapter.c
diff options
context:
space:
mode:
authorBrian Gix <brian.gix@intel.com>2022-06-29 14:16:39 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-06-30 13:26:58 -0700
commit8fc3368db84035bee91ce0bea2f7592343e19f81 (patch)
tree5d94daad0b41ef47b8b57cd0f525bcdbc377e3d4 /src/adapter.c
parent44658fccacda3ade0ca2adbb2643b489671fe477 (diff)
downloadbluez-8fc3368db84035bee91ce0bea2f7592343e19f81.tar.gz
core: make bt_uuid_hash() portable across archs
bt_uuid_t is defined as a byte array, so it can cause alignment errors on some architectures, when the two 64 bit halves are treated as u64s. This patch ensures proper alignment across all architectures. Fixes: src/adapter.c: In function ‘bt_uuid_hash’: src/adapter.c:3617:8: error: cast increases required alignment of target type [-Werror=cast-align] val = (uint64_t *)&uuid_128.value.u128; ^ cc1: all warnings being treated as errors
Diffstat (limited to 'src/adapter.c')
-rw-r--r--src/adapter.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/adapter.c b/src/adapter.c
index 16da20034..c4d5ad2e2 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3607,16 +3607,14 @@ static void add_uuid_to_uuid_set(void *data, void *user_data)
static guint bt_uuid_hash(gconstpointer key)
{
const bt_uuid_t *uuid = key;
- bt_uuid_t uuid_128;
- uint64_t *val;
+ uint64_t uuid_128[2];
if (!uuid)
return 0;
- bt_uuid_to_uuid128(uuid, &uuid_128);
- val = (uint64_t *)&uuid_128.value.u128;
+ bt_uuid_to_uuid128(uuid, (bt_uuid_t *)uuid_128);
- return g_int64_hash(val) ^ g_int64_hash(val+1);
+ return g_int64_hash(uuid_128) ^ g_int64_hash(uuid_128+1);
}
static gboolean bt_uuid_equal(gconstpointer v1, gconstpointer v2)