Update for some compiler warning fixes.

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2019-11-12 13:23:45 -05:00
parent aba94f63cc
commit acb7ffc5e0
11 changed files with 6726 additions and 1 deletions

View File

@ -0,0 +1,33 @@
From cb0b1c30103abc17dbbed14210bbc59a73802206 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 7 Jan 2019 10:30:23 -0500
Subject: [PATCH 01/10] util.h: add unlikely() and likely() macros
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/util.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/util.h b/src/util.h
index f63a8907611..ba8fee35ae9 100644
--- a/src/util.h
+++ b/src/util.h
@@ -52,6 +52,15 @@
#define PACKED __attribute__((__packed__))
#define VERSION(sym, ver) __asm__(".symver " # sym "," # ver)
+#define __branch_check__(x, expect, is_constant) \
+ __builtin_expect(!!(x), expect)
+#ifndef likely
+#define likely(x) (__branch_check__(x, 1, __builtin_constant_p(x)))
+#endif
+#ifndef unlikely
+#define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x)))
+#endif
+
/*
* I'm not actually sure when these appear, but they're present in the
* version in front of me.
--
2.23.0

View File

@ -0,0 +1,59 @@
From b98ba8921010d03f46704a476c69861515deb1ca Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 7 Jan 2019 10:30:59 -0500
Subject: [PATCH 02/10] dp.h: make format_guid() handle misaligned guid
pointers safely.
GCC 9 adds -Werror=address-of-packed-member, which causes us to see the
build error reported at
https://bugzilla.opensuse.org/show_bug.cgi?id=1120862 .
That bug report shows us the following:
In file included from dp.c:26:
dp.h: In function 'format_vendor_helper':
dp.h:120:37: error: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Werror=address-of-packed-member]
120 | format_guid(buf, size, off, label, &dp->hw_vendor.vendor_guid);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
dp.h:74:25: note: in definition of macro 'format_guid'
74 | _rc = efi_guid_to_str(guid, &_guidstr); \
| ^~~~
cc1: all warnings being treated as errors
This patch makes format_guid() use a local variable as a bounce buffer
in the case that the guid we're passed is aligned as chaotic neutral.
Note that this only fixes this instance and there may be others that bz
didn't show because it exited too soon, and I don't have a gcc 9 build
in front of me right now.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/dp.h | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/dp.h b/src/dp.h
index aa4e3902992..20cb608d05f 100644
--- a/src/dp.h
+++ b/src/dp.h
@@ -70,8 +70,15 @@
#define format_guid(buf, size, off, dp_type, guid) ({ \
int _rc; \
char *_guidstr = NULL; \
- \
- _rc = efi_guid_to_str(guid, &_guidstr); \
+ efi_guid_t _guid; \
+ const efi_guid_t * const _guid_p = \
+ likely(__alignof__(guid) == sizeof(guid)) \
+ ? guid \
+ : &_guid; \
+ \
+ if (unlikely(__alignof__(guid) == sizeof(guid))) \
+ memmove(&_guid, guid, sizeof(_guid)); \
+ _rc = efi_guid_to_str(_guid_p, &_guidstr); \
if (_rc < 0) { \
efi_error("could not build %s GUID DP string", \
dp_type); \
--
2.23.0

View File

@ -0,0 +1,27 @@
From 8f803791a1c97a4d1bce049264218a94c46d7838 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 7 Jan 2019 11:32:41 -0500
Subject: [PATCH 03/10] linux-pci-root: remove an unused assignment
scan-build gripes about this, and it's pointless, so it can go.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/linux-pci-root.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/linux-pci-root.c b/src/linux-pci-root.c
index a2d9fb04a11..5d1df06119d 100644
--- a/src/linux-pci-root.c
+++ b/src/linux-pci-root.c
@@ -115,7 +115,6 @@ dp_create_pci_root(struct device *dev UNUSED,
return new;
}
}
- off += new;
sz += new;
debug("returning %zd", sz);
--
2.23.0

View File

@ -0,0 +1,172 @@
From c3c553db85ff10890209d0fe48fb4856ad68e4e0 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 21 Feb 2019 15:20:12 -0500
Subject: [PATCH 04/10] 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>
---
src/dp-message.c | 6 ++++--
src/dp.h | 12 ++++--------
src/guid.c | 2 +-
src/include/efivar/efivar.h | 2 +-
src/ucs2.h | 27 +++++++++++++++++++--------
5 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/src/dp-message.c b/src/dp-message.c
index 3724e5f57bd..9f964663de8 100644
--- 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)
) / sizeof(efi_ip_addr_t);
format(buf, size, off, "Dns", "Dns(");
for (int i=0; i < end; i++) {
- const efi_ip_addr_t *addr = &dp->dns.addrs[i];
+ efi_ip_addr_t addr;
+
+ memcpy(&addr, &dp->dns.addrs[i], sizeof(addr));
if (i != 0)
format(buf, size, off, "Dns", ",");
format_ip_addr(buf, size, off, "Dns",
- dp->dns.is_ipv6, addr);
+ dp->dns.is_ipv6, &addr);
}
format(buf, size, off, "Dns", ")");
break;
diff --git a/src/dp.h b/src/dp.h
index 20cb608d05f..1f921d524aa 100644
--- a/src/dp.h
+++ b/src/dp.h
@@ -71,13 +71,9 @@
int _rc; \
char *_guidstr = NULL; \
efi_guid_t _guid; \
- const efi_guid_t * const _guid_p = \
- likely(__alignof__(guid) == sizeof(guid)) \
- ? guid \
- : &_guid; \
- \
- if (unlikely(__alignof__(guid) == sizeof(guid))) \
- memmove(&_guid, guid, sizeof(_guid)); \
+ const efi_guid_t * const _guid_p = &_guid; \
+ \
+ memmove(&_guid, guid, sizeof(_guid)); \
_rc = efi_guid_to_str(_guid_p, &_guidstr); \
if (_rc < 0) { \
efi_error("could not build %s GUID DP string", \
@@ -86,7 +82,7 @@
_guidstr = onstack(_guidstr, \
strlen(_guidstr)+1); \
_rc = format(buf, size, off, dp_type, "%s", \
- _guidstr); \
+ _guidstr); \
} \
_rc; \
})
diff --git a/src/guid.c b/src/guid.c
index 306c9ff8287..3156b3b7c60 100644
--- a/src/guid.c
+++ b/src/guid.c
@@ -31,7 +31,7 @@
extern const efi_guid_t efi_guid_zero;
int NONNULL(1, 2) PUBLIC
-efi_guid_cmp(const efi_guid_t *a, const efi_guid_t *b)
+efi_guid_cmp(const void * const a, const void * const b)
{
return memcmp(a, b, sizeof (efi_guid_t));
}
diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h
index 316891ccae9..ad6449d9d93 100644
--- 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)
extern int efi_guid_is_zero(const efi_guid_t *guid);
extern int efi_guid_is_empty(const efi_guid_t *guid);
-extern int efi_guid_cmp(const efi_guid_t *a, const efi_guid_t *b);
+extern int efi_guid_cmp(const void * const a, const void * const b);
/* import / export functions */
typedef struct efi_variable efi_variable_t;
diff --git a/src/ucs2.h b/src/ucs2.h
index dbb59004b7c..edd8367b4bc 100644
--- a/src/ucs2.h
+++ b/src/ucs2.h
@@ -23,16 +23,21 @@
(((val) & ((mask) << (shift))) >> (shift))
static inline size_t UNUSED
-ucs2len(const uint16_t * const s, ssize_t limit)
+ucs2len(const void *vs, ssize_t limit)
{
ssize_t i;
- for (i = 0; i < (limit >= 0 ? limit : i+1) && s[i] != (uint16_t)0; i++)
+ const uint16_t *s = vs;
+ const uint8_t *s8 = vs;
+
+ for (i = 0;
+ i < (limit >= 0 ? limit : i+1) && s8[0] != 0 && s8[1] != 0;
+ i++, s8 += 2, s++)
;
return i;
}
static inline size_t UNUSED
-ucs2size(const uint16_t * const s, ssize_t limit)
+ucs2size(const void *s, ssize_t limit)
{
size_t rc = ucs2len(s, limit);
rc *= sizeof (uint16_t);
@@ -69,10 +74,11 @@ utf8size(uint8_t *s, ssize_t limit)
}
static inline unsigned char * UNUSED
-ucs2_to_utf8(const uint16_t * const chars, ssize_t limit)
+ucs2_to_utf8(const void * const voidchars, ssize_t limit)
{
ssize_t i, j;
unsigned char *ret;
+ const uint16_t * const chars = voidchars;
if (limit < 0)
limit = ucs2len(chars, -1);
@@ -124,10 +130,12 @@ ucs2_to_utf8(const uint16_t * const chars, ssize_t limit)
}
static inline ssize_t UNUSED NONNULL(4)
-utf8_to_ucs2(uint16_t *ucs2, ssize_t size, int terminate, uint8_t *utf8)
+utf8_to_ucs2(void *ucs2void, ssize_t size, int terminate, uint8_t *utf8)
{
ssize_t req;
ssize_t i, j;
+ uint16_t *ucs2 = ucs2void;
+ uint16_t val16;
if (!ucs2 && size > 0) {
errno = EINVAL;
@@ -162,10 +170,13 @@ utf8_to_ucs2(uint16_t *ucs2, ssize_t size, int terminate, uint8_t *utf8)
val = utf8[i] & 0x7f;
i += 1;
}
- ucs2[j] = val;
+ val16 = val;
+ ucs2[j] = val16;
+ }
+ if (terminate) {
+ val16 = 0;
+ ucs2[j++] = val16;
}
- if (terminate)
- ucs2[j++] = (uint16_t)0;
return j;
};
--
2.23.0

View File

@ -0,0 +1,372 @@
From e39fb5b9e590c6616459c15b5d95fbc09fb077d6 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 21 Feb 2019 15:26:23 -0500
Subject: [PATCH 05/10] Get rid of the arrows in our debug messages.
They're not *that* useful, and the code is clever and problematic.
Resolves github issue #124
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/linux-acpi-root.c | 7 -------
src/linux-emmc.c | 9 ---------
src/linux-md.c | 8 --------
src/linux-nvme.c | 9 ---------
src/linux-pci-root.c | 7 -------
src/linux-pci.c | 8 --------
src/linux-sata.c | 11 -----------
src/linux-scsi.c | 24 ------------------------
src/linux-soc-root.c | 7 -------
src/linux-virtblk.c | 8 --------
src/util.h | 1 -
11 files changed, 99 deletions(-)
diff --git a/src/linux-acpi-root.c b/src/linux-acpi-root.c
index 06e69eebe78..30728ded671 100644
--- a/src/linux-acpi-root.c
+++ b/src/linux-acpi-root.c
@@ -51,13 +51,6 @@ parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED
char *colon;
const char *devpart = current;
- char *spaces;
-
- pos = strlen(current);
- spaces = alloca(pos+1);
- memset(spaces, ' ', pos+1);
- spaces[pos] = '\0';
- pos = 0;
debug("entry");
diff --git a/src/linux-emmc.c b/src/linux-emmc.c
index 87e92477554..b290ed0a2bd 100644
--- a/src/linux-emmc.c
+++ b/src/linux-emmc.c
@@ -50,13 +50,6 @@ parse_emmc(struct device *dev, const char *current, const char *root UNUSED)
int rc;
int32_t tosser0, tosser1, tosser2, tosser3, slot_id, partition;
int pos0 = 0, pos1 = 0;
- char *spaces;
-
- pos0 = strlen(current);
- spaces = alloca(pos0+1);
- memset(spaces, ' ', pos0+1);
- spaces[pos0] = '\0';
- pos0 = 0;
debug("entry");
@@ -65,8 +58,6 @@ parse_emmc(struct device *dev, const char *current, const char *root UNUSED)
&tosser0, &tosser1, &tosser2, &slot_id,
&pos0, &tosser3, &partition, &pos1);
debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 4);
- arrow(LOG_DEBUG, spaces, 9, pos1, rc, 6);
/*
* If it isn't of that form, it's not one of our emmc devices.
*/
diff --git a/src/linux-md.c b/src/linux-md.c
index 0a5c1cdb435..cb584c96c4b 100644
--- a/src/linux-md.c
+++ b/src/linux-md.c
@@ -44,13 +44,6 @@ parse_md(struct device *dev, const char *current, const char *root UNUSED)
int rc;
int32_t md, tosser0, part;
int pos0 = 0, pos1 = 0;
- char *spaces;
-
- pos0 = strlen(current);
- spaces = alloca(pos0+1);
- memset(spaces, ' ', pos0+1);
- spaces[pos0] = '\0';
- pos0 = 0;
debug("entry");
@@ -58,7 +51,6 @@ parse_md(struct device *dev, const char *current, const char *root UNUSED)
rc = sscanf(current, "md%d/%nmd%dp%d%n",
&md, &pos0, &tosser0, &part, &pos1);
debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
/*
* If it isn't of that form, it's not one of our partitioned md devices.
*/
diff --git a/src/linux-nvme.c b/src/linux-nvme.c
index d68d11a3409..1d8fc654f76 100644
--- a/src/linux-nvme.c
+++ b/src/linux-nvme.c
@@ -54,13 +54,6 @@ parse_nvme(struct device *dev, const char *current, const char *root UNUSED)
int32_t tosser0, tosser1, tosser2, ctrl_id, ns_id, partition;
uint8_t *filebuf = NULL;
int pos0 = 0, pos1 = 0;
- char *spaces;
-
- pos0 = strlen(current);
- spaces = alloca(pos0+1);
- memset(spaces, ' ', pos0+1);
- spaces[pos0] = '\0';
- pos0 = 0;
debug("entry");
@@ -69,8 +62,6 @@ parse_nvme(struct device *dev, const char *current, const char *root UNUSED)
&tosser0, &ctrl_id, &ns_id, &pos0,
&tosser1, &tosser2, &partition, &pos1);
debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
- arrow(LOG_DEBUG, spaces, 9, pos1, rc, 6);
/*
* If it isn't of that form, it's not one of our nvme devices.
*/
diff --git a/src/linux-pci-root.c b/src/linux-pci-root.c
index 5d1df06119d..0605acfc7cb 100644
--- a/src/linux-pci-root.c
+++ b/src/linux-pci-root.c
@@ -48,13 +48,6 @@ parse_pci_root(struct device *dev, const char *current, const char *root UNUSED)
uint16_t root_domain;
uint8_t root_bus;
const char *devpart = current;
- char *spaces;
-
- pos = strlen(current);
- spaces = alloca(pos+1);
- memset(spaces, ' ', pos+1);
- spaces[pos] = '\0';
- pos = 0;
debug("entry");
diff --git a/src/linux-pci.c b/src/linux-pci.c
index f63f5914d9f..64aaefb461c 100644
--- a/src/linux-pci.c
+++ b/src/linux-pci.c
@@ -48,13 +48,6 @@ parse_pci(struct device *dev, const char *current, const char *root)
int rc;
int pos;
const char *devpart = current;
- char *spaces;
-
- pos = strlen(current);
- spaces = alloca(pos+1);
- memset(spaces, ' ', pos+1);
- spaces[pos] = '\0';
- pos = 0;
debug("entry");
@@ -75,7 +68,6 @@ parse_pci(struct device *dev, const char *current, const char *root)
rc = sscanf(devpart, "%hx:%hhx:%hhx.%hhx/%n",
&domain, &bus, &device, &function, &pos);
debug("current:\"%s\" rc:%d pos:%d", devpart, rc, pos);
- arrow(LOG_DEBUG, spaces, 9, pos, rc, 3);
if (rc != 4)
break;
devpart += pos;
diff --git a/src/linux-sata.c b/src/linux-sata.c
index 85265022f89..356411724bb 100644
--- a/src/linux-sata.c
+++ b/src/linux-sata.c
@@ -148,13 +148,6 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
uint64_t scsi_lun, tosser3;
int pos = 0;
int rc;
- char *spaces;
-
- pos = strlen(current);
- spaces = alloca(pos+1);
- memset(spaces, ' ', pos+1);
- spaces[pos] = '\0';
- pos = 0;
debug("entry");
if (is_pata(dev)) {
@@ -169,7 +162,6 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
debug("searching for ata1/");
rc = sscanf(current, "ata%"PRIu32"/%n", &print_id, &pos);
debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
- arrow(LOG_DEBUG, spaces, 9, pos, rc, 1);
/*
* If we don't find this one, it isn't an ata device, so return 0 not
* error. Later errors mean it is an ata device, but we can't parse
@@ -183,7 +175,6 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
debug("searching for host0/");
rc = sscanf(current, "host%"PRIu32"/%n", &scsi_bus, &pos);
debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
- arrow(LOG_DEBUG, spaces, 9, pos, rc, 1);
if (rc != 1)
return -1;
current += pos;
@@ -193,7 +184,6 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
rc = sscanf(current, "target%"PRIu32":%"PRIu32":%"PRIu64"/%n",
&scsi_device, &scsi_target, &scsi_lun, &pos);
debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
- arrow(LOG_DEBUG, spaces, 9, pos, rc, 3);
if (rc != 3)
return -1;
current += pos;
@@ -203,7 +193,6 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
rc = sscanf(current, "%"PRIu32":%"PRIu32":%"PRIu32":%"PRIu64"/%n",
&tosser0, &tosser1, &tosser2, &tosser3, &pos);
debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
- arrow(LOG_DEBUG, spaces, 9, pos, rc, 4);
if (rc != 4)
return -1;
current += pos;
diff --git a/src/linux-scsi.c b/src/linux-scsi.c
index a5e81cf9cb6..04892f02b4e 100644
--- a/src/linux-scsi.c
+++ b/src/linux-scsi.c
@@ -45,13 +45,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
int rc;
int sz = 0;
int pos0 = 0, pos1 = 0;
- char *spaces;
-
- sz = strlen(current);
- spaces = alloca(sz+1);
- memset(spaces, ' ', sz+1);
- spaces[sz] = '\0';
- sz = 0;
debug("entry");
/*
@@ -108,7 +101,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
debug("searching for host4/");
rc = sscanf(current, "host%d/%n", scsi_host, &pos0);
debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 1);
if (rc != 1)
return -1;
sz += pos0;
@@ -126,8 +118,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
rc = sscanf(current+sz, "port-%d:%d%n:%d%n", &tosser0,
&tosser1, &pos0, &tosser2, &pos1);
debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current+sz, rc, pos0, pos1);
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2);
- arrow(LOG_DEBUG, spaces, 9, pos1, rc, 3);
if (rc == 2 || rc == 3) {
sz += pos0;
pos0 = 0;
@@ -153,7 +143,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
debug("searching for expander-4:0/");
rc = sscanf(current+sz, "expander-%d:%d/%n", &tosser0, &tosser1, &pos0);
debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2);
if (rc == 2) {
if (!remote_target_id) {
efi_error("Device is PHY is a remote target, but remote_target_id is NULL");
@@ -169,7 +158,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
debug("searching for port-2:0:2/");
rc = sscanf(current+sz, "port-%d:%d:%d/%n", &tosser0, &tosser1, &tosser2, &pos0);
debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
if (rc != 3) {
efi_error("Couldn't parse port expander port string");
return -1;
@@ -192,8 +180,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
pos1 = 0;
rc = sscanf(current + sz + pos0, ":%d%n", &tosser2, &pos1);
- arrow(LOG_DEBUG, spaces, 9, pos0, rc + 2, 2);
- arrow(LOG_DEBUG, spaces, 9, pos0 + pos1, rc + 2, 3);
if (rc != 0 && rc != 1)
return -1;
if (remote_port_id && rc == 1)
@@ -217,7 +203,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
rc = sscanf(current + sz, "target%d:%d:%"PRIu64"/%n", &tosser0, &tosser1,
&tosser3, &pos0);
debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
if (rc != 3)
return -1;
sz += pos0;
@@ -230,7 +215,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
rc = sscanf(current + sz, "%d:%d:%d:%"PRIu64"/%n",
scsi_bus, scsi_device, scsi_target, scsi_lun, &pos0);
debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 4);
if (rc != 4)
return -1;
sz += pos0;
@@ -247,13 +231,6 @@ parse_scsi(struct device *dev, const char *current, const char *root UNUSED)
ssize_t sz;
int pos;
int rc;
- char *spaces;
-
- pos = strlen(current);
- spaces = alloca(pos+1);
- memset(spaces, ' ', pos+1);
- spaces[pos] = '\0';
- pos = 0;
debug("entry");
@@ -265,7 +242,6 @@ parse_scsi(struct device *dev, const char *current, const char *root UNUSED)
&dev->scsi_info.scsi_lun,
&pos);
debug("current:\"%s\" rc:%d pos:%d\n", dev->device, rc, pos);
- arrow(LOG_DEBUG, spaces, 9, pos, rc, 3);
if (rc != 4)
return 0;
diff --git a/src/linux-soc-root.c b/src/linux-soc-root.c
index 394f496a453..373cd59521a 100644
--- a/src/linux-soc-root.c
+++ b/src/linux-soc-root.c
@@ -43,13 +43,6 @@ parse_soc_root(struct device *dev UNUSED, const char *current, const char *root
int rc;
int pos;
const char *devpart = current;
- char *spaces;
-
- pos = strlen(current);
- spaces = alloca(pos+1);
- memset(spaces, ' ', pos+1);
- spaces[pos] = '\0';
- pos = 0;
debug("entry");
diff --git a/src/linux-virtblk.c b/src/linux-virtblk.c
index c54a813a947..2e9889def2f 100644
--- a/src/linux-virtblk.c
+++ b/src/linux-virtblk.c
@@ -50,20 +50,12 @@ parse_virtblk(struct device *dev, const char *current, const char *root UNUSED)
uint32_t tosser;
int pos;
int rc;
- char *spaces;
-
- pos = strlen(current);
- spaces = alloca(pos+1);
- memset(spaces, ' ', pos+1);
- spaces[pos] = '\0';
- pos = 0;
debug("entry");
debug("searching for virtio0/");
rc = sscanf(current, "virtio%x/%n", &tosser, &pos);
debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
- arrow(LOG_DEBUG, spaces, 9, pos, rc, 1);
/*
* If we couldn't find virtioX/ then it isn't a virtio device.
*/
diff --git a/src/util.h b/src/util.h
index ba8fee35ae9..6d3c10e946e 100644
--- a/src/util.h
+++ b/src/util.h
@@ -388,7 +388,6 @@ swizzle_guid_to_uuid(efi_guid_t *guid)
#undef log
#endif
#define log(level, fmt, args...) log_(__FILE__, __LINE__, __func__, level, fmt, ## args)
-#define arrow(l,b,o,p,n,m) ({if(n==m){char c_=b[p+1]; b[o]='^'; b[p+o]='^';b[p+o+1]='\0';log(l,"%s",b);b[o]=' ';b[p+o]=' ';b[p+o+1]=c_;}})
#define debug(fmt, args...) log(LOG_DEBUG, fmt, ## args)
#endif /* EFIVAR_UTIL_H */
--
2.23.0

View File

@ -0,0 +1,38 @@
From 25d73605b36933004b0266183de8051af30612ca Mon Sep 17 00:00:00 2001
From: Chih-Wei Huang <cwhuang@linux.org.tw>
Date: Thu, 10 Jan 2019 16:44:38 +0800
Subject: [PATCH 06/10] Define strdupa if it is not defined
Android does not include strdupa in <string.h>. Define strdupa if it has
not already been defined.
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
---
src/util.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/util.h b/src/util.h
index 6d3c10e946e..d98bfa1beed 100644
--- a/src/util.h
+++ b/src/util.h
@@ -252,6 +252,17 @@ lcm(uint64_t x, uint64_t y)
return (x / n) * y;
}
+#ifndef strdupa
+#define strdupa(s) \
+ (__extension__ ({ \
+ const char *__in = (s); \
+ size_t __len = strlen (__in); \
+ char *__out = (char *) alloca (__len + 1); \
+ strcpy(__out, __in); \
+ __out; \
+ }))
+#endif
+
#ifndef strndupa
#define strndupa(s, l) \
(__extension__ ({ \
--
2.23.0

View File

@ -0,0 +1,82 @@
From 1a0ea5da82d8be7d05338bb42e8e71cdba7866f4 Mon Sep 17 00:00:00 2001
From: Chih-Wei Huang <cwhuang@linux.org.tw>
Date: Thu, 10 Jan 2019 16:48:30 +0800
Subject: [PATCH 07/10] Android: inital porting of libefivar
The static library is linked by efibootmgr.
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
---
src/Android.mk | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
create mode 100644 src/Android.mk
diff --git a/src/Android.mk b/src/Android.mk
new file mode 100644
index 00000000000..b3410e1f3e7
--- /dev/null
+++ b/src/Android.mk
@@ -0,0 +1,60 @@
+#
+# Copyright (C) 2019 The Android-x86 Open Source Project
+#
+# Licensed under the GNU Lesser General Public License Version 2.1.
+# You may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.gnu.org/licenses/lgpl-2.1.html
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := makeguids
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_CFLAGS := -DEFIVAR_BUILD_ENVIRONMENT
+LOCAL_SRC_FILES := guid.c makeguids.c
+LOCAL_LDLIBS := -ldl
+include $(BUILD_HOST_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libefivar
+LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+LIBEFIBOOT_SOURCES := \
+ crc32.c \
+ creator.c \
+ disk.c \
+ gpt.c \
+ loadopt.c \
+ path-helpers.c \
+ $(notdir $(wildcard $(LOCAL_PATH)/linux*.c))
+
+LIBEFIVAR_SOURCES := \
+ dp.c \
+ dp-acpi.c \
+ dp-hw.c \
+ dp-media.c \
+ dp-message.c \
+ efivarfs.c \
+ error.c \
+ export.c \
+ guid.c \
+ guids.S \
+ lib.c \
+ vars.c
+
+LOCAL_SRC_FILES := $(LIBEFIBOOT_SOURCES) $(LIBEFIVAR_SOURCES)
+LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -std=gnu11
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_C_INCLUDES) $(LOCAL_C_INCLUDES)/efivar $(local-generated-sources-dir)
+LIBEFIVAR_GUIDS_H := $(local-generated-sources-dir)/efivar/efivar-guids.h
+LOCAL_GENERATED_SOURCES := $(LIBEFIVAR_GUIDS_H) $(local-generated-sources-dir)/guid-symbols.c
+$(LIBEFIVAR_GUIDS_H): PRIVATE_CUSTOM_TOOL = $^ $(addprefix $(dir $(@D)),guids.bin names.bin guid-symbols.c efivar/efivar-guids.h)
+$(LIBEFIVAR_GUIDS_H): $(BUILD_OUT_EXECUTABLES)/makeguids $(LOCAL_PATH)/guids.txt
+ $(transform-generated-source)
+$(lastword $(LOCAL_GENERATED_SOURCES)): $(LIBEFIVAR_GUIDS_H)
+
+include $(BUILD_STATIC_LIBRARY)
--
2.23.0

View File

@ -0,0 +1,40 @@
From 22da79a45a0c3a1437255c813b0b86a7b7925ae3 Mon Sep 17 00:00:00 2001
From: Chih-Wei Huang <cwhuang@linux.org.tw>
Date: Tue, 26 Feb 2019 14:57:00 +0800
Subject: [PATCH 08/10] Remove an unused function
This gets rid of an error from Android 9 clang:
external/efivar/src/linux.c:256:1: error: unused function 'supports_iface' [-Werror,-Wunused-function]
supports_iface(struct dev_probe *probe, enum interface_type iftype)
^
1 error generated.
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
---
src/linux.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/src/linux.c b/src/linux.c
index 6d405af8a76..4bb453be834 100644
--- a/src/linux.c
+++ b/src/linux.c
@@ -252,15 +252,6 @@ static struct dev_probe *dev_probes[] = {
NULL
};
-static inline bool
-supports_iface(struct dev_probe *probe, enum interface_type iftype)
-{
- for (unsigned int i = 0; probe->iftypes[i] != unknown; i++)
- if (probe->iftypes[i] == iftype)
- return true;
- return false;
-}
-
void HIDDEN
device_free(struct device *dev)
{
--
2.23.0

View File

@ -0,0 +1,54 @@
From 0dad6d78a7fb5f6c5fb4a1d646040539db6cf865 Mon Sep 17 00:00:00 2001
From: Chih-Wei Huang <cwhuang@linux.org.tw>
Date: Tue, 26 Feb 2019 18:42:20 +0800
Subject: [PATCH 09/10] Fix another error of -Werror=address-of-packed-member
Android 9 clang complains:
external/efivar/src/dp-message.c:367:24: error: taking address of packed member '' of class or structure 'efidp_infiniband' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member]
(efi_guid_t *)&dp->infiniband.ioc_guid);
^~~~~~~~~~~~~~~~~~~~~~~
external/efivar/src/dp.h:76:19: note: expanded from macro 'format_guid'
memmove(&_guid, guid, sizeof(_guid)); \
^~~~
1 error generated.
Since commit c3c553d the fifth parameter of format_guid() is treated as
a const void *. The casting is unnecessary.
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
---
src/dp-media.c | 3 +--
src/dp-message.c | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/dp-media.c b/src/dp-media.c
index 96a576fdc2a..be691c44326 100644
--- a/src/dp-media.c
+++ b/src/dp-media.c
@@ -46,8 +46,7 @@ _format_media_dn(char *buf, size_t size, const_efidp dp)
break;
case EFIDP_HD_SIGNATURE_GUID:
format(buf, size, off, "HD", "GPT,");
- format_guid(buf, size, off, "HD",
- (efi_guid_t *)dp->hd.signature);
+ format_guid(buf, size, off, "HD", dp->hd.signature);
format(buf, size, off, "HD",
",0x%"PRIx64",0x%"PRIx64")",
dp->hd.start, dp->hd.size);
diff --git a/src/dp-message.c b/src/dp-message.c
index 9f964663de8..6b8e9072594 100644
--- a/src/dp-message.c
+++ b/src/dp-message.c
@@ -364,7 +364,7 @@ _format_message_dn(char *buf, size_t size, const_efidp dp)
dp->infiniband.port_gid[1],
dp->infiniband.port_gid[0]);
format_guid(buf, size, off, "Infiniband",
- (efi_guid_t *)&dp->infiniband.ioc_guid);
+ &dp->infiniband.ioc_guid);
format(buf, size, off, "Infiniband",
",%"PRIu64",%"PRIu64")",
dp->infiniband.target_port_id,
--
2.23.0

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
Name: efivar
Version: 37
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Tools to manage UEFI variables
License: LGPLv2.1
URL: https://github.com/rhboot/efivar
@ -13,6 +13,17 @@ BuildRequires: efi-srpm-macros git glibc-static libabigail
# to a different tarball.
Source0: https://github.com/rhboot/efivar/releases/download/%{version}/efivar-%{version}.tar.bz2
Patch0001: 0001-util.h-add-unlikely-and-likely-macros.patch
Patch0002: 0002-dp.h-make-format_guid-handle-misaligned-guid-pointer.patch
Patch0003: 0003-linux-pci-root-remove-an-unused-assignment.patch
Patch0004: 0004-Fix-all-the-places-Werror-address-of-packed-member-c.patch
Patch0005: 0005-Get-rid-of-the-arrows-in-our-debug-messages.patch
Patch0006: 0006-Define-strdupa-if-it-is-not-defined.patch
Patch0007: 0007-Android-inital-porting-of-libefivar.patch
Patch0008: 0008-Remove-an-unused-function.patch
Patch0009: 0009-Fix-another-error-of-Werror-address-of-packed-member.patch
Patch0010: 0010-Update-generated-ABI.patch
%description
efivar provides a simple command line interface to the UEFI variable facility.
@ -71,6 +82,10 @@ make abicheck
%{_libdir}/*.so.*
%changelog
* Tue Nov 12 2019 Peter Jones <pjones@redhat.com> - 37-4
- Update for some compiler warning fixes.
Resolves: rhbz#1735168
* Wed Jul 24 2019 Fedora Release Engineering <releng@fedoraproject.org> - 37-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild