All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] core: make bt_uuid_hash() portable across archs
@ 2022-06-29 19:44 Brian Gix
  2022-06-29 19:44 ` [PATCH BlueZ 2/2] core: Fix signed vs unsigned compare Brian Gix
  2022-06-29 22:15 ` [BlueZ,1/2] core: make bt_uuid_hash() portable across archs bluez.test.bot
  0 siblings, 2 replies; 4+ messages in thread
From: Brian Gix @ 2022-06-29 19:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: luiz.von.dentz, brian.gix

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
---
 src/adapter.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index afefa1d5d..c8b3d27a7 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)
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-29 22:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-29 19:44 [PATCH BlueZ 1/2] core: make bt_uuid_hash() portable across archs Brian Gix
2022-06-29 19:44 ` [PATCH BlueZ 2/2] core: Fix signed vs unsigned compare Brian Gix
2022-06-29 21:07   ` Luiz Augusto von Dentz
2022-06-29 22:15 ` [BlueZ,1/2] core: make bt_uuid_hash() portable across archs bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.