From: Vladimir Serbinenko Date: Wed, 11 Dec 2013 14:54:01 +0000 (+0100) Subject: * include/grub/efi/api.h (grub_efi_device_path): Define length as X-Git-Tag: grub-2.02-beta1~114 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=219401b8b9f1fc870f514ffc6fbb0419e5613093;p=thirdparty%2Fgrub.git * include/grub/efi/api.h (grub_efi_device_path): Define length as unaligned u16 rather than u8[2]. --- diff --git a/ChangeLog b/ChangeLog index 37184be26..5aa70bb3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-12-11 Vladimir Serbinenko + + * include/grub/efi/api.h (grub_efi_device_path): Define length as + unaligned u16 rather than u8[2]. + 2013-12-11 Vladimir Serbinenko * grub-core/kern/ia64/dl.c (grub_arch_dl_relocate_symbols): Add checks diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 3a7876329..68f6d9f75 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -157,8 +157,7 @@ find_parent_device (struct grub_efidisk_data *devices, ldp = find_last_device_path (dp); ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; - ldp->length[0] = sizeof (*ldp); - ldp->length[1] = 0; + ldp->length = sizeof (*ldp); for (parent = devices; parent; parent = parent->next) { @@ -188,8 +187,7 @@ is_child (struct grub_efidisk_data *child, ldp = find_last_device_path (dp); ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; - ldp->length[0] = sizeof (*ldp); - ldp->length[1] = 0; + ldp->length = sizeof (*ldp); ret = (grub_efi_compare_device_paths (dp, parent->device_path) == 0); grub_free (dp); @@ -816,8 +814,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; - dup_ldp->length[0] = sizeof (*dup_ldp); - dup_ldp->length[1] = 0; + dup_ldp->length = sizeof (*dup_ldp); } if (!get_diskname_from_path (dup_dp, device_name)) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c index c0fed8068..233237018 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -122,9 +122,7 @@ copy_file_path (grub_efi_file_path_device_path_t *fp, if (*p == '/') *p = '\\'; - size = size * sizeof (grub_efi_char16_t) + sizeof (*fp); - fp->header.length[0] = (grub_efi_uint8_t) (size & 0xff); - fp->header.length[1] = (grub_efi_uint8_t) (size >> 8); + fp->header.length = size * sizeof (grub_efi_char16_t) + sizeof (*fp); } static grub_efi_device_path_t * @@ -184,8 +182,7 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) d = GRUB_EFI_NEXT_DEVICE_PATH (d); d->type = GRUB_EFI_END_DEVICE_PATH_TYPE; d->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; - d->length[0] = sizeof (*d); - d->length[1] = 0; + d->length = sizeof (*d); return file_path; } diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index 3af09111a..ac0389cac 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -544,8 +544,8 @@ struct grub_efi_device_path { grub_efi_uint8_t type; grub_efi_uint8_t subtype; - grub_efi_uint8_t length[2]; -}; + grub_efi_uint16_t length; +} __attribute__ ((packed)); typedef struct grub_efi_device_path grub_efi_device_path_t; /* XXX EFI does not define EFI_DEVICE_PATH_PROTOCOL but uses it. It seems to be identical to EFI_DEVICE_PATH. */ @@ -553,7 +553,7 @@ typedef struct grub_efi_device_path grub_efi_device_path_protocol_t; #define GRUB_EFI_DEVICE_PATH_TYPE(dp) ((dp)->type & 0x7f) #define GRUB_EFI_DEVICE_PATH_SUBTYPE(dp) ((dp)->subtype) -#define GRUB_EFI_DEVICE_PATH_LENGTH(dp) (grub_get_unaligned16 ((dp)->length)) +#define GRUB_EFI_DEVICE_PATH_LENGTH(dp) ((dp)->length) /* The End of Device Path nodes. */ #define GRUB_EFI_END_DEVICE_PATH_TYPE (0xff & 0x7f)