From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1E4EC433F5 for ; Thu, 6 Oct 2022 03:26:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 76CE684BAA; Thu, 6 Oct 2022 05:26:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de 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; secure) header.d=gmx.net header.i=@gmx.net header.b="SVrLcjug"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5F7C384C36; Thu, 6 Oct 2022 05:26:39 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (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 9A51184B0C for ; Thu, 6 Oct 2022 05:26:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1665026795; bh=Blu7GYDNMo5KAXRi8mj6MyVa8c++6PggjzuB9E1xQOc=; h=X-UI-Sender-Class:Date:Subject:To:References:Cc:From:In-Reply-To; b=SVrLcjugz8YGLRpzoWS7XTOp0tFtDHLcNjm/l8/MmoYNDpqdq1xeyIyE3OZ3Z2LFk 8Sv76GIIvQQ5d7P8ZP/0dP8ccgz81pG8R9sLnlbhuRuJ7VwH6gl+mPfPfQPtfwF7eg PRdDmD+3y4MznDBJU1cviKgEQNtyWoKM5pCWKUlA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.94] ([84.118.157.2]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MRCK6-1osKjv0V3U-00N7zR; Thu, 06 Oct 2022 05:26:35 +0200 Message-ID: Date: Thu, 6 Oct 2022 05:26:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH v4 2/6] efi: Add string conversion helper Content-Language: en-US To: Paul Barker References: <20221005121839.3938771-1-paul.barker@sancloud.com> <20221005121839.3938771-3-paul.barker@sancloud.com> Cc: u-boot@lists.denx.de, Ilias Apalodimas , Tom Rini From: Heinrich Schuchardt In-Reply-To: <20221005121839.3938771-3-paul.barker@sancloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:A8yn1pnxEoIMcRFBr/RRBbE35E21HZUSRsBipmYBsLKakPwEHE8 4FYnfxZivwdgroL4Q6E2yOhOIxb3vpLtGiYKx3zIbxYGTFr8M9ydGYpT3zoHvwVfplhbtvQ KR+iLRN5CtWvh6aBfoed6m7YR+Wc8aO2wx/uyYypspZJ+wQiFYYdQy31c6taTs7cSOAVJWj YPCkb4OqJehOf+SxhV4RA== X-UI-Out-Filterresults: notjunk:1;V03:K0:7RTVLkszOMc=:WsHECiaq9rfPEUOC+MsTF8 IMpzPaR5uCtzNfGPPbRPTXcANIBGHOyIvSvoeThDigr4+KfzHdZ4VOFuRE8/u+aa/xXSJdtBv bfLO/ZXz2B9MAEQ90g7eUKRt2l2fRhGhFtsvOy+AL6YsJwojp0nK7AcdsV7P635xnFoSRG2N1 n/zsOvGMnewX5k4SY4hd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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.6 at phobos.denx.de X-Virus-Status: Clean On 10/5/22 14:18, Paul Barker wrote: > Signed-off-by: Paul Barker > --- > include/efi_loader.h | 3 ++- > lib/efi_loader/efi_string.c | 24 ++++++++++++++++++++++++ > 2 files changed, 26 insertions(+), 1 deletion(-) > > diff --git a/include/efi_loader.h b/include/efi_loader.h > index 545ba06d9466..4dbbb2d3a06c 100644 > --- a/include/efi_loader.h > +++ b/include/efi_loader.h > @@ -985,9 +985,10 @@ struct pkcs7_message *efi_parse_pkcs7_header(const = void *buf, > /* runtime implementation of memcpy() */ > void efi_memcpy_runtime(void *dest, const void *src, size_t n); > > -/* commonly used helper function */ > +/* commonly used helper functions */ > u16 *efi_create_indexed_name(u16 *buffer, size_t buffer_size, const ch= ar *name, > unsigned int index); > +efi_string_t efi_convert_string(const char *str); > > extern const struct efi_firmware_management_protocol efi_fmp_fit; > extern const struct efi_firmware_management_protocol efi_fmp_raw; > diff --git a/lib/efi_loader/efi_string.c b/lib/efi_loader/efi_string.c > index 8bf1e493b89e..e21e09c94617 100644 > --- a/lib/efi_loader/efi_string.c > +++ b/lib/efi_loader/efi_string.c > @@ -8,6 +8,7 @@ > #include > #include > #include > +#include > > /** > * efi_create_indexed_name - create a string name with an index > @@ -41,3 +42,26 @@ u16 *efi_create_indexed_name(u16 *buffer, size_t buff= er_size, const char *name, > > return p; > } > + > +/** > + * efi_convert_string - Convert an ASCII or UTF-8 string to UTF-16 > + * @str: String to be converted > + * > + * Return: Converted string in UTF-16 format. The caller is responsible= for > + * freeing this string when it is no longer needed. > + */ > +efi_string_t efi_convert_string(const char *str) > +{ > + efi_string_t str_16, tmp; > + size_t sz_16; > + > + sz_16 =3D utf8_utf16_strlen(str); > + str_16 =3D calloc(sz_16 + 1, sizeof(u16)); > + if (!str_16) > + return NULL; > + > + tmp =3D str_16; > + utf8_utf16_strcpy(&tmp, str); > + > + return str_16; > +} We will be able to use the function for code simplification in the following places in future: cmd/efidebug.c:800: cmd/nvedit_efi.c:498: Reviewed-by: Heinrich Schuchardt