From patchwork Fri Dec 13 03:33:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 300868 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 191762C00A0 for ; Fri, 13 Dec 2013 14:33:22 +1100 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1VrJV9-0005NC-PP; Fri, 13 Dec 2013 03:33:19 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1VrJV3-0005N7-MN for fwts-devel@lists.ubuntu.com; Fri, 13 Dec 2013 03:33:13 +0000 Received: from [175.41.48.77] (helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1VrJV2-00041a-Ol; Fri, 13 Dec 2013 03:33:13 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH] lib: fwts_uefi header add attribure packed for struct typedef Date: Fri, 13 Dec 2013 11:33:07 +0800 Message-Id: <1386905587-24177-1-git-send-email-ivan.hu@canonical.com> X-Mailer: git-send-email 1.7.9.5 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com Most of the structs are evaluated the size by sizeof() in the uefidump.c. Add the __attribute__((packed)) for these structs to avoid the padding size are added by using the sizeof. Signed-off-by: Ivan Hu Acked-by: Colin Ian King Acked-by: Alex Hung --- src/lib/include/fwts_uefi.h | 48 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h index c834d28..eed96f7 100644 --- a/src/lib/include/fwts_uefi.h +++ b/src/lib/include/fwts_uefi.h @@ -266,7 +266,7 @@ typedef struct { fwts_uefi_dev_path dev_path; uint32_t hid; uint32_t uid; -} fwts_uefi_acpi_dev_path; +} __attribute__((packed)) fwts_uefi_acpi_dev_path; typedef struct { fwts_uefi_dev_path dev_path; @@ -274,25 +274,25 @@ typedef struct { uint32_t uid; uint32_t cid; char hidstr[1]; -} fwts_uefi_expanded_acpi_dev_path; +} __attribute__((packed)) fwts_uefi_expanded_acpi_dev_path; typedef struct { fwts_uefi_dev_path dev_path; uint32_t adr; -} fwts_uefi_acpi_adr_dev_path; +} __attribute__((packed)) fwts_uefi_acpi_adr_dev_path; typedef struct { fwts_uefi_dev_path dev_path; uint8_t primary_secondary; uint8_t slave_master; uint16_t lun; -} fwts_uefi_atapi_dev_path; +} __attribute__((packed)) fwts_uefi_atapi_dev_path; typedef struct { fwts_uefi_dev_path dev_path; uint16_t pun; uint16_t lun; -} fwts_uefi_scsi_dev_path; +} __attribute__((packed)) fwts_uefi_scsi_dev_path; typedef struct { fwts_uefi_dev_path dev_path; @@ -305,13 +305,13 @@ typedef struct { fwts_uefi_dev_path dev_path; uint32_t reserved; uint64_t guid; -} fwts_uefi_1394_dev_path; +} __attribute__((packed)) fwts_uefi_1394_dev_path; typedef struct { fwts_uefi_dev_path dev_path; uint8_t parent_port_number; uint8_t interface; -} fwts_uefi_usb_dev_path; +} __attribute__((packed)) fwts_uefi_usb_dev_path; typedef struct { fwts_uefi_dev_path dev_path; @@ -320,19 +320,19 @@ typedef struct { uint8_t device_class; uint8_t device_subclass; uint8_t device_protocol; -} fwts_uefi_usb_class_dev_path; +} __attribute__((packed)) fwts_uefi_usb_class_dev_path; typedef struct { fwts_uefi_dev_path dev_path; uint32_t tid; -} fwts_uefi_i2o_dev_path; +} __attribute__((packed)) fwts_uefi_i2o_dev_path; typedef struct { fwts_uefi_dev_path dev_path; fwts_uefi_mac_addr mac_addr; uint8_t if_type; -} fwts_uefi_mac_addr_dev_path; +} __attribute__((packed)) fwts_uefi_mac_addr_dev_path; typedef struct { fwts_uefi_dev_path dev_path; @@ -342,7 +342,7 @@ typedef struct { uint16_t remote_port; uint16_t protocol; uint8_t static_ip_address; -} fwts_uefi_ipv4_dev_path; +} __attribute__((packed)) fwts_uefi_ipv4_dev_path; typedef struct { fwts_uefi_dev_path dev_path; @@ -352,7 +352,7 @@ typedef struct { uint16_t remote_port; uint16_t protocol; uint8_t static_ip_address; -} fwts_uefi_ipv6_dev_path; +} __attribute__((packed)) fwts_uefi_ipv6_dev_path; typedef struct { fwts_uefi_dev_path dev_path; @@ -361,7 +361,7 @@ typedef struct { uint64_t remote_id; uint64_t target_port_id; uint64_t device_id; -} fwts_uefi_infiniband_dev_path; +} __attribute__((packed)) fwts_uefi_infiniband_dev_path; typedef struct { fwts_uefi_dev_path dev_path; @@ -370,27 +370,27 @@ typedef struct { uint8_t data_bits; uint8_t parity; uint8_t stop_bits; -} fwts_uefi_uart_dev_path; +} __attribute__((packed)) fwts_uefi_uart_dev_path; typedef struct { fwts_uefi_dev_path dev_path; fwts_uefi_guid guid; uint8_t vendor_defined_data[0]; -} fwts_uefi_vendor_messaging_dev_path; +} __attribute__((packed)) fwts_uefi_vendor_messaging_dev_path; typedef struct { fwts_uefi_dev_path dev_path; uint32_t reserved; uint64_t wwn; uint64_t lun; -} fwts_uefi_fibre_channel_ex_dev_path; +} __attribute__((packed)) fwts_uefi_fibre_channel_ex_dev_path; typedef struct { fwts_uefi_dev_path dev_path; uint16_t hbapn; uint16_t pmpn; uint16_t lun; -} fwts_uefi_sata_dev_path; +} __attribute__((packed)) fwts_uefi_sata_dev_path; typedef struct { fwts_uefi_dev_path dev_path; @@ -398,7 +398,7 @@ typedef struct { uint16_t vendor_id; uint16_t product_id; uint16_t serial_number[0]; -} fwts_uefi_usb_wwid_dev_path; +} __attribute__((packed)) fwts_uefi_usb_wwid_dev_path; typedef struct { fwts_uefi_dev_path dev_path; @@ -408,7 +408,7 @@ typedef struct { typedef struct { fwts_uefi_dev_path dev_path; uint16_t vlanid; -} fwts_uefi_vlan_dev_path; +} __attribute__((packed)) fwts_uefi_vlan_dev_path; typedef struct { fwts_uefi_dev_path dev_path; @@ -441,32 +441,32 @@ typedef struct { uint8_t partition_signature[8]; uint8_t mbr_type; uint8_t signature_type; -} fwts_uefi_hard_drive_dev_path; +} __attribute__((packed)) fwts_uefi_hard_drive_dev_path; typedef struct { fwts_uefi_dev_path dev_path; uint32_t boot_entry; uint64_t partition_start; uint64_t partition_size; -} fwts_uefi_cdrom_dev_path; +} __attribute__((packed)) fwts_uefi_cdrom_dev_path; typedef struct { fwts_uefi_dev_path dev_path; fwts_uefi_guid guid; uint8_t vendor_defined_data[0]; -} fwts_uefi_vendor_media_dev_path; +} __attribute__((packed)) fwts_uefi_vendor_media_dev_path; typedef struct { fwts_uefi_dev_path dev_path; uint16_t path_name[0]; -} fwts_uefi_file_path_dev_path; +} __attribute__((packed)) fwts_uefi_file_path_dev_path; typedef struct { fwts_uefi_dev_path dev_path; uint16_t device_type; uint16_t status_flags; char description[0]; -} fwts_uefi_bios_dev_path; +} __attribute__((packed)) fwts_uefi_bios_dev_path; typedef struct { fwts_uefi_guid signaturetype;