efi_loader: Fix warnings for unaligned accesses
authorIlias Apalodimas <ilias.apalodimas@linaro.org>
Thu, 11 May 2023 16:40:35 +0000 (19:40 +0300)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sat, 13 May 2023 09:09:51 +0000 (11:09 +0200)
commit7dfab39855897418c05ccb6f4213c840f91d1c30
tree44bbe49c4fa81c5b4ea94a93140883efbef00874
parent227d3b3e0af02918592dda19aefa379e9ea20887
efi_loader: Fix warnings for unaligned accesses

Tom reports that when building with clang we see this warning:
field guid within 'struct efi_hii_keyboard_layout' is less aligned than 'efi_guid_t' and is usually due to 'struct efi_hii_keyboard_layout' being packed, which can lead to unaligned accesses [-Wunaligned-access]

This happens because 'struct efi_hii_keyboard_layout' is defined as
packed and thus has 1-byte alignment but efi_guid_t is a type that
requires greater alignment than that.

However the EFI spec describes the EFI_GUID as
"128-bit buffer containing a unique identifier value.
Unless otherwise specified"

So convert the efi_guid_t -> u8 b[16] here and skip the alignment
requirements.  Since the struct is packed to begin with, it makes no
difference on the final memory layout.

Suggested-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
include/efi_api.h