wok-current view efivar/stuff/0003-Fix-all-the-places-Werror-address-of-packed-member-c.patch @ rev 25788
Mass update to fix build with gcc10 and up others packages
author | Stanislas Leduc <shann@slitaz.org> |
---|---|
date | Tue Sep 30 07:43:04 2025 +0000 (3 weeks ago) |
parents | |
children |
line source
1 From c3c553db85ff10890209d0fe48fb4856ad68e4e0 Mon Sep 17 00:00:00 2001
2 From: Peter Jones <pjones@redhat.com>
3 Date: Thu, 21 Feb 2019 15:20:12 -0500
4 Subject: [PATCH] Fix all the places -Werror=address-of-packed-member catches.
6 This gets rid of all the places GCC 9's -Werror=address-of-packed-member
7 flags as problematic.
9 Fixes github issue #123
11 Signed-off-by: Peter Jones <pjones@redhat.com>
12 [james.hilliard1@gmail.com: backport from upstream commit
13 c3c553db85ff10890209d0fe48fb4856ad68e4e0]
14 Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
15 ---
16 src/dp-message.c | 6 ++++--
17 src/dp.h | 12 ++++--------
18 src/guid.c | 2 +-
19 src/include/efivar/efivar.h | 2 +-
20 src/ucs2.h | 27 +++++++++++++++++++--------
21 5 files changed, 29 insertions(+), 20 deletions(-)
23 diff --git a/src/dp-message.c b/src/dp-message.c
24 index 3724e5f..9f96466 100644
25 --- a/src/dp-message.c
26 +++ b/src/dp-message.c
27 @@ -620,11 +620,13 @@ _format_message_dn(char *buf, size_t size, const_efidp dp)
28 ) / sizeof(efi_ip_addr_t);
29 format(buf, size, off, "Dns", "Dns(");
30 for (int i=0; i < end; i++) {
31 - const efi_ip_addr_t *addr = &dp->dns.addrs[i];
32 + efi_ip_addr_t addr;
33 +
34 + memcpy(&addr, &dp->dns.addrs[i], sizeof(addr));
35 if (i != 0)
36 format(buf, size, off, "Dns", ",");
37 format_ip_addr(buf, size, off, "Dns",
38 - dp->dns.is_ipv6, addr);
39 + dp->dns.is_ipv6, &addr);
40 }
41 format(buf, size, off, "Dns", ")");
42 break;
43 diff --git a/src/dp.h b/src/dp.h
44 index 20cb608..1f921d5 100644
45 --- a/src/dp.h
46 +++ b/src/dp.h
47 @@ -71,13 +71,9 @@
48 int _rc; \
49 char *_guidstr = NULL; \
50 efi_guid_t _guid; \
51 - const efi_guid_t * const _guid_p = \
52 - likely(__alignof__(guid) == sizeof(guid)) \
53 - ? guid \
54 - : &_guid; \
55 - \
56 - if (unlikely(__alignof__(guid) == sizeof(guid))) \
57 - memmove(&_guid, guid, sizeof(_guid)); \
58 + const efi_guid_t * const _guid_p = &_guid; \
59 + \
60 + memmove(&_guid, guid, sizeof(_guid)); \
61 _rc = efi_guid_to_str(_guid_p, &_guidstr); \
62 if (_rc < 0) { \
63 efi_error("could not build %s GUID DP string", \
64 @@ -86,7 +82,7 @@
65 _guidstr = onstack(_guidstr, \
66 strlen(_guidstr)+1); \
67 _rc = format(buf, size, off, dp_type, "%s", \
68 - _guidstr); \
69 + _guidstr); \
70 } \
71 _rc; \
72 })
73 diff --git a/src/guid.c b/src/guid.c
74 index 306c9ff..3156b3b 100644
75 --- a/src/guid.c
76 +++ b/src/guid.c
77 @@ -31,7 +31,7 @@
78 extern const efi_guid_t efi_guid_zero;
80 int NONNULL(1, 2) PUBLIC
81 -efi_guid_cmp(const efi_guid_t *a, const efi_guid_t *b)
82 +efi_guid_cmp(const void * const a, const void * const b)
83 {
84 return memcmp(a, b, sizeof (efi_guid_t));
85 }
86 diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h
87 index 316891c..ad6449d 100644
88 --- a/src/include/efivar/efivar.h
89 +++ b/src/include/efivar/efivar.h
90 @@ -128,7 +128,7 @@ extern int efi_symbol_to_guid(const char *symbol, efi_guid_t *guid)
92 extern int efi_guid_is_zero(const efi_guid_t *guid);
93 extern int efi_guid_is_empty(const efi_guid_t *guid);
94 -extern int efi_guid_cmp(const efi_guid_t *a, const efi_guid_t *b);
95 +extern int efi_guid_cmp(const void * const a, const void * const b);
97 /* import / export functions */
98 typedef struct efi_variable efi_variable_t;
99 diff --git a/src/ucs2.h b/src/ucs2.h
100 index dbb5900..edd8367 100644
101 --- a/src/ucs2.h
102 +++ b/src/ucs2.h
103 @@ -23,16 +23,21 @@
104 (((val) & ((mask) << (shift))) >> (shift))
106 static inline size_t UNUSED
107 -ucs2len(const uint16_t * const s, ssize_t limit)
108 +ucs2len(const void *vs, ssize_t limit)
109 {
110 ssize_t i;
111 - for (i = 0; i < (limit >= 0 ? limit : i+1) && s[i] != (uint16_t)0; i++)
112 + const uint16_t *s = vs;
113 + const uint8_t *s8 = vs;
114 +
115 + for (i = 0;
116 + i < (limit >= 0 ? limit : i+1) && s8[0] != 0 && s8[1] != 0;
117 + i++, s8 += 2, s++)
118 ;
119 return i;
120 }
122 static inline size_t UNUSED
123 -ucs2size(const uint16_t * const s, ssize_t limit)
124 +ucs2size(const void *s, ssize_t limit)
125 {
126 size_t rc = ucs2len(s, limit);
127 rc *= sizeof (uint16_t);
128 @@ -69,10 +74,11 @@ utf8size(uint8_t *s, ssize_t limit)
129 }
131 static inline unsigned char * UNUSED
132 -ucs2_to_utf8(const uint16_t * const chars, ssize_t limit)
133 +ucs2_to_utf8(const void * const voidchars, ssize_t limit)
134 {
135 ssize_t i, j;
136 unsigned char *ret;
137 + const uint16_t * const chars = voidchars;
139 if (limit < 0)
140 limit = ucs2len(chars, -1);
141 @@ -124,10 +130,12 @@ ucs2_to_utf8(const uint16_t * const chars, ssize_t limit)
142 }
144 static inline ssize_t UNUSED NONNULL(4)
145 -utf8_to_ucs2(uint16_t *ucs2, ssize_t size, int terminate, uint8_t *utf8)
146 +utf8_to_ucs2(void *ucs2void, ssize_t size, int terminate, uint8_t *utf8)
147 {
148 ssize_t req;
149 ssize_t i, j;
150 + uint16_t *ucs2 = ucs2void;
151 + uint16_t val16;
153 if (!ucs2 && size > 0) {
154 errno = EINVAL;
155 @@ -162,10 +170,13 @@ utf8_to_ucs2(uint16_t *ucs2, ssize_t size, int terminate, uint8_t *utf8)
156 val = utf8[i] & 0x7f;
157 i += 1;
158 }
159 - ucs2[j] = val;
160 + val16 = val;
161 + ucs2[j] = val16;
162 + }
163 + if (terminate) {
164 + val16 = 0;
165 + ucs2[j++] = val16;
166 }
167 - if (terminate)
168 - ucs2[j++] = (uint16_t)0;
169 return j;
170 };
172 --
173 2.20.1