Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1q2VkO-00034w-Tt for mharc-grub-devel@gnu.org; Fri, 26 May 2023 07:36:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2VkN-000342-8C for grub-devel@gnu.org; Fri, 26 May 2023 07:36:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2VkL-0005KY-HH for grub-devel@gnu.org; Fri, 26 May 2023 07:36:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685100996; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7Sj13A8CO00mv487tBI11eD2ryYyEQc0dW0Wu3WEUGs=; b=XS2In9FeHLCNgoQsK/pINcYJ5G6bkpgF1feF216fahG2NHFy+S66NqplDWfLR5Zq4cDoUw WBfHAYlh5zJSlVg1UgQL9tlGkMATi/this+CkBaPRiCYkNfC2uCEHsTSPXfEallwiGWvXs 1FUwSLIoit9SLf8zlCOF3p8PfYZSNc0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-111-18P0MQgAPEyEjC9WJY5Tjw-1; Fri, 26 May 2023 07:36:31 -0400 X-MC-Unique: 18P0MQgAPEyEjC9WJY5Tjw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55B4B2811BC5; Fri, 26 May 2023 11:36:31 +0000 (UTC) Received: from osteffen-laptop.redhat.com (unknown [10.39.193.184]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C57340CFD47; Fri, 26 May 2023 11:36:30 +0000 (UTC) From: Oliver Steffen To: grub-devel@gnu.org Cc: Daniel Kiper , Gerd Hoffmann , Oliver Steffen , Daniel Kiper Subject: [PATCH v9 04/11] grub-core: Make use of guid printf format specifier Date: Fri, 26 May 2023 13:35:45 +0200 Message-Id: <20230526113552.555635-5-osteffen@redhat.com> In-Reply-To: <20230526113552.555635-1-osteffen@redhat.com> References: <20230526113552.555635-1-osteffen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Received-SPF: pass client-ip=170.10.129.124; envelope-from=osteffen@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 May 2023 11:36:39 -0000 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 Reviewed-by: Daniel Kiper --- grub-core/commands/efi/lsefi.c | 13 +------------ grub-core/commands/efi/lsefisystab.c | 6 +----- grub-core/commands/probe.c | 12 ++++-------- grub-core/kern/efi/efi.c | 28 ++-------------------------- grub-core/loader/i386/xnu.c | 9 ++------- 5 files changed, 10 insertions(+), 58 deletions(-) diff --git a/grub-core/commands/efi/lsefi.c b/grub-core/commands/efi/lsefi.c index 6935cd302..05e2e511e 100644 --- a/grub-core/commands/efi/lsefi.c +++ b/grub-core/commands/efi/lsefi.c @@ -124,18 +124,7 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)), if (k < ARRAY_SIZE (known_protocols)) grub_printf (" %s\n", known_protocols[k].name); else - grub_printf (" %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", - 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]); + grub_printf (" %pG\n", protocols[j]); } } diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c index eff8c41f3..79ccee12a 100644 --- a/grub-core/commands/efi/lsefisystab.c +++ b/grub-core/commands/efi/lsefisystab.c @@ -96,11 +96,7 @@ grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)), grub_printf ("%p ", t->vendor_table); - grub_printf ("%08x-%04x-%04x-", - 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]); + grub_printf ("%pG", &t->vendor_guid); for (j = 0; j < ARRAY_SIZE (guid_mappings); j++) if (grub_memcmp (&guid_mappings[j].guid, &t->vendor_guid, diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c index cc8c05586..be9637f33 100644 --- a/grub-core/commands/probe.c +++ b/grub-core/commands/probe.c @@ -130,14 +130,10 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args) return grub_errno; } guid = &entry.guid; - grub_snprintf (val, sizeof(val), - "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - grub_le_to_cpu32 (guid->data1), - grub_le_to_cpu16 (guid->data2), - 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]); + guid->data1 = grub_le_to_cpu32 (guid->data1); + guid->data2 = grub_le_to_cpu16 (guid->data2); + guid->data3 = grub_le_to_cpu16 (guid->data3); + grub_snprintf (val, sizeof(val), "%pG", guid); } else if (grub_strcmp(dev->disk->partition->partmap->name, "msdos") == 0) { diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index 9e7d1a4a7..394523d0a 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -545,20 +545,7 @@ static void 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_printf ("/%sVendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)[%x: ", - 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); + grub_printf ("/%sVendor(%pG)[%x: ", type, &vendor->vendor_guid, vendor_data_len); if (vendor->header.length > sizeof (*vendor)) { 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 *) dp; - grub_printf ("/Protocol(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)", - (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]); + grub_printf ("/Protocol(%pG)",&proto->guid); } break; default: diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index 93ba4476d..4e31ce99a 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -726,13 +726,8 @@ grub_cpu_xnu_fill_devicetree (grub_uint64_t *fsbfreq_out) #endif /* The name of key for new table. */ - grub_snprintf (guidbuf, sizeof (guidbuf), "%08x-%04x-%04x-%02x%02x-", - 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]); + grub_snprintf (guidbuf, sizeof (guidbuf), "%pG", &guid); + /* For some reason GUID has to be in uppercase. */ for (j = 0; guidbuf[j] ; j++) if (guidbuf[j] >= 'a' && guidbuf[j] <= 'f') -- 2.40.1