From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 85A87780091 for ; Sun, 24 Dec 2023 22:59:46 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=qPAiXgc4OwKmeT1ig2iiT+I03sZAL9je21qJEzsBlfU=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1703458785; v=1; b=iGqmNC+2lyMcyGFb6NCXchHB3/NWyarEry/RILAjG86aPIzgTJCx1RDdO3+T2FVuyvRwqozq EizB6I5FhDok4bWOcs7nAs5woFWvFsZKm9edkBwN8dZmVPF7h2hYajE/ssuUevGYvDhIcCB+7uX 9WslQhLO0TVONf3nhg19Cvd8= X-Received: by 127.0.0.2 with SMTP id LiJGYY7687511xQFFH3Z804N; Sun, 24 Dec 2023 14:59:45 -0800 X-Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by mx.groups.io with SMTP id smtpd.web11.35802.1703458782931361092 for ; Sun, 24 Dec 2023 14:59:43 -0800 X-Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-50e7c6e3c63so67165e87.3 for ; Sun, 24 Dec 2023 14:59:42 -0800 (PST) X-Gm-Message-State: OpHnIsZB7fzAGRwUVsN9H724x7686176AA= X-Google-Smtp-Source: AGHT+IHbYDHSRyb80mVrAOCjZd3/O/ecNluGdfPl1OO60ArD1TuafFlIeks7SU6TPZj7mL++rTkzJw== X-Received: by 2002:a19:750c:0:b0:50e:7c70:fbe9 with SMTP id y12-20020a19750c000000b0050e7c70fbe9mr19707lfe.150.1703458781076; Sun, 24 Dec 2023 14:59:41 -0800 (PST) X-Received: from localhost.localdomain ([79.164.221.98]) by smtp.gmail.com with ESMTPSA id be44-20020a056512252c00b0050e78f5178asm326596lfb.262.2023.12.24.14.59.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 24 Dec 2023 14:59:40 -0800 (PST) From: "Mike Maslenkin" To: devel@edk2.groups.io Cc: abner.chang@amd.com, nicklew@nvidia.com, igork@ami.com, Mike Maslenkin Subject: [edk2-devel] [PATCH v3 12/16] RedfishDiscoverDxe: refine InitInformationData() function Date: Mon, 25 Dec 2023 01:59:23 +0300 Message-Id: <20231224225927.9119-13-mike.maslenkin@gmail.com> In-Reply-To: <20231224225927.9119-1-mike.maslenkin@gmail.com> References: <20231224225927.9119-1-mike.maslenkin@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mike.maslenkin@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=iGqmNC+2; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Cache size of ASCII string in local variable. Cc: Nickle Wang Cc: Igor Kulchytskyy Signed-off-by: Mike Maslenkin Reviewed-by: Abner Chang --- .../RedfishDiscoverDxe/RedfishDiscoverDxe.c | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPk= g/RedfishDiscoverDxe/RedfishDiscoverDxe.c index 0ac41f09559b..76f87e4fe5e7 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c @@ -738,39 +738,47 @@ InitInformationData ( IN CONST CHAR8 *ProductVer OPTIONAL=0D )=0D {=0D + UINTN AllocationSize;=0D +=0D if (RedfishVersion !=3D NULL) {=0D Information->RedfishVersion =3D *RedfishVersion;=0D DEBUG ((DEBUG_MANAGEABILITY, "Redfish service version: %d.\n", Informa= tion->RedfishVersion));=0D }=0D =0D if (RedfishLocation !=3D NULL) {=0D - Information->Location =3D AllocatePool (AsciiStrSize (RedfishLocation)= * sizeof (CHAR16));=0D - AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, AsciiSt= rSize (RedfishLocation) * sizeof (CHAR16));=0D + AllocationSize =3D AsciiStrSize (RedfishLocation) * sizeof (CHA= R16);=0D + Information->Location =3D AllocatePool (AllocationSize);=0D + AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, Allocat= ionSize);=0D DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", Inform= ation->Location));=0D }=0D =0D if (Uuid !=3D NULL) {=0D - Information->Uuid =3D AllocatePool (AsciiStrSize (Uuid) * sizeof (CHAR= 16));=0D - AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AsciiStrSize (Uuid) * = sizeof (CHAR16));=0D + AllocationSize =3D AsciiStrSize (Uuid) * sizeof (CHAR16);=0D + Information->Uuid =3D AllocatePool (AllocationSize);=0D + AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AllocationSize);=0D DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", Information->Uuid)= );=0D }=0D =0D if (Os !=3D NULL) {=0D - Information->Os =3D AllocatePool (AsciiStrSize (Os) * sizeof (CHAR16))= ;=0D - AsciiStrToUnicodeStrS (Os, Information->Os, AsciiStrSize (Os) * sizeof= (CHAR16));=0D - DEBUG ((DEBUG_MANAGEABILITY, "Redfish service OS: %s, Version:%s.\n", = Information->Os, Information->OsVersion));=0D + AllocationSize =3D AsciiStrSize (Os) * sizeof (CHAR16);=0D + Information->Os =3D AllocatePool (AllocationSize);=0D + AsciiStrToUnicodeStrS (Os, Information->Os, AllocationSize);=0D }=0D =0D if (OsVer !=3D NULL) {=0D - Information->OsVersion =3D AllocatePool (AsciiStrSize (OsVer) * sizeof= (CHAR16));=0D - AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, AsciiStrSize (Os= Ver) * sizeof (CHAR16));=0D + AllocationSize =3D AsciiStrSize (OsVer) * sizeof (CHAR16);=0D + Information->OsVersion =3D AllocatePool (AllocationSize);=0D + AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, AllocationSize);= =0D + DEBUG ((DEBUG_MANAGEABILITY, "Redfish service OS: %s, Version:%s.\n", = Information->Os, Information->OsVersion));=0D }=0D =0D if ((Product !=3D NULL) && (ProductVer !=3D NULL)) {=0D - Information->Product =3D AllocatePool (AsciiStrSize (Product) * sizeof= (CHAR16));=0D - AsciiStrToUnicodeStrS (Product, Information->Product, AsciiStrSize (Pr= oduct) * sizeof (CHAR16));=0D - Information->ProductVer =3D AllocatePool (AsciiStrSize (ProductVer) * = sizeof (CHAR16));=0D - AsciiStrToUnicodeStrS (ProductVer, Information->ProductVer, AsciiStrSi= ze (ProductVer) * sizeof (CHAR16));=0D + AllocationSize =3D AsciiStrSize (Product) * sizeof (CHAR16);=0D + Information->Product =3D AllocatePool (AllocationSize);=0D + AsciiStrToUnicodeStrS (Product, Information->Product, AllocationSize);= =0D + AllocationSize =3D AsciiStrSize (ProductVer) * sizeof (CHAR16= );=0D + Information->ProductVer =3D AllocatePool (AllocationSize);=0D + AsciiStrToUnicodeStrS (ProductVer, Information->ProductVer, Allocation= Size);=0D DEBUG ((DEBUG_MANAGEABILITY, "Redfish service product: %s, Version:%s.= \n", Information->Product, Information->ProductVer));=0D }=0D }=0D --=20 2.32.0 (Apple Git-132) -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112871): https://edk2.groups.io/g/devel/message/112871 Mute This Topic: https://groups.io/mt/103354131/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-