fix aliasing error for parsing message float data
authorFelix Fietkau <nbd@openwrt.org>
Thu, 2 Oct 2014 10:43:18 +0000 (12:43 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 2 Oct 2014 10:43:18 +0000 (12:43 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
data/gen-code.pl

index 5245bdeb5bbde4319791ec1ef68f5a7bd7641e00..f45d28a0538209055a20baa5eb142bdf76e296de 100755 (executable)
@@ -19,7 +19,7 @@ my %tlv_get = (
        guint32 => "le32_to_cpu(*(uint32_t *) get_next(4))",
        gint64 => "le64_to_cpu(*(uint64_t *) get_next(8))",
        guint64 => "le64_to_cpu(*(uint64_t *) get_next(8))",
-       gfloat => "({ uint32_t data = le32_to_cpu(*(uint32_t *) get_next(4)); *((float *) &data); })"
+       gfloat => "({ uint32_t data = le32_to_cpu(*(uint32_t *) get_next(4)); float _val; memcpy(&_val, &data, sizeof(_val)); _val; })"
 );
 
 my %tlv_get_be = (