From afbfd5d9375919c0b6dd718d68588a5d7cf18140 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 9 Aug 2008 17:03:43 +0200 Subject: adhere to C strict aliasing rules --- src/pulsecore/endianmacros.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/pulsecore/endianmacros.h b/src/pulsecore/endianmacros.h index 26336918..1b94de17 100644 --- a/src/pulsecore/endianmacros.h +++ b/src/pulsecore/endianmacros.h @@ -46,9 +46,14 @@ #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) -- cgit