From 1d3e6a04875327763c464861db68d156c250c786 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Tue, 16 Mar 2010 16:10:59 -0400 Subject: [PATCH] Fix a warning "dereferencing type-punned pointer will break strict-aliasing rules" See man gcc, -fstrict-aliasing Signed-off-by: Benjamin Poirier --- lttv/lttv/sync/data_structures.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lttv/lttv/sync/data_structures.c b/lttv/lttv/sync/data_structures.c index c2bf6467..a8cc337b 100644 --- a/lttv/lttv/sync/data_structures.c +++ b/lttv/lttv/sync/data_structures.c @@ -453,9 +453,14 @@ void gdnConnectionKeyDestroy(gpointer data) guint ghfDatagramKeyHash(gconstpointer key) { DatagramKey* datagramKey; + union { + uint8_t byteKey[8]; + uint32_t hashableKey[2]; + } dataKey; uint32_t a, b, c; datagramKey= (DatagramKey*) key; + memcpy(dataKey.byteKey, datagramKey->dataKey, sizeof(dataKey.byteKey)); a= datagramKey->saddr; b= datagramKey->daddr; @@ -463,8 +468,8 @@ guint ghfDatagramKeyHash(gconstpointer key) mix(a, b, c); a+= datagramKey->ulen; // 16 bits left here - b+= *((uint32_t*) datagramKey->dataKey); - c+= *((uint32_t*) ((void*) datagramKey->dataKey + 4)); + b+= dataKey.hashableKey[0]; + c+= dataKey.hashableKey[1]; final(a, b, c); return c; -- 2.34.1