Fix a warning
authorBenjamin Poirier <benjamin.poirier@polymtl.ca>
Tue, 16 Mar 2010 20:10:59 +0000 (16:10 -0400)
committerBenjamin Poirier <benjamin.poirier@polymtl.ca>
Wed, 7 Apr 2010 16:11:38 +0000 (12:11 -0400)
"dereferencing type-punned pointer will break strict-aliasing rules"
See man gcc, -fstrict-aliasing

Signed-off-by: Benjamin Poirier <benjamin.poirier@polymtl.ca>
lttv/lttv/sync/data_structures.c

index c2bf6467227de36a36c7cbc0a8500f251d4ae458..a8cc337ba091413b6328f023dda24edf6c50b84e 100644 (file)
@@ -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;
This page took 0.023845 seconds and 4 git commands to generate.