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 C1D89C433F5 for ; Thu, 6 Oct 2022 08:04:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3D1FE84940; Thu, 6 Oct 2022 10:04:10 +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="MHRoa262"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ECE32844C2; Thu, 6 Oct 2022 10:04:08 +0200 (CEST) Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) (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 4AEDE84BAA for ; Thu, 6 Oct 2022 10:04:02 +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-ed1-x529.google.com with SMTP id e18so1681037edj.3 for ; Thu, 06 Oct 2022 01:04:02 -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=yOzEYpSQdUXRpW1hVkCXKAk3FSjgX+13F9H9PWlYMk8=; b=MHRoa262lAIxPUIFpqXK95tteT8QRG3bNnDdPQVW6m8gV7GnBgxf8SZSim04bC9ny0 he34rtY1SthXA+Tx7BGE+9EuaRmbMEYUhoUt6t/4fVsUh7u7wNOecTlFIwUza94he3r4 0tH4h0oYnK3rOb6VPBrnTWiWfYlcmncqkN4OLIGhjvl2CvIhLuZZk9g1hW6VVpSQ4yDl Kb4OCsxDgccpKsXYfiTQHHa0eBH2+8vbOxVlU+Fo34CJZTfF//oGNLOq93WfpnNSeEED wq7E6mc16sjYfrwE58/mTABLJLXj/4WiwRsP5h2zdxvtOsI/bj9eHyXUpabWtM50YCW7 fmHA== 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=yOzEYpSQdUXRpW1hVkCXKAk3FSjgX+13F9H9PWlYMk8=; b=PyV4W3gJseVVMRn4gyD+rbQIXNLrttFdb0x+l06HC4b4fWMjeuw7NIKlf+yBjxt1Q1 6WgNKvDytV06AQU2OauA1jwMnfu+Jq7EHmSAXfIlrXaSlBgZ2lxhXalVoUhD11oxvW/c K2FXd1/DUkIIDO1bhhBfSgBLTH4XiMYc7+S+CDLW7hoKpeJzcEwXyzN+2QTMkR2/7UZC tB7NRKbpLqrcChdVpWUh56rCPVqGpycjBRHIwk1ABGCNxPzXiHWwYc8bK2PyLa7cTl3+ /xfDmcOAnPbLOkPC+/Z7q8WWCj6ctlckf9VbA50vvFz/fKyCiu5RZP3PtIclu62zcSmX m3PQ== X-Gm-Message-State: ACrzQf1smDFpEd1KKmPgYl+nf+RPJm/8B67FJPMNApMDA3ec4M3ziu9i FXi+aJeP91S9Xw+id7G7jfL4ZGZFuBsBew== X-Google-Smtp-Source: AMsMyM6KVLHh88JBIloWjypmWafwnyJ/lHRtToMjePwltgNz5J6rqrgUOWcmXjApTAtIfGCGTK1kWw== X-Received: by 2002:a05:6402:26c1:b0:459:e394:489b with SMTP id x1-20020a05640226c100b00459e394489bmr1380314edd.117.1665043441956; Thu, 06 Oct 2022 01:04:01 -0700 (PDT) Received: from hera (ppp046103015185.access.hol.gr. [46.103.15.185]) by smtp.gmail.com with ESMTPSA id i15-20020a170906444f00b0073c0b87ba34sm9833328ejp.198.2022.10.06.01.04.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 01:04:01 -0700 (PDT) Date: Thu, 6 Oct 2022 11:03:59 +0300 From: Ilias Apalodimas To: Heinrich Schuchardt Cc: u-boot@lists.denx.de Subject: Re: [PATCH 1/1] cmd: simplify do_env_set_efi() Message-ID: References: <20221006045419.30435-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221006045419.30435-1-heinrich.schuchardt@canonical.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 Hi Heinrich, On Thu, Oct 06, 2022 at 06:54:19AM +0200, Heinrich Schuchardt wrote: > Use efi_convert_string() to convert a UTF-8 to a UTF-16 string. > > Signed-off-by: Heinrich Schuchardt > --- > cmd/nvedit_efi.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c > index 770877c527..0411b66559 100644 > --- a/cmd/nvedit_efi.c > +++ b/cmd/nvedit_efi.c > @@ -383,7 +383,6 @@ int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int argc, > u32 attributes; > bool default_guid, verbose, value_on_memory; > u16 *var_name16 = NULL, *p; > - size_t len; > efi_status_t ret; > > if (argc == 1) > @@ -487,16 +486,13 @@ int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int argc, > 16, 1, value, size, true); > } > > - len = utf8_utf16_strnlen(var_name, strlen(var_name)); > - var_name16 = malloc((len + 1) * 2); > + var_name16 = efi_convert_string(var_name); > if (!var_name16) { > printf("## Out of memory\n"); > ret = CMD_RET_FAILURE; > goto out; > } > p = var_name16; > - utf8_utf16_strncpy(&p, var_name, len + 1); > - Shouldn't we remove p as well after the cleanup ? > ret = efi_set_variable_int(var_name16, &guid, attributes, size, value, > true); > unmap_sysmem(value); > -- > 2.37.2 > Cheers /Ilias