wok-current diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/efivar/stuff/0003-Fix-all-the-places-Werror-address-of-packed-member-c.patch Tue Sep 30 07:43:04 2025 +0000 1.3 @@ -0,0 +1,175 @@ 1.4 +From c3c553db85ff10890209d0fe48fb4856ad68e4e0 Mon Sep 17 00:00:00 2001 1.5 +From: Peter Jones <pjones@redhat.com> 1.6 +Date: Thu, 21 Feb 2019 15:20:12 -0500 1.7 +Subject: [PATCH] Fix all the places -Werror=address-of-packed-member catches. 1.8 + 1.9 +This gets rid of all the places GCC 9's -Werror=address-of-packed-member 1.10 +flags as problematic. 1.11 + 1.12 +Fixes github issue #123 1.13 + 1.14 +Signed-off-by: Peter Jones <pjones@redhat.com> 1.15 +[james.hilliard1@gmail.com: backport from upstream commit 1.16 +c3c553db85ff10890209d0fe48fb4856ad68e4e0] 1.17 +Signed-off-by: James Hilliard <james.hilliard1@gmail.com> 1.18 +--- 1.19 + src/dp-message.c | 6 ++++-- 1.20 + src/dp.h | 12 ++++-------- 1.21 + src/guid.c | 2 +- 1.22 + src/include/efivar/efivar.h | 2 +- 1.23 + src/ucs2.h | 27 +++++++++++++++++++-------- 1.24 + 5 files changed, 29 insertions(+), 20 deletions(-) 1.25 + 1.26 +diff --git a/src/dp-message.c b/src/dp-message.c 1.27 +index 3724e5f..9f96466 100644 1.28 +--- a/src/dp-message.c 1.29 ++++ b/src/dp-message.c 1.30 +@@ -620,11 +620,13 @@ _format_message_dn(char *buf, size_t size, const_efidp dp) 1.31 + ) / sizeof(efi_ip_addr_t); 1.32 + format(buf, size, off, "Dns", "Dns("); 1.33 + for (int i=0; i < end; i++) { 1.34 +- const efi_ip_addr_t *addr = &dp->dns.addrs[i]; 1.35 ++ efi_ip_addr_t addr; 1.36 ++ 1.37 ++ memcpy(&addr, &dp->dns.addrs[i], sizeof(addr)); 1.38 + if (i != 0) 1.39 + format(buf, size, off, "Dns", ","); 1.40 + format_ip_addr(buf, size, off, "Dns", 1.41 +- dp->dns.is_ipv6, addr); 1.42 ++ dp->dns.is_ipv6, &addr); 1.43 + } 1.44 + format(buf, size, off, "Dns", ")"); 1.45 + break; 1.46 +diff --git a/src/dp.h b/src/dp.h 1.47 +index 20cb608..1f921d5 100644 1.48 +--- a/src/dp.h 1.49 ++++ b/src/dp.h 1.50 +@@ -71,13 +71,9 @@ 1.51 + int _rc; \ 1.52 + char *_guidstr = NULL; \ 1.53 + efi_guid_t _guid; \ 1.54 +- const efi_guid_t * const _guid_p = \ 1.55 +- likely(__alignof__(guid) == sizeof(guid)) \ 1.56 +- ? guid \ 1.57 +- : &_guid; \ 1.58 +- \ 1.59 +- if (unlikely(__alignof__(guid) == sizeof(guid))) \ 1.60 +- memmove(&_guid, guid, sizeof(_guid)); \ 1.61 ++ const efi_guid_t * const _guid_p = &_guid; \ 1.62 ++ \ 1.63 ++ memmove(&_guid, guid, sizeof(_guid)); \ 1.64 + _rc = efi_guid_to_str(_guid_p, &_guidstr); \ 1.65 + if (_rc < 0) { \ 1.66 + efi_error("could not build %s GUID DP string", \ 1.67 +@@ -86,7 +82,7 @@ 1.68 + _guidstr = onstack(_guidstr, \ 1.69 + strlen(_guidstr)+1); \ 1.70 + _rc = format(buf, size, off, dp_type, "%s", \ 1.71 +- _guidstr); \ 1.72 ++ _guidstr); \ 1.73 + } \ 1.74 + _rc; \ 1.75 + }) 1.76 +diff --git a/src/guid.c b/src/guid.c 1.77 +index 306c9ff..3156b3b 100644 1.78 +--- a/src/guid.c 1.79 ++++ b/src/guid.c 1.80 +@@ -31,7 +31,7 @@ 1.81 + extern const efi_guid_t efi_guid_zero; 1.82 + 1.83 + int NONNULL(1, 2) PUBLIC 1.84 +-efi_guid_cmp(const efi_guid_t *a, const efi_guid_t *b) 1.85 ++efi_guid_cmp(const void * const a, const void * const b) 1.86 + { 1.87 + return memcmp(a, b, sizeof (efi_guid_t)); 1.88 + } 1.89 +diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h 1.90 +index 316891c..ad6449d 100644 1.91 +--- a/src/include/efivar/efivar.h 1.92 ++++ b/src/include/efivar/efivar.h 1.93 +@@ -128,7 +128,7 @@ extern int efi_symbol_to_guid(const char *symbol, efi_guid_t *guid) 1.94 + 1.95 + extern int efi_guid_is_zero(const efi_guid_t *guid); 1.96 + extern int efi_guid_is_empty(const efi_guid_t *guid); 1.97 +-extern int efi_guid_cmp(const efi_guid_t *a, const efi_guid_t *b); 1.98 ++extern int efi_guid_cmp(const void * const a, const void * const b); 1.99 + 1.100 + /* import / export functions */ 1.101 + typedef struct efi_variable efi_variable_t; 1.102 +diff --git a/src/ucs2.h b/src/ucs2.h 1.103 +index dbb5900..edd8367 100644 1.104 +--- a/src/ucs2.h 1.105 ++++ b/src/ucs2.h 1.106 +@@ -23,16 +23,21 @@ 1.107 + (((val) & ((mask) << (shift))) >> (shift)) 1.108 + 1.109 + static inline size_t UNUSED 1.110 +-ucs2len(const uint16_t * const s, ssize_t limit) 1.111 ++ucs2len(const void *vs, ssize_t limit) 1.112 + { 1.113 + ssize_t i; 1.114 +- for (i = 0; i < (limit >= 0 ? limit : i+1) && s[i] != (uint16_t)0; i++) 1.115 ++ const uint16_t *s = vs; 1.116 ++ const uint8_t *s8 = vs; 1.117 ++ 1.118 ++ for (i = 0; 1.119 ++ i < (limit >= 0 ? limit : i+1) && s8[0] != 0 && s8[1] != 0; 1.120 ++ i++, s8 += 2, s++) 1.121 + ; 1.122 + return i; 1.123 + } 1.124 + 1.125 + static inline size_t UNUSED 1.126 +-ucs2size(const uint16_t * const s, ssize_t limit) 1.127 ++ucs2size(const void *s, ssize_t limit) 1.128 + { 1.129 + size_t rc = ucs2len(s, limit); 1.130 + rc *= sizeof (uint16_t); 1.131 +@@ -69,10 +74,11 @@ utf8size(uint8_t *s, ssize_t limit) 1.132 + } 1.133 + 1.134 + static inline unsigned char * UNUSED 1.135 +-ucs2_to_utf8(const uint16_t * const chars, ssize_t limit) 1.136 ++ucs2_to_utf8(const void * const voidchars, ssize_t limit) 1.137 + { 1.138 + ssize_t i, j; 1.139 + unsigned char *ret; 1.140 ++ const uint16_t * const chars = voidchars; 1.141 + 1.142 + if (limit < 0) 1.143 + limit = ucs2len(chars, -1); 1.144 +@@ -124,10 +130,12 @@ ucs2_to_utf8(const uint16_t * const chars, ssize_t limit) 1.145 + } 1.146 + 1.147 + static inline ssize_t UNUSED NONNULL(4) 1.148 +-utf8_to_ucs2(uint16_t *ucs2, ssize_t size, int terminate, uint8_t *utf8) 1.149 ++utf8_to_ucs2(void *ucs2void, ssize_t size, int terminate, uint8_t *utf8) 1.150 + { 1.151 + ssize_t req; 1.152 + ssize_t i, j; 1.153 ++ uint16_t *ucs2 = ucs2void; 1.154 ++ uint16_t val16; 1.155 + 1.156 + if (!ucs2 && size > 0) { 1.157 + errno = EINVAL; 1.158 +@@ -162,10 +170,13 @@ utf8_to_ucs2(uint16_t *ucs2, ssize_t size, int terminate, uint8_t *utf8) 1.159 + val = utf8[i] & 0x7f; 1.160 + i += 1; 1.161 + } 1.162 +- ucs2[j] = val; 1.163 ++ val16 = val; 1.164 ++ ucs2[j] = val16; 1.165 ++ } 1.166 ++ if (terminate) { 1.167 ++ val16 = 0; 1.168 ++ ucs2[j++] = val16; 1.169 + } 1.170 +- if (terminate) 1.171 +- ucs2[j++] = (uint16_t)0; 1.172 + return j; 1.173 + }; 1.174 + 1.175 +-- 1.176 +2.20.1 1.177 + 1.178 +