From: Benjamin Poirier Date: Tue, 16 Mar 2010 20:10:59 +0000 (-0400) Subject: Fix a warning X-Git-Tag: 0.12.32~29 X-Git-Url: http://git.liburcu.org/?p=lttv.git;a=commitdiff_plain;h=1d3e6a04875327763c464861db68d156c250c786 Fix a warning "dereferencing type-punned pointer will break strict-aliasing rules" See man gcc, -fstrict-aliasing Signed-off-by: Benjamin Poirier --- 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;