[U-Boot,v2,1/1] disk: efi: avoid unaligned pointer error
diff mbox series

Message ID 20190716220600.2747-1-xypron.glpk@gmx.de
State Accepted, archived
Delegated to: Heinrich Schuchardt
Headers show
Series
  • [U-Boot,v2,1/1] disk: efi: avoid unaligned pointer error
Related show

Commit Message

Heinrich Schuchardt July 16, 2019, 10:06 p.m. UTC
When building with GCC 9.1 an error occurs:

disk/part_efi.c: In function ‘gpt_verify_partitions’:
disk/part_efi.c:737:49: error: taking address of packed member of
‘struct _gpt_entry’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
  737 |   gpt_convert_efi_name_to_char(efi_str, gpt_e[i].partition_name,
      |                                         ~~~~~~~~^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [scripts/Makefile.build:279: disk/part_efi.o] Error 1
make: *** [Makefile:1594: disk] Error 2

Adjust gpt_convert_efi_name_to_char() to accept unaligned strings.

Reported-by: Ramon Fried <rfried.dev@gmail.com>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2
	remove unrelated change
---
 disk/part_efi.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

--
2.20.1

Patch
diff mbox series

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 3e026697db..359b55a818 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -670,9 +670,18 @@  err:
 	return ret;
 }

-static void gpt_convert_efi_name_to_char(char *s, efi_char16_t *es, int n)
+/**
+ * gpt_convert_efi_name_to_char() - convert u16 string to char string
+ *
+ * TODO: this conversion only supports ANSI characters
+ *
+ * @s:	target buffer
+ * @es:	u16 string to be converted
+ * @n:	size of target buffer
+ */
+static void gpt_convert_efi_name_to_char(char *s, void *es, int n)
 {
-	char *ess = (char *)es;
+	char *ess = es;
 	int i, j;

 	memset(s, '\0', n);