]> code.delx.au - pulseaudio/commitdiff
adhere to C strict aliasing rules
authorLennart Poettering <lennart@poettering.net>
Sat, 9 Aug 2008 15:03:43 +0000 (17:03 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 9 Aug 2008 15:03:43 +0000 (17:03 +0200)
src/pulsecore/endianmacros.h

index 263369189e5d03eb0ce9146acd4037f5f9c735bb..1b94de17d88a456f3147b3065fffe5c2d90f81e6 100644 (file)
 #endif
 
 static inline float PA_FLOAT32_SWAP(float x) {
-    uint32_t i = *(uint32_t*) &x;
-    i = PA_UINT32_SWAP(i);
-    return *(float*) &i;
+    union {
+        float f;
+        uint32_t u;
+    } t;
+
+    t.f = x;
+    t.u = PA_UINT32_SWAP(t.u);
+    return t.f;
 }
 
 #define PA_MAYBE_INT16_SWAP(c,x) ((c) ? PA_INT32_SWAP(x) : x)