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 9A64CC433F5 for ; Thu, 6 Oct 2022 06:19:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DB1A884D80; Thu, 6 Oct 2022 08:19:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="GNy5jUlI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CFAF884D85; Thu, 6 Oct 2022 08:19:49 +0200 (CEST) Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0598382140 for ; Thu, 6 Oct 2022 08:19:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ej1-x632.google.com with SMTP id ot12so2342087ejb.1 for ; Wed, 05 Oct 2022 23:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=8YgrbfeQ3aKf5Qkj+VDZWIby8j3+Ojl2A9glXOT0i8A=; b=GNy5jUlIBYSRdLf+YXW5+jZUXVnuK+YPRuRHtyPeL2s7RPT/OnaIxEohL5/mC0uq4E jfvjRZY+qJ4QUqFxbNxYFKqoSMkrxUT7nJPRIYlpuu555s/L9R8Lz6VN9HdrGV3G0YDH 9D6LbCRusfzDnu6AxVKRts49Pw6vGRMwcq38G3VoLHd/XupPAqwEHsHcnrZPJwOIuqTP WXPvFn72uKi29XT93K686R7rgwWDKZ+EiMYXGL7FGQ9yp84nM8H6FvO61DGjmhcvJ3xq ZClh4bsQSB6AszNqphldEAu6/BTk58lYr/YYwVxLfyHNSiVjwLRTNnLJB9QiAUE3+2Pc rYgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=8YgrbfeQ3aKf5Qkj+VDZWIby8j3+Ojl2A9glXOT0i8A=; b=6efHiFnkZgW+hx6s3QfPOKfJsu1+SUn4VTGqH7cnqWtW7BeKPjsRUPlP/EHp/r42jf RYEd+LVVfkLt4wmtKTyJ+6P6yZqZnkADAr+e7RA2Bxni6G9kBlpqH2fOQdZwgtTJ7J80 ui2MforrZss0tvdwdvyj906sEvvOjfyCfRdHBb/oIjfSH/l2RAHa3vq0ZWWH5vz9C3Ca vW9Tzcd6n5QHQEs/WEAR9p5Epq4RFTXhsGTUECC7OGgxIb/1+JsQPNZUBpa/CTBXKq57 rKkDZstZolVxiP8CysLdzgQTlqRe4/iZY2P5LQY1mMXAPeC9VoLeXL3O3n14ELfbEgws 208g== X-Gm-Message-State: ACrzQf0EKbje12DDXDskSoYCZ7aY44fjPvODSI4RSEofE1+HHC8BVFwG mMTyq4cqnbIHCoo0OoPqYvc7ng== X-Google-Smtp-Source: AMsMyM5YYjolU1z765Pjj7Q6plXRUQ1iZvahd14T+rFcm6jMwuZ0M2fN2GImPh3irjBhxO8DDs8NXw== X-Received: by 2002:a17:907:94ce:b0:78c:6795:d545 with SMTP id dn14-20020a17090794ce00b0078c6795d545mr2596885ejc.530.1665037186367; Wed, 05 Oct 2022 23:19:46 -0700 (PDT) Received: from hera (ppp046103015185.access.hol.gr. [46.103.15.185]) by smtp.gmail.com with ESMTPSA id la3-20020a170907780300b00781dbdb292asm9695675ejc.155.2022.10.05.23.19.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 23:19:45 -0700 (PDT) Date: Thu, 6 Oct 2022 09:19:43 +0300 From: Ilias Apalodimas To: Paul Barker Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Tom Rini Subject: Re: [PATCH v4 2/6] efi: Add string conversion helper Message-ID: References: <20221005121839.3938771-1-paul.barker@sancloud.com> <20221005121839.3938771-3-paul.barker@sancloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221005121839.3938771-3-paul.barker@sancloud.com> 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.6 at phobos.denx.de X-Virus-Status: Clean Thanks Paul! On Wed, Oct 05, 2022 at 01:18:35PM +0100, 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 char *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 buffer_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 = utf8_utf16_strlen(str); > + str_16 = calloc(sz_16 + 1, sizeof(u16)); > + if (!str_16) > + return NULL; > + > + tmp = str_16; > + utf8_utf16_strcpy(&tmp, str); > + > + return str_16; > +} > -- > 2.25.1 > Reviewed-by: Ilias Apalodimas