Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-efivar: Commit

external/efivar


Commit MetaInfo

Revisionc3c553db85ff10890209d0fe48fb4856ad68e4e0 (tree)
Time2019-02-22 05:27:09
AuthorPeter Jones <pjones@redh...>
CommiterPeter Jones

Log Message

Fix all the places -Werror=address-of-packed-member catches.

This gets rid of all the places GCC 9's -Werror=address-of-packed-member
flags as problematic.

Fixes github issue #123

Signed-off-by: Peter Jones <pjones@redhat.com>

Change Summary

Incremental Difference

--- a/src/dp-message.c
+++ b/src/dp-message.c
@@ -620,11 +620,13 @@ _format_message_dn(char *buf, size_t size, const_efidp dp)
620620 ) / sizeof(efi_ip_addr_t);
621621 format(buf, size, off, "Dns", "Dns(");
622622 for (int i=0; i < end; i++) {
623- const efi_ip_addr_t *addr = &dp->dns.addrs[i];
623+ efi_ip_addr_t addr;
624+
625+ memcpy(&addr, &dp->dns.addrs[i], sizeof(addr));
624626 if (i != 0)
625627 format(buf, size, off, "Dns", ",");
626628 format_ip_addr(buf, size, off, "Dns",
627- dp->dns.is_ipv6, addr);
629+ dp->dns.is_ipv6, &addr);
628630 }
629631 format(buf, size, off, "Dns", ")");
630632 break;
--- a/src/dp.h
+++ b/src/dp.h
@@ -71,13 +71,9 @@
7171 int _rc; \
7272 char *_guidstr = NULL; \
7373 efi_guid_t _guid; \
74- const efi_guid_t * const _guid_p = \
75- likely(__alignof__(guid) == sizeof(guid)) \
76- ? guid \
77- : &_guid; \
78- \
79- if (unlikely(__alignof__(guid) == sizeof(guid))) \
80- memmove(&_guid, guid, sizeof(_guid)); \
74+ const efi_guid_t * const _guid_p = &_guid; \
75+ \
76+ memmove(&_guid, guid, sizeof(_guid)); \
8177 _rc = efi_guid_to_str(_guid_p, &_guidstr); \
8278 if (_rc < 0) { \
8379 efi_error("could not build %s GUID DP string", \
@@ -86,7 +82,7 @@
8682 _guidstr = onstack(_guidstr, \
8783 strlen(_guidstr)+1); \
8884 _rc = format(buf, size, off, dp_type, "%s", \
89- _guidstr); \
85+ _guidstr); \
9086 } \
9187 _rc; \
9288 })
--- a/src/guid.c
+++ b/src/guid.c
@@ -31,7 +31,7 @@
3131 extern const efi_guid_t efi_guid_zero;
3232
3333 int NONNULL(1, 2) PUBLIC
34-efi_guid_cmp(const efi_guid_t *a, const efi_guid_t *b)
34+efi_guid_cmp(const void * const a, const void * const b)
3535 {
3636 return memcmp(a, b, sizeof (efi_guid_t));
3737 }
--- a/src/include/efivar/efivar.h
+++ b/src/include/efivar/efivar.h
@@ -128,7 +128,7 @@ extern int efi_symbol_to_guid(const char *symbol, efi_guid_t *guid)
128128
129129 extern int efi_guid_is_zero(const efi_guid_t *guid);
130130 extern int efi_guid_is_empty(const efi_guid_t *guid);
131-extern int efi_guid_cmp(const efi_guid_t *a, const efi_guid_t *b);
131+extern int efi_guid_cmp(const void * const a, const void * const b);
132132
133133 /* import / export functions */
134134 typedef struct efi_variable efi_variable_t;
--- a/src/ucs2.h
+++ b/src/ucs2.h
@@ -23,16 +23,21 @@
2323 (((val) & ((mask) << (shift))) >> (shift))
2424
2525 static inline size_t UNUSED
26-ucs2len(const uint16_t * const s, ssize_t limit)
26+ucs2len(const void *vs, ssize_t limit)
2727 {
2828 ssize_t i;
29- for (i = 0; i < (limit >= 0 ? limit : i+1) && s[i] != (uint16_t)0; i++)
29+ const uint16_t *s = vs;
30+ const uint8_t *s8 = vs;
31+
32+ for (i = 0;
33+ i < (limit >= 0 ? limit : i+1) && s8[0] != 0 && s8[1] != 0;
34+ i++, s8 += 2, s++)
3035 ;
3136 return i;
3237 }
3338
3439 static inline size_t UNUSED
35-ucs2size(const uint16_t * const s, ssize_t limit)
40+ucs2size(const void *s, ssize_t limit)
3641 {
3742 size_t rc = ucs2len(s, limit);
3843 rc *= sizeof (uint16_t);
@@ -69,10 +74,11 @@ utf8size(uint8_t *s, ssize_t limit)
6974 }
7075
7176 static inline unsigned char * UNUSED
72-ucs2_to_utf8(const uint16_t * const chars, ssize_t limit)
77+ucs2_to_utf8(const void * const voidchars, ssize_t limit)
7378 {
7479 ssize_t i, j;
7580 unsigned char *ret;
81+ const uint16_t * const chars = voidchars;
7682
7783 if (limit < 0)
7884 limit = ucs2len(chars, -1);
@@ -124,10 +130,12 @@ ucs2_to_utf8(const uint16_t * const chars, ssize_t limit)
124130 }
125131
126132 static inline ssize_t UNUSED NONNULL(4)
127-utf8_to_ucs2(uint16_t *ucs2, ssize_t size, int terminate, uint8_t *utf8)
133+utf8_to_ucs2(void *ucs2void, ssize_t size, int terminate, uint8_t *utf8)
128134 {
129135 ssize_t req;
130136 ssize_t i, j;
137+ uint16_t *ucs2 = ucs2void;
138+ uint16_t val16;
131139
132140 if (!ucs2 && size > 0) {
133141 errno = EINVAL;
@@ -162,10 +170,13 @@ utf8_to_ucs2(uint16_t *ucs2, ssize_t size, int terminate, uint8_t *utf8)
162170 val = utf8[i] & 0x7f;
163171 i += 1;
164172 }
165- ucs2[j] = val;
173+ val16 = val;
174+ ucs2[j] = val16;
175+ }
176+ if (terminate) {
177+ val16 = 0;
178+ ucs2[j++] = val16;
166179 }
167- if (terminate)
168- ucs2[j++] = (uint16_t)0;
169180 return j;
170181 };
171182
Show on old repository browser