From patchwork Sun Jan 16 15:14:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1580476 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=cKBz0Plu; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JcJX95jClz9sRR for ; Mon, 17 Jan 2022 02:16:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 242DB8360F; Sun, 16 Jan 2022 16:15:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.b="cKBz0Plu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D131B82FC8; Sun, 16 Jan 2022 16:15:02 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 91D7783518 for ; Sun, 16 Jan 2022 16:14:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from workstation5.fritz.box (ip-88-152-144-107.hsi03.unitymediagroup.de [88.152.144.107]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 0025B4199B; Sun, 16 Jan 2022 15:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1642346092; bh=C6CkULBq+nDZ8qNuMUFyH9MzDaqguXcG92XIo//T+Rc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cKBz0PluwpjVtg88rMCWue2Sdu6Uu5fUk6DZU9D001aPL/2Aj3wzv7eoN6iq0J1P0 8slJpWEBCWhSzjTL5QdzG1VZz9Eyur1IO8/Dkb5FRX0mI9ezrCnav9X2diEXY5hDbY vmkCsS0QLMRbb3fGUcdrn+nHh6U878ER0rDFabLxmMZLcPVm/Rsz0RAO/rDhSkCZoU GSuZKWhXEEsVkQtzwMq/Es9hettvq5DWW4/O1EFxL48JpUX02kDF7jQ/usWyFZpLMX 99FEmS4KRVSplRQdctiBjh6bojeAvd4rwwPAyFg4HOEn27qDNExRQ1LDzaxRj+3woL tmXMaiLwSo7GA== From: Heinrich Schuchardt To: Tom Rini Cc: Simon Glass , Rasmus Villemoes , Patrick Delaunay , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH 8/8] cmd: printenv: simplify printing GUIDs Date: Sun, 16 Jan 2022 16:14:41 +0100 Message-Id: <20220116151441.219566-9-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220116151441.219566-1-heinrich.schuchardt@canonical.com> References: <20220116151441.219566-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Use "%pS" to print text representations of GUIDs. Signed-off-by: Heinrich Schuchardt --- cmd/nvedit_efi.c | 39 ++------------------------------------- lib/uuid.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 37 deletions(-) diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c index 710d923a91..7ebb14e25f 100644 --- a/cmd/nvedit_efi.c +++ b/cmd/nvedit_efi.c @@ -39,40 +39,6 @@ static const struct { {EFI_VARIABLE_READ_ONLY, "RO"}, }; -static const struct { - efi_guid_t guid; - char *text; -} efi_guid_text[] = { - /* signature database */ - {EFI_GLOBAL_VARIABLE_GUID, "EFI_GLOBAL_VARIABLE_GUID"}, - {EFI_IMAGE_SECURITY_DATABASE_GUID, "EFI_IMAGE_SECURITY_DATABASE_GUID"}, - /* certificate type */ - {EFI_CERT_SHA256_GUID, "EFI_CERT_SHA256_GUID"}, - {EFI_CERT_X509_GUID, "EFI_CERT_X509_GUID"}, - {EFI_CERT_TYPE_PKCS7_GUID, "EFI_CERT_TYPE_PKCS7_GUID"}, -}; - -static const char unknown_guid[] = ""; - -/** - * efi_guid_to_str() - convert guid to readable name - * - * @guid: GUID - * Return: string for GUID - * - * convert guid to readable name - */ -static const char *efi_guid_to_str(const efi_guid_t *guid) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(efi_guid_text); i++) - if (!guidcmp(guid, &efi_guid_text[i].guid)) - return efi_guid_text[i].text; - - return unknown_guid; -} - /** * efi_dump_single_var() - show information about a UEFI variable * @@ -111,7 +77,7 @@ static void efi_dump_single_var(u16 *name, const efi_guid_t *guid, bool verbose) goto out; rtc_to_tm(time, &tm); - printf("%ls:\n %pUl %s\n", name, guid, efi_guid_to_str(guid)); + printf("%ls:\n %pUl (%pUs)\n", name, guid, guid); if (attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) printf(" %04d-%02d-%02d %02d:%02d:%02d\n", tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); @@ -497,8 +463,7 @@ int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int argc, } if (verbose) { - printf("GUID: %pUl %s\n", &guid, - efi_guid_to_str((const efi_guid_t *)&guid)); + printf("GUID: %pUl (%pUs)\n", &guid, &guid); printf("Attributes: 0x%x\n", attributes); } diff --git a/lib/uuid.c b/lib/uuid.c index 60b7ca17f1..3ffaab7d15 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -217,6 +217,30 @@ static const struct { EFI_TCG2_FINAL_EVENTS_TABLE_GUID, }, #endif +#ifdef CONFIG_CMD_NVEDIT_EFI + /* signature database */ + { + "EFI_GLOBAL_VARIABLE_GUID", + EFI_GLOBAL_VARIABLE_GUID, + }, + { + "EFI_IMAGE_SECURITY_DATABASE_GUID", + EFI_IMAGE_SECURITY_DATABASE_GUID, + }, + /* certificate types */ + { + "EFI_CERT_SHA256_GUID", + EFI_CERT_SHA256_GUID, + }, + { + "EFI_CERT_X509_GUID", + EFI_CERT_X509_GUID, + }, + { + "EFI_CERT_TYPE_PKCS7_GUID", + EFI_CERT_TYPE_PKCS7_GUID, + }, +#endif }; /*