From patchwork Fri Nov 20 10:45:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1403580 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=YelPmoiB; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 ozlabs.org (Postfix) with ESMTPS id 4CctX12jSmz9sSs for ; Fri, 20 Nov 2020 21:46:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3FBFD82573; Fri, 20 Nov 2020 11:46:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.b="YelPmoiB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 53C0282564; Fri, 20 Nov 2020 11:45:58 +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=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02on071e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe07::71e]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A73FA82366 for ; Fri, 20 Nov 2020 11:45:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gYcUOS1MiV51DEXLkaDOeKgtrzgRVw7prp5gDZQPxI6nxS6hLgBODs6kFGrVXEt51qOp9UeI4F6a18fDC1nd6xuA4/WMRdjDHQEXI6CXAGq9OjBD4P14Mk8/Z/QY3BIMEhcwH70+/T+BbYaPc3OtqSvL5cnFSo8u7x9w0J/UOkCCEM10RxVI6hA5NENXN4vhKfOP3qKZrL3Hf3rJ7FZK48YhOj4GJOi9OuE0dxs5e2Xs9sit9Ekdq3B39aTs104UfqsBKxRifBtsVPWselgbWDFw36NtgeymeAl7K2P8+779G70COOhhC/pGLTDEu2njr0eUIUivuWPRg/WpE9T7pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+h11wDZ9fomQ1/xgFfl8O3OxV+hanH21UHapmv3ZoUg=; b=J+XxBB/Gfb9RMOPk+CuiDoVVRVWrDcGED4SeMmEcxcgLgkwVrnAJfZDxNb0g7pZWK/25snrfdSp1AcnnCawRE1v0PoD72RSE/E2v7QkyxpumaeHcu8iKiNMY2mnCNbAE2bxGnARywYykVwjRc+8lvNbyrK4uGkTVKbUTMEjVfhnEX8cAZ/Aw69991zXPN2gfp/d+M4aaWL0fPO6cOiZOCnYHyAvwcPKj9/IrBwXUJj201zA8RyytQ4kXvNtk6lVlqxhsDJzGF83S1RbDGA996sa6tw/zZqQeASgtsjRn8i2GZGLdurdHHjW4dC1H1/4YVP5DQUEpF6RlRs8LrS2/gA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+h11wDZ9fomQ1/xgFfl8O3OxV+hanH21UHapmv3ZoUg=; b=YelPmoiB4YB9ggsFuH1K/RRrVygs+/YW7/utp+4E9hMWbjjs4UR3oTgBOmeIyvnV3BDK9irqPV9PULWnQdTXNT5zb+RRbLRZUWhxjWy57tJ7Lz4p8qgX4HvoJ3EasJnaBx27CBlsz6m4BzSxm0vdZ3PCWTOQOHZ2oZlmZhwAhdI= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=prevas.dk; Received: from AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:3f::10) by AM8PR10MB4276.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:1ea::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20; Fri, 20 Nov 2020 10:45:48 +0000 Received: from AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM ([fe80::9068:c899:48f:a8e3]) by AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM ([fe80::9068:c899:48f:a8e3%6]) with mapi id 15.20.3589.022; Fri, 20 Nov 2020 10:45:48 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Simon Glass , Tom Rini , Marcin Juszkiewicz , Rasmus Villemoes Subject: [PATCH 1/3] lib/uuid.c: change prototype of uuid_guid_get_str() Date: Fri, 20 Nov 2020 11:45:35 +0100 Message-Id: <20201120104537.619-2-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20201120104537.619-1-rasmus.villemoes@prevas.dk> References: <07954a18-fc7d-aaa2-cd1c-649c131b485a@prevas.dk> <20201120104537.619-1-rasmus.villemoes@prevas.dk> X-Originating-IP: [81.216.59.226] X-ClientProxiedBy: HE1PR0501CA0026.eurprd05.prod.outlook.com (2603:10a6:3:1a::36) To AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:3f::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (81.216.59.226) by HE1PR0501CA0026.eurprd05.prod.outlook.com (2603:10a6:3:1a::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Fri, 20 Nov 2020 10:45:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 81490558-42c9-4c52-d8fb-08d88d417159 X-MS-TrafficTypeDiagnostic: AM8PR10MB4276: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:400; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Znu/2sMcOtvkS85hVxxP9FQrfVDLUB1v1f0ZE5g8FQcF9BeB4Qn+VydUCwwt5EI7w7MN1a43658NVqYeNdqTRm0KBPfmJYJYDSnW/dHSq7R7GYOdmAmRAiwbKSopk/rFJPUX9N2C5aOUkVOc4qIlP4nGn6vxxnfnvVZFyVMmBex782MxlKXTZf54CUd2f67m5Ci/0vNDD9T/0LvQMBj8UqdjLmY25dhr1L4B7b/tq89RCmTYlB828DhtDHVJo3oFVW3dI3zHdwONYfb+NxLnAnQgsgGlg5oRiM2BI6nvAHNxG8n4SpxfmKMQOQEYKFylYNQ4NWBjfqZxWBZ9Tgn+DQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(136003)(39840400004)(366004)(396003)(376002)(346002)(6666004)(66556008)(5660300002)(52116002)(6512007)(6916009)(4326008)(83380400001)(6506007)(186003)(16526019)(6486002)(44832011)(66946007)(478600001)(26005)(66476007)(8676002)(107886003)(8936002)(2616005)(2906002)(316002)(8976002)(1076003)(956004)(54906003)(86362001)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: oLRp8ccKLbKHBvUQAl2l9W5Tm80WsxBZo9ZDRO/9TwqC3wuJ4WzYKL0bADnXZaoidxmhLmj+UWxoNb7Xpz6Zu4jdpL1/7uCrXC3G4ojiDouscuAA0aZ0K0GIYpUslDeJKKPjIHQNUTTHQABdnfv2KwROi7xGg5pXH/8wjYGsiXqu45pWRBVla+7V8odXFZAE1bQA/f5GHf6A42uth2EHPeFXy2/F3hrZrfp8xRbOS+TJ6bAYYq4lqzvGYQphVUbaczG2Q+IyoYIjdB+QJ39y4k+6oSJQPbWBK+YN+/5DvlC2gOZN2zHcETY5awd61qSsqC1UqV9v69Vu0Dzh4DBqs7Cxq5beH272XxAv6qXlsiGJjD30oETW2gsSay9GSB++DoE2DDCFgUuJv0snEje0NRCmHOLW6DCCn/C1nAgS4cU3GE4NE5k//78JSFDhkPmRjNWjHmYYO2lbZq0iRM0lgyvcx2xS0WcfNp95LX9R4N4U1bEW5qVfM26lnAmPlOJ0wPpfRzkjEV4VGK5teavclmkQJqA364ocOIYrr5BncIMh89nSY7kGP2p3FHPq4hRAGYsOGX3sLHR3emJslIuEUs241CKIf7jUQQ81N4JaT9dRApnpRqrT3DNunXc0LRpIje53aP6cDPJQ1anlDNYHRQ== X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 81490558-42c9-4c52-d8fb-08d88d417159 X-MS-Exchange-CrossTenant-AuthSource: AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2020 10:45:48.8418 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vH0IXAHq8G0ydRA1c87HCbYqlP2iY1lIjo3DYDd84yrMGWP8N9G2LNIxgSh3/ZRkb91XU6JKpQmqc6BupJu1BMbLngQpTrWECVMMLQMr3BA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR10MB4276 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean There's no reason to require an appropriately sized output parameter for the string, that's error-prone should the table ever grow an element with a longer string. We can just return the const char* pointer directly. Update the only caller accordingly, and get rid of pointless ifdeffery in the header so that the compiler always sees a declaration and can thus do type-checking, whether or not PARTITION_TYPE_GUID is enabled or not. Signed-off-by: Rasmus Villemoes --- disk/part_efi.c | 9 +++++---- include/uuid.h | 4 +--- lib/uuid.c | 11 +++++------ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index 60b1c1d761..2f922662e6 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -247,10 +247,11 @@ void part_print_efi(struct blk_desc *dev_desc) uuid_bin = (unsigned char *)gpt_pte[i].partition_type_guid.b; uuid_bin_to_str(uuid_bin, uuid, UUID_STR_FORMAT_GUID); printf("\ttype:\t%s\n", uuid); -#ifdef CONFIG_PARTITION_TYPE_GUID - if (!uuid_guid_get_str(uuid_bin, uuid)) - printf("\ttype:\t%s\n", uuid); -#endif + if (CONFIG_IS_ENABLED(PARTITION_TYPE_GUID)) { + const char *type = uuid_guid_get_str(uuid_bin); + if (type) + printf("\ttype:\t%s\n", type); + } uuid_bin = (unsigned char *)gpt_pte[i].unique_partition_guid.b; uuid_bin_to_str(uuid_bin, uuid, UUID_STR_FORMAT_GUID); printf("\tguid:\t%s\n", uuid); diff --git a/include/uuid.h b/include/uuid.h index 73c5a89ec7..0c653cb087 100644 --- a/include/uuid.h +++ b/include/uuid.h @@ -39,10 +39,8 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin, int str_format); void uuid_bin_to_str(const unsigned char *uuid_bin, char *uuid_str, int str_format); -#ifdef CONFIG_PARTITION_TYPE_GUID int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin); -int uuid_guid_get_str(const unsigned char *guid_bin, char *guid_str); -#endif +const char *uuid_guid_get_str(const unsigned char *guid_bin); void gen_rand_uuid(unsigned char *uuid_bin); void gen_rand_uuid_str(char *uuid_str, int str_format); #endif diff --git a/lib/uuid.c b/lib/uuid.c index e62d5ca264..6cfb6cd449 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -122,20 +122,19 @@ int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin) * uuid_guid_get_str() - this function get string for GUID. * * @param guid_bin - pointer to string with partition type guid [16B] - * @param guid_str - pointer to allocated partition type string [7B] + * + * Returns NULL if the type GUID is not known. */ -int uuid_guid_get_str(const unsigned char *guid_bin, char *guid_str) +const char *uuid_guid_get_str(const unsigned char *guid_bin) { int i; - *guid_str = 0; for (i = 0; i < ARRAY_SIZE(list_guid); i++) { if (!memcmp(list_guid[i].guid.b, guid_bin, 16)) { - strcpy(guid_str, list_guid[i].string); - return 0; + return list_guid[i].string; } } - return -ENODEV; + return NULL; } #endif