From 9698f90ccec779f7812a9aa550a6b77feefb52e3 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sun, 11 Aug 2019 03:41:23 +0000 Subject: [PATCH] Avoid statement expressions for get_aligned_le* --- src/utils/platform.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/utils/platform.h b/src/utils/platform.h index 813987eb6..1aa9dc069 100644 --- a/src/utils/platform.h +++ b/src/utils/platform.h @@ -4,18 +4,18 @@ #include "includes.h" #include "common.h" -#define le16_to_cpu le_to_host16 -#define le32_to_cpu le_to_host32 +static inline u16 get_unaligned_le16(void *p) +{ + u16 v; + memcpy(&v, p, sizeof(v)); + return le_to_host16(v); +} -#define get_unaligned(p) \ -({ \ - struct packed_dummy_struct { \ - typeof(*(p)) __val; \ - } __attribute__((packed)) *__ptr = (void *) (p); \ - \ - __ptr->__val; \ -}) -#define get_unaligned_le16(p) le16_to_cpu(get_unaligned((le16 *)(p))) -#define get_unaligned_le32(p) le32_to_cpu(get_unaligned((le32 *)(p))) +static inline u32 get_unaligned_le32(void *p) +{ + u32 v; + memcpy(&v, p, sizeof(v)); + return le_to_host32(v); +} #endif /* PLATFORM_H */ -- 2.22.0