guid: Make use of GUID printf format specifier

Use the new printf format specifier %pG.

Fixes the text representation of GUIDs in the output of the lsefisystab
command (missing 4th dash).

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Oliver Steffen authored and Daniel Kiper committed 2023-06-01 11:45:00 +02:00
1 parent f82dbf2bd8
commit 6ad116e5ff
5 files changed
+10 -58

No files matched your search

+1 -12
View File
@@ -124,18 +124,7 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
if (k < ARRAY_SIZE (known_protocols)) if (k < ARRAY_SIZE (known_protocols))
grub_printf (" %s\n", known_protocols[k].name); grub_printf (" %s\n", known_protocols[k].name);
else else
grub_printf (" %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", grub_printf (" %pG\n", protocols[j]);
protocols[j]->data1,
protocols[j]->data2,
protocols[j]->data3,
(unsigned) protocols[j]->data4[0],
(unsigned) protocols[j]->data4[1],
(unsigned) protocols[j]->data4[2],
(unsigned) protocols[j]->data4[3],
(unsigned) protocols[j]->data4[4],
(unsigned) protocols[j]->data4[5],
(unsigned) protocols[j]->data4[6],
(unsigned) protocols[j]->data4[7]);
} }
} }
+1 -5
View File
@@ -96,11 +96,7 @@ grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)),
grub_printf ("%p ", t->vendor_table); grub_printf ("%p ", t->vendor_table);
grub_printf ("%08x-%04x-%04x-", grub_printf ("%pG", &t->vendor_guid);
t->vendor_guid.data1, t->vendor_guid.data2,
t->vendor_guid.data3);
for (j = 0; j < 8; j++)
grub_printf ("%02x", t->vendor_guid.data4[j]);
for (j = 0; j < ARRAY_SIZE (guid_mappings); j++) for (j = 0; j < ARRAY_SIZE (guid_mappings); j++)
if (grub_memcmp (&guid_mappings[j].guid, &t->vendor_guid, if (grub_memcmp (&guid_mappings[j].guid, &t->vendor_guid,
+4 -8
View File
@@ -130,14 +130,10 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
return grub_errno; return grub_errno;
} }
guid = &entry.guid; guid = &entry.guid;
grub_snprintf (val, sizeof(val), guid->data1 = grub_le_to_cpu32 (guid->data1);
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", guid->data2 = grub_le_to_cpu16 (guid->data2);
grub_le_to_cpu32 (guid->data1), guid->data3 = grub_le_to_cpu16 (guid->data3);
grub_le_to_cpu16 (guid->data2), grub_snprintf (val, sizeof(val), "%pG", guid);
grub_le_to_cpu16 (guid->data3),
guid->data4[0], guid->data4[1], guid->data4[2],
guid->data4[3], guid->data4[4], guid->data4[5],
guid->data4[6], guid->data4[7]);
} }
else if (grub_strcmp(dev->disk->partition->partmap->name, "msdos") == 0) else if (grub_strcmp(dev->disk->partition->partmap->name, "msdos") == 0)
{ {
+2 -26
View File
@@ -545,20 +545,7 @@ static void
dump_vendor_path (const char *type, grub_efi_vendor_device_path_t *vendor) dump_vendor_path (const char *type, grub_efi_vendor_device_path_t *vendor)
{ {
grub_uint32_t vendor_data_len = vendor->header.length - sizeof (*vendor); grub_uint32_t vendor_data_len = vendor->header.length - sizeof (*vendor);
grub_printf ("/%sVendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)[%x: ", grub_printf ("/%sVendor(%pG)[%x: ", type, &vendor->vendor_guid, vendor_data_len);
type,
(unsigned) vendor->vendor_guid.data1,
(unsigned) vendor->vendor_guid.data2,
(unsigned) vendor->vendor_guid.data3,
(unsigned) vendor->vendor_guid.data4[0],
(unsigned) vendor->vendor_guid.data4[1],
(unsigned) vendor->vendor_guid.data4[2],
(unsigned) vendor->vendor_guid.data4[3],
(unsigned) vendor->vendor_guid.data4[4],
(unsigned) vendor->vendor_guid.data4[5],
(unsigned) vendor->vendor_guid.data4[6],
(unsigned) vendor->vendor_guid.data4[7],
vendor_data_len);
if (vendor->header.length > sizeof (*vendor)) if (vendor->header.length > sizeof (*vendor))
{ {
grub_uint32_t i; grub_uint32_t i;
@@ -929,18 +916,7 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
{ {
grub_efi_protocol_device_path_t *proto grub_efi_protocol_device_path_t *proto
= (grub_efi_protocol_device_path_t *) dp; = (grub_efi_protocol_device_path_t *) dp;
grub_printf ("/Protocol(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)", grub_printf ("/Protocol(%pG)",&proto->guid);
(unsigned) proto->guid.data1,
(unsigned) proto->guid.data2,
(unsigned) proto->guid.data3,
(unsigned) proto->guid.data4[0],
(unsigned) proto->guid.data4[1],
(unsigned) proto->guid.data4[2],
(unsigned) proto->guid.data4[3],
(unsigned) proto->guid.data4[4],
(unsigned) proto->guid.data4[5],
(unsigned) proto->guid.data4[6],
(unsigned) proto->guid.data4[7]);
} }
break; break;
default: default:
+2 -7
View File
@@ -726,13 +726,8 @@ grub_cpu_xnu_fill_devicetree (grub_uint64_t *fsbfreq_out)
#endif #endif
/* The name of key for new table. */ /* The name of key for new table. */
grub_snprintf (guidbuf, sizeof (guidbuf), "%08x-%04x-%04x-%02x%02x-", grub_snprintf (guidbuf, sizeof (guidbuf), "%pG", &guid);
guid.data1, guid.data2, guid.data3, guid.data4[0],
guid.data4[1]);
for (j = 2; j < 8; j++)
grub_snprintf (guidbuf + grub_strlen (guidbuf),
sizeof (guidbuf) - grub_strlen (guidbuf),
"%02x", guid.data4[j]);
/* For some reason GUID has to be in uppercase. */ /* For some reason GUID has to be in uppercase. */
for (j = 0; guidbuf[j] ; j++) for (j = 0; guidbuf[j] ; j++)
if (guidbuf[j] >= 'a' && guidbuf[j] <= 'f') if (guidbuf[j] >= 'a' && guidbuf[j] <= 'f')