blob: 73484e6554e1aad43f69f06e99295b912507218d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
From 9698f90ccec779f7812a9aa550a6b77feefb52e3 Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
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
|