[PATCH 18/18] uefi: uefidump: print format using inttypes and whitespace tidy

Keng-Yu Lin kengyu at canonical.com
Thu Sep 27 10:06:10 UTC 2012


On Mon, Sep 24, 2012 at 3:04 AM, Colin King <colin.king at canonical.com> wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/uefi/uefidump/uefidump.c |  223 ++++++++++++++++++++++--------------------
>  1 file changed, 118 insertions(+), 105 deletions(-)
>
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index 42b78af..11c40e9 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -16,10 +16,12 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
>   *
>   */
> +#include <inttypes.h>
>
>  #include "fwts.h"
>  #include "fwts_uefi.h"
>
> +
>  typedef void (*uefidump_func)(fwts_framework *fw, fwts_uefi_var *var);
>
>  typedef struct {
> @@ -32,7 +34,7 @@ static void uefidump_var_hexdump(fwts_framework *fw, fwts_uefi_var *var)
>         int i;
>         uint8_t *data = (uint8_t*)var->data;
>
> -       fwts_log_info_verbatum(fw,  "  Size: %d bytes of data.", (int)var->datalen);
> +       fwts_log_info_verbatum(fw,  "  Size: %zd bytes of data.", var->datalen);
>
>         for (i = 0; i < (int)var->datalen; i+= 16) {
>                 char buffer[128];
> @@ -86,7 +88,7 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path)
>                 case FWTS_UEFI_END_THIS_DEV_PATH_SUBTYPE:
>                         break;
>                 default:
> -                       return uefidump_vprintf(path, "\\Unknown-End(0x%x)", (unsigned int) dev_path->subtype);
> +                       return uefidump_vprintf(path, "\\Unknown-End(0x%" PRIx8 ")", dev_path->subtype);
>                 }
>                 break;
>         case FWTS_UEFI_HARDWARE_DEV_PATH_TYPE:
> @@ -94,25 +96,24 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path)
>                 case FWTS_UEFI_PCI_DEV_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_pci_dev_path *p = (fwts_uefi_pci_dev_path *)dev_path;
> -                               path = uefidump_vprintf(path, "\\PCI(0x%x,0x%x)",
> -                                       (unsigned int)p->function, (unsigned int)p->device);
> +                               path = uefidump_vprintf(path, "\\PCI(0x%" PRIx8 ",0x%" PRIx8 ")",
> +                                       p->function, p->device);
>                         }
>                         break;
>                 case FWTS_UEFI_PCCARD_DEV_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_pccard_dev_path *p = (fwts_uefi_pccard_dev_path *)dev_path;
> -                               path = uefidump_vprintf(path, "\\PCCARD(0x%x)",
> -                                       (unsigned int)p->function);
> -
> +                               path = uefidump_vprintf(path, "\\PCCARD(0x%" PRIx8 ")",
> +                                       p->function);
>                         }
>                         break;
>                 case FWTS_UEFI_MEMORY_MAPPED_DEV_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_mem_mapped_dev_path *m = (fwts_uefi_mem_mapped_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\Memmap(0x%x,0x%llx,0x%llx)",
> -                                       (unsigned int)m->memory_type,
> -                                       (unsigned long long int)m->start_addr,
> -                                       (unsigned long long int)m->end_addr);
> +                               path = uefidump_vprintf(path, "\\Memmap(0x%" PRIx32 ",0x%" PRIx64 ",0x%" PRIx64 ")",
> +                                       m->memory_type,
> +                                       m->start_addr,
> +                                       m->end_addr);
>                         }
>                         break;
>                 case FWTS_UEFI_VENDOR_DEV_PATH_SUBTYPE:
> @@ -127,25 +128,23 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path)
>                 case FWTS_UEFI_CONTROLLER_DEV_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_controller_dev_path *c = (fwts_uefi_controller_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\Controller(0x%x)",
> -                                       (unsigned int)c->controller);
> -
> +                               path = uefidump_vprintf(path, "\\Controller(0x%" PRIx32 ")",
> +                                       c->controller);
>                         }
>                         break;
>                 default:
> -                       path = uefidump_vprintf(path, "\\Unknown-HW-DEV-PATH(0x%x)", (unsigned int) dev_path->subtype);
> +                       path = uefidump_vprintf(path, "\\Unknown-HW-DEV-PATH(0x%" PRIx8 ")", dev_path->subtype);
>                         break;
>                 }
>                 break;
>
>         case FWTS_UEFI_ACPI_DEVICE_PATH_TYPE:
>                 switch (dev_path->subtype) {
> -               case FWTS_UEFI_ACPI_DEVICE_PATH_SUBTYPE:
> +               case FWTS_UEFI_ACPI_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_acpi_dev_path *a = (fwts_uefi_acpi_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\ACPI(0x%x,0x%x)",
> -                                       (unsigned int)a->hid, (unsigned int)a->uid);
> -
> +                               path = uefidump_vprintf(path, "\\ACPI(0x%" PRIx32 ",0x%" PRIx32 ")",
> +                                       a->hid, a->uid);
>                         }
>                         break;
>                 case FWTS_UEFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE:
> @@ -154,22 +153,22 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path)
>                                 char *hidstr= a->hidstr;
>                                 path = uefidump_vprintf(path, "\\ACPI(");
>                                 if (hidstr[0] == '\0')
> -                                       path = uefidump_vprintf(path, "0x%x,", (unsigned int)a->hid);
> +                                       path = uefidump_vprintf(path, "0x%" PRIx32 ",", a->hid);
>                                 else
>                                         path = uefidump_vprintf(path, "%s,", hidstr);
>                                 hidstr += strlen(hidstr) + 1;
>                                 if (hidstr[0] == '\0')
> -                                       path = uefidump_vprintf(path, "0x%x,", (unsigned int)a->uid);
> +                                       path = uefidump_vprintf(path, "0x%" PRIx32 ",", a->uid);
>                                 else
>                                         path = uefidump_vprintf(path, "%s,", hidstr);
>                                 hidstr += strlen(hidstr) + 1;
>                                 if (hidstr[0] == '\0')
> -                                       path = uefidump_vprintf(path, "0x%x,", (unsigned int)a->cid);
> +                                       path = uefidump_vprintf(path, "0x%" PRIx32 ",", a->cid);
>                                 else
>                                         path = uefidump_vprintf(path, "%s,", hidstr);
>                         }
>                 default:
> -                       path = uefidump_vprintf(path, "\\Unknown-ACPI-DEV-PATH(0x%x)", (unsigned int) dev_path->subtype);
> +                       path = uefidump_vprintf(path, "\\Unknown-ACPI-DEV-PATH(0x%" PRIx8 ")", dev_path->subtype);
>                         break;
>                 }
>                 break;
> @@ -179,121 +178,132 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path)
>                         case FWTS_UEFI_ATAPI_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_atapi_dev_path *a = (fwts_uefi_atapi_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\ATAPI(0x%x,0x%x,0x%x)",
> -                                       (unsigned int)a->primary_secondary, (unsigned int)a->slave_master, (unsigned int)a->lun);
> +                               path = uefidump_vprintf(path, "\\ATAPI(0x%" PRIx8 ",0x%" PRIx8 ",0x%" PRIx16 ")",
> +                                       a->primary_secondary, a->slave_master, a->lun);
>                         }
>                         break;
>                 case FWTS_UEFI_SCSI_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_scsi_dev_path *s = (fwts_uefi_scsi_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\SCSI(0x%x,0x%x)",
> -                                       (unsigned int)s->pun, (unsigned int)s->lun);
> +                               path = uefidump_vprintf(path, "\\SCSI(0x%" PRIx16 ",0x%" PRIx16 ")",
> +                                       s->pun, s->lun);
>                         }
>                         break;
>                 case FWTS_UEFI_FIBRE_CHANNEL_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_fibre_channel_dev_path *f = (fwts_uefi_fibre_channel_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\FIBRECHANNEL(0x%x,0x%x)",
> -                                       (unsigned int)f->wwn, (unsigned int)f->lun);
> -
> +                               path = uefidump_vprintf(path, "\\FIBRECHANNEL(0x%" PRIx64 ",0x%" PRIx64 ")",
> +                                       f->wwn, f->lun);
>                         }
>                         break;
>                 case FWTS_UEFI_1394_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_1394_dev_path *fw = (fwts_uefi_1394_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\1394(0x%llx)",
> -                                       (unsigned long long int)fw->guid);
> +                               path = uefidump_vprintf(path, "\\1394(0x%" PRIx64 ")",
> +                                       fw->guid);
>                         }
>                         break;
>                 case FWTS_UEFI_USB_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_usb_dev_path *u = (fwts_uefi_usb_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\USB(0x%x,0x%x)",
> -                                       (unsigned int)u->parent_port_number, (unsigned int)u->interface);
> +                               path = uefidump_vprintf(path, "\\USB(0x%" PRIx8 ",0x%" PRIx8 ")",
> +                                       u->parent_port_number, u->interface);
>                         }
>                         break;
>                 case FWTS_UEFI_USB_CLASS_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_usb_class_dev_path *u = (fwts_uefi_usb_class_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\USBCLASS(0x%x,0x%x,0x%x,0x%x,0x%x)",
> -                                       (unsigned int)u->vendor_id, (unsigned int)u->product_id,
> -                                       (unsigned int)u->device_class, (unsigned int)u->device_subclass,
> -                                       (unsigned int)u->device_protocol);
> +                               path = uefidump_vprintf(path, "\\USBCLASS(0x%" PRIx16 ",0x%" PRIx16
> +                                       ",0x%" PRIx8 ",0x%" PRIx8 ",0x%" PRIx8 ")",
> +                                       u->vendor_id, u->product_id,
> +                                       u->device_class, u->device_subclass,
> +                                       u->device_protocol);
>                         }
>                         break;
>                 case FWTS_UEFI_I2O_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_i2o_dev_path *i2o = (fwts_uefi_i2o_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\I2O(0x%x)", (unsigned int)i2o->tid);
> -
> +                               path = uefidump_vprintf(path, "\\I2O(0x%" PRIx32 ")", i2o->tid);
>                         }
>                         break;
>                 case FWTS_UEFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_mac_addr_dev_path *m = (fwts_uefi_mac_addr_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\MACADDR(%x:%x:%x:%x:%x:%x,0x%x)",
> -                                       (unsigned int)m->mac_addr[0], (unsigned int)m->mac_addr[1],
> -                                       (unsigned int)m->mac_addr[2], (unsigned int)m->mac_addr[3],
> -                                       (unsigned int)m->mac_addr[4], (unsigned int)m->mac_addr[5],
> -                                       (unsigned int)m->if_type);
> +                               path = uefidump_vprintf(path, "\\MACADDR(%" PRIx8 ":%" PRIx8 ":%" PRIx8
> +                                       ":%" PRIx8 ":%" PRIx8 ":%" PRIx8 ",0x%" PRIx8 ")",
> +                                       m->mac_addr[0], m->mac_addr[1],
> +                                       m->mac_addr[2], m->mac_addr[3],
> +                                       m->mac_addr[4], m->mac_addr[5],
> +                                       m->if_type);
>                         }
>                         break;
>                 case FWTS_UEFI_IPV4_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_ipv4_dev_path *i = (fwts_uefi_ipv4_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\%u.%u.%u.%u,%u.%u.%u.%u,%u,%u,%x,%x)",
> -                                       (unsigned int)i->local_ip_addr[0], (unsigned int)i->local_ip_addr[1],
> -                                       (unsigned int)i->local_ip_addr[2], (unsigned int)i->local_ip_addr[3],
> -                                       (unsigned int)i->remote_ip_addr[0], (unsigned int)i->remote_ip_addr[1],
> -                                       (unsigned int)i->remote_ip_addr[2], (unsigned int)i->remote_ip_addr[3],
> -                                       (unsigned int)i->local_port, (unsigned int)i->remote_port,
> -                                       (unsigned int)i->protocol, (unsigned int)i->static_ip_address);
> +                               path = uefidump_vprintf(path, "\\IPv4("
> +                                       "%" PRIu8 ".%" PRIu8 ".%" PRIu8 ".%" PRIu8 ","
> +                                       "%" PRIu8 ".%" PRIu8 ".%" PRIu8 ".%" PRIu8 ","
> +                                       "%" PRIu16 ",%" PRIu16 ",%" PRIx16 ",%" PRIx8 ")",
> +                                       i->local_ip_addr[0], i->local_ip_addr[1],
> +                                       i->local_ip_addr[2], i->local_ip_addr[3],
> +                                       i->remote_ip_addr[0], i->remote_ip_addr[1],
> +                                       i->remote_ip_addr[2], i->remote_ip_addr[3],
> +                                       i->local_port, i->remote_port,
> +                                       i->protocol, i->static_ip_address);
>                         }
>                         break;
>                 case FWTS_UEFI_IPV6_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_ipv6_dev_path *i = (fwts_uefi_ipv6_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\IPv6(%x:%x:%x:%x:%x:%x:%x:%x,%x:%x:%x:%x:%x:%x:%x:%x,%u,%u,%x,%x)",
> -                                       (unsigned int)i->local_ip_addr[0], (unsigned int)i->local_ip_addr[1],
> -                                       (unsigned int)i->local_ip_addr[2], (unsigned int)i->local_ip_addr[3],
> -                                       (unsigned int)i->local_ip_addr[4], (unsigned int)i->local_ip_addr[5],
> -                                       (unsigned int)i->local_ip_addr[6], (unsigned int)i->local_ip_addr[7],
> -                                       (unsigned int)i->remote_ip_addr[0], (unsigned int)i->remote_ip_addr[1],
> -                                       (unsigned int)i->remote_ip_addr[2], (unsigned int)i->remote_ip_addr[3],
> -                                       (unsigned int)i->remote_ip_addr[4], (unsigned int)i->remote_ip_addr[5],
> -                                       (unsigned int)i->remote_ip_addr[6], (unsigned int)i->remote_ip_addr[7],
> -                                       (unsigned int)i->local_port, (unsigned int)i->remote_port,
> -                                       (unsigned int)i->protocol, (unsigned int)i->static_ip_address);
> +                               path = uefidump_vprintf(path, "\\IPv6("
> +                                       "%" PRIx8 ":%" PRIx8 ":%" PRIx8 ":%" PRIx8
> +                                       ":%" PRIx8 ":%" PRIx8 ":%" PRIx8 ":%" PRIx8 ","
> +                                       "%" PRIx8 ":%" PRIx8 ":%" PRIx8 ":%" PRIx8
> +                                       ":%" PRIx8 ":%" PRIx8 ":%" PRIx8 ":%" PRIx8 ","
> +                                       "%" PRIu16 ",%" PRIu16 ",%" PRIx16 ",%" PRIx8 ")",
> +                                       i->local_ip_addr[0], i->local_ip_addr[1],
> +                                       i->local_ip_addr[2], i->local_ip_addr[3],
> +                                       i->local_ip_addr[4], i->local_ip_addr[5],
> +                                       i->local_ip_addr[6], i->local_ip_addr[7],
> +                                       i->remote_ip_addr[0], i->remote_ip_addr[1],
> +                                       i->remote_ip_addr[2], i->remote_ip_addr[3],
> +                                       i->remote_ip_addr[4], i->remote_ip_addr[5],
> +                                       i->remote_ip_addr[6], i->remote_ip_addr[7],
> +                                       i->local_port, i->remote_port,
> +                                       i->protocol, i->static_ip_address);
>                         }
>                         break;
>                 case FWTS_UEFI_INFINIBAND_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_infiniband_dev_path *i = (fwts_uefi_infiniband_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\InfiniBand(%x,%llx,%llx,%llx)",
> -                                       (unsigned int) i->port_gid[0],
> -                                       (unsigned long long int)i->remote_id,
> -                                       (unsigned long long int)i->target_port_id,
> -                                       (unsigned long long int)i->device_id);
> +                               path = uefidump_vprintf(path, "\\InfiniBand("
> +                                       "%" PRIx8 ",%" PRIx64 ",%" PRIx64 ",%" PRIx64 ")",
> +                                       i->port_gid[0], i->remote_id,
> +                                       i->target_port_id, i->device_id);
>                         }
>                         break;
>                 case FWTS_UEFI_UART_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_uart_dev_path *u = (fwts_uefi_uart_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\UART(%llu baud,%u,%x,%x)",
> -                                       (unsigned long long int)u->baud_rate, u->data_bits, u->parity, u->stop_bits);
> +                               path = uefidump_vprintf(path, "\\UART("
> +                                       "%" PRIu64 ",%" PRIu8 ",%" PRIu8 ",%" PRIu8 ")",
> +                                       u->baud_rate, u->data_bits, u->parity, u->stop_bits);
>                         }
>                         break;
>                 case FWTS_UEFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_vendor_messaging_dev_path *v = (fwts_uefi_vendor_messaging_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\VENDOR(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
> +                               path = uefidump_vprintf(path, "\\VENDOR("
> +                                       "%08" PRIx32 "-%04" PRIx16 "-%04" PRIx16 "-"
> +                                       "%02" PRIx8 "-%02" PRIx8 "-"
> +                                       "%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 ")",
>                                         v->guid.info1, v->guid.info2, v->guid.info3,
>                                         v->guid.info4[0], v->guid.info4[1], v->guid.info4[2], v->guid.info4[3],
>                                         v->guid.info4[4], v->guid.info4[5], v->guid.info4[6], v->guid.info4[7]);
>                         }
>                         break;
>                 default:
> -                       path = uefidump_vprintf(path, "\\Unknown-MESSAGING-DEV-PATH(0x%x)", (unsigned int) dev_path->subtype);
> +                       path = uefidump_vprintf(path, "\\Unknown-MESSAGING-DEV-PATH(0x%" PRIx8 ")", dev_path->subtype);
>                         break;
>                 }
>                 break;
> @@ -303,37 +313,41 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path)
>                 case FWTS_UEFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_hard_drive_dev_path *h = (fwts_uefi_hard_drive_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\HARDDRIVE(%u,%llx,%llx,%02x%02x%02x%02x%02x%02x%02x%02x,%x,%x)",
> -                               h->partition_number,
> -                               (unsigned long long int)h->partition_start,
> -                               (unsigned long long int)h->partition_size,
> -                               (unsigned int)h->partition_signature[0], (unsigned int)h->partition_signature[1],
> -                               (unsigned int)h->partition_signature[2], (unsigned int)h->partition_signature[3],
> -                               (unsigned int)h->partition_signature[4], (unsigned int)h->partition_signature[5],
> -                               (unsigned int)h->partition_signature[6], (unsigned int)h->partition_signature[7],
> -                               (unsigned int)h->mbr_type, (unsigned int)h->signature_type);
> +                               path = uefidump_vprintf(path, "\\HARDDRIVE("
> +                               "%" PRIu32 ",%" PRIx64 ",%" PRIx64 ","
> +                               "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 ","
> +                               "%" PRIx8 ",%" PRIx8 ")",
> +                               h->partition_number,
> +                               h->partition_start,
> +                               h->partition_size,
> +                               h->partition_signature[0], h->partition_signature[1],
> +                               h->partition_signature[2], h->partition_signature[3],
> +                               h->partition_signature[4], h->partition_signature[5],
> +                               h->partition_signature[6], h->partition_signature[7],
> +                               h->mbr_type, h->signature_type);
>                         }
>                         break;
>                 case FWTS_UEFI_CDROM_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_cdrom_dev_path *c = (fwts_uefi_cdrom_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\CDROM(%u,%llx,%llx)",
> -                                       c->boot_entry,
> -                                       (unsigned long long int)c->partition_start,
> -                                       (unsigned long long int)c->partition_size);
> +                               path = uefidump_vprintf(path, "\\CDROM(%" PRIu32 ",%" PRIx64 ",%" PRIx64 ")",
> +                                       c->boot_entry, c->partition_start, c->partition_size);
>                         }
>                         break;
>                 case FWTS_UEFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_vendor_media_dev_path *v = (fwts_uefi_vendor_media_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\VENDOR(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
> +                               path = uefidump_vprintf(path, "\\VENDOR("
> +                                       "%08" PRIx32 "-%04" PRIx16 "-%04" PRIx16 "-"
> +                                       "%02" PRIx8 "-%02" PRIx8 "-"
> +                                       "%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 ")",
>                                         v->guid.info1, v->guid.info2, v->guid.info3,
>                                         v->guid.info4[0], v->guid.info4[1], v->guid.info4[2], v->guid.info4[3],
>                                         v->guid.info4[4], v->guid.info4[5], v->guid.info4[6], v->guid.info4[7]);
>                         }
>                         break;
>                 case FWTS_UEFI_FILE_PATH_DEVICE_PATH_SUBTYPE:
> -                       {
> +                       {
>                                 char tmp[4096];
>                                 fwts_uefi_file_path_dev_path *f = (fwts_uefi_file_path_dev_path*)dev_path;
>                                 fwts_uefi_str16_to_str(tmp, sizeof(tmp), f->path_name);
> @@ -342,7 +356,7 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path)
>                         break;
>                 case FWTS_UEFI_PROTOCOL_DEVICE_PATH_SUBTYPE:
>                 default:
> -                       path = uefidump_vprintf(path, "\\Unknown-MEDIA-DEV-PATH(0x%x)", (unsigned int) dev_path->subtype);
> +                       path = uefidump_vprintf(path, "\\Unknown-MEDIA-DEV-PATH(0x%" PRIx8 ")", dev_path->subtype);
>                         break;
>                 }
>                 break;
> @@ -352,18 +366,17 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path)
>                 case FWTS_UEFI_BIOS_DEVICE_PATH_SUBTYPE:
>                         {
>                                 fwts_uefi_bios_dev_path *b = (fwts_uefi_bios_dev_path*)dev_path;
> -                               path = uefidump_vprintf(path, "\\BIOS(%x,%x,%s)",
> -                                       (unsigned int)b->device_type, (unsigned int)b->status_flags, b->description);
> +                               path = uefidump_vprintf(path, "\\BIOS(%" PRIx16 ",%" PRIx16 ",%s)",
> +                                       b->device_type, b->status_flags, b->description);
>                         }
>                         break;
>                 default:
> -                       path = uefidump_vprintf(path, "\\Unknown-BIOS-DEV-PATH(0x%x)", (unsigned int) dev_path->subtype);
> +                       path = uefidump_vprintf(path, "\\Unknown-BIOS-DEV-PATH(0x%" PRIx8 ")", dev_path->subtype);
>                         break;
>                 }
>                 break;
> -
>         default:
> -               path = uefidump_vprintf(path, "\\Unknown-TYPE(0x%x)", (unsigned int) dev_path->type);
> +               path = uefidump_vprintf(path, "\\Unknown-TYPE(0x%" PRIx8 ")", dev_path->type);
>                 break;
>         }
>
> @@ -444,28 +457,28 @@ static void uefidump_info_platform_langcodes(fwts_framework *fw, fwts_uefi_var *
>  static void uefidump_info_timeout(fwts_framework *fw, fwts_uefi_var *var)
>  {
>         uint16_t *data = (uint16_t*)var->data;
> -       fwts_log_info_verbatum(fw, "Timeout: %d seconds.", (int)*data);
> +       fwts_log_info_verbatum(fw, "Timeout: %" PRId16 " seconds.", *data);
>  }
>
>  static void uefidump_info_bootcurrent(fwts_framework *fw, fwts_uefi_var *var)
>  {
>         uint16_t *data = (uint16_t *)var->data;
>
> -       fwts_log_info_verbatum(fw, "  BootCurrent: 0x%4.4x.", (unsigned int)*data);
> +       fwts_log_info_verbatum(fw, "  BootCurrent: 0x%4.4" PRIx16 ".", *data);
>  }
>
>  static void uefidump_info_bootnext(fwts_framework *fw, fwts_uefi_var *var)
>  {
>         uint16_t *data = (uint16_t *)var->data;
>
> -       fwts_log_info_verbatum(fw, "  BootNext: 0x%4.4x.", (unsigned int)*data);
> +       fwts_log_info_verbatum(fw, "  BootNext: 0x%4.4" PRIx16 ".", *data);
>  }
>
>  static void uefidump_info_bootoptionsupport(fwts_framework *fw, fwts_uefi_var *var)
>  {
>         uint16_t *data = (uint16_t *)var->data;
>
> -       fwts_log_info_verbatum(fw, "  BootOptionSupport: 0x%4.4x.", (unsigned int)*data);
> +       fwts_log_info_verbatum(fw, "  BootOptionSupport: 0x%4.4" PRIx16 ".", *data);
>  }
>
>  static void uefidump_info_bootorder(fwts_framework *fw, fwts_uefi_var *var)
> @@ -476,7 +489,7 @@ static void uefidump_info_bootorder(fwts_framework *fw, fwts_uefi_var *var)
>         char *str = NULL;
>
>         for (i = 0; i<n; i++) {
> -               str = uefidump_vprintf(str, "0x%04x%s",
> +               str = uefidump_vprintf(str, "0x%04" PRIx16 "%s",
>                         *data++, i < (n - 1) ? "," : "");
>         }
>         fwts_log_info_verbatum(fw, "  Boot Order: %s.", str);
> @@ -498,7 +511,7 @@ static void uefidump_info_bootdev(fwts_framework *fw, fwts_uefi_var *var)
>
>         /* Skip over description to get to packed path, unpack path and print */
>         path = (char *)var->data + sizeof(load_option->attributes) +
> -               sizeof(load_option->file_path_list_length) +
> +               sizeof(load_option->file_path_list_length) +
>                 (sizeof(uint16_t) * (len + 1));
>         path = uefidump_build_dev_path(NULL, (fwts_uefi_dev_path *)path);
>         fwts_log_info_verbatum(fw, "  Path: %s.", path);
> @@ -568,7 +581,7 @@ static void uefidump_info_setup_mode(fwts_framework *fw, fwts_uefi_var *var)
>                         mode = "";
>                         break;
>                 }
> -               fwts_log_info_verbatum(fw, "  Value: 0x%2.2x%s.", value, mode);
> +               fwts_log_info_verbatum(fw, "  Value: 0x%2.2" PRIx8 "%s.", value, mode);
>         }
>  }
>
> @@ -596,7 +609,7 @@ static void uefidump_info_morc(fwts_framework *fw, fwts_uefi_var *var)
>                         mode = "";
>                         break;
>                 }
> -               fwts_log_info_verbatum(fw, "  Value: 0x%2.2x%s.", value, mode);
> +               fwts_log_info_verbatum(fw, "  Value: 0x%2.2" PRIx8 "%s.", value, mode);
>         }
>  }
>
> @@ -612,7 +625,7 @@ static void uefidump_info_acpi_global_variable(fwts_framework *fw, fwts_uefi_var
>                 uint64_t value;
>
>                 memcpy(&value, var->data, sizeof(uint64_t));
> -               fwts_log_info_verbatum(fw, "  ACPI Global Variable Address: 0x%16.16llx.", (unsigned long long)value);
> +               fwts_log_info_verbatum(fw, "  ACPI Global Variable Address: 0x%16.16" PRIx64 ".", value);
>         }
>  }
>
> @@ -681,13 +694,13 @@ static char *uefidump_attribute(uint32_t attr)
>                 strcat(str, "NonVolatile");
>
>         if (attr & FWTS_UEFI_VAR_BOOTSERVICE_ACCESS) {
> -               if (*str)
> +               if (*str)
>                         strcat(str, ",");
>                 strcat(str, "BootServ");
>         }
> -
> +
>         if (attr & FWTS_UEFI_VAR_RUNTIME_ACCESS) {
> -               if (*str)
> +               if (*str)
>                         strcat(str, ",");
>                 strcat(str, "RunTime");
>         }
> --
> 1.7.10.4
>
Acked-by: Keng-Yu Lin <kengyu at canonical.com>



More information about the fwts-devel mailing list