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 63A99740032 for ; Tue, 16 Jan 2024 05:01:28 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=veiyp6+Sg/MkfXi43HuEtEmcKU3i5t0EumMQMTtoxSo=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1705381287; v=1; b=vbz05IWTfBaeqn1Leer7GLacYXz56c86SSoude4r5OEUs2vBPAiziqswoKiEgGuLqdFi6zTN B/sW8lsuEnss5ByihxP9hLDg/dJtESQu0FVC/kxWbhU1ioKI0c+MrTc+CnHekHmUQGbPdEMO+Hm K7Y5q9Kq4HxhdQCfJXZNfYGw= X-Received: by 127.0.0.2 with SMTP id C0U0YY7687511xjZaiWgY2ch; Mon, 15 Jan 2024 21:01:27 -0800 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.48]) by mx.groups.io with SMTP id smtpd.web10.3219.1705374886542247008 for ; Mon, 15 Jan 2024 19:14:46 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XG4eAfjuQEnyTSvkkuAbP9SBGs7KKdFMBKta/3lLwcHPzoNTAnEKhlRgBdxjj8Dbsl0aaBoKhFi2tsWg5OkYBzMB2WB2/3xvIfDRD0D4NqAKhVgKe1YuupGFh4de6sWZYTkB1HlImmojyx04jICD5qX0Rd31ySFjATTsOWSPMzdbY6utdz8XMfRrywxTQiQztsntUpxbY7jZdiJj+gXVmiMWxWP9Ni1xfptfMlKx0fkJlobLIib+6Hyew/KJAgN+loyjpgBPSA405FPqKj6obqlacXxg0XzWyLFuBYZWztJFK6rJS644R8M/aeujMgumsebFHzMql5kcVyuOXXF/VA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yszCLdbJrxpWBGN4Sx7VLhY9HYZ9QEdTq55Wd8DBq5I=; b=jcQXojEArxDdv4XxwDXO5POftV4xPbCslhsuy9oKYfcheRQP778Vv/HbVSAwekg7ki/ghYoJK7RMhi6KZrdqzRi+tvtDt+0XPh7C30KYOEeD6p59ySjmBLmKikkAuz5wDZSEt+wSsQAqZRcShHtsPXIkgE2TgUR6EovAVLkltHopPquetwRBTevGPNg3iXsrmOeCSc6t+FQMOzqKxJmclAnXsr8oKtzzKkIeTI1qBeBwuMN+4iGn1iPRAHeqW1ZCVfgcNtOtIxP4lJ3u2mvizRXIuYhAvaPE1qK0rQfavRFWO6TZAsHE0dzvYLkSrr9GyAawH646gzLvaf5pazpslg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none X-Received: from MW4PR12MB7031.namprd12.prod.outlook.com (2603:10b6:303:1ef::6) by DS7PR12MB6047.namprd12.prod.outlook.com (2603:10b6:8:84::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.21; Tue, 16 Jan 2024 03:14:43 +0000 X-Received: from MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::a78e:602e:415c:4cb4]) by MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::a78e:602e:415c:4cb4%3]) with mapi id 15.20.7181.020; Tue, 16 Jan 2024 03:14:43 +0000 From: "Nickle Wang via groups.io" To: "abner.chang@amd.com" , "devel@edk2.groups.io" CC: Igor Kulchytskyy Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH 2/3] RedfishClientPkg/RedfishFeatureUtilityLib: Add two helper functions Thread-Topic: [edk2-redfish-client][PATCH 2/3] RedfishClientPkg/RedfishFeatureUtilityLib: Add two helper functions Thread-Index: AQHaRQc3jRpf35Te40u0gtteKiWcubDbyLyg Date: Tue, 16 Jan 2024 03:14:43 +0000 Message-ID: References: <20240112032622.274-1-abner.chang@amd.com> <20240112032622.274-2-abner.chang@amd.com> In-Reply-To: <20240112032622.274-2-abner.chang@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR12MB7031:EE_|DS7PR12MB6047:EE_ x-ms-office365-filtering-correlation-id: 06037ee0-e4aa-41e0-150b-08dc164148f7 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: F5I4B+aUs/Uw27xGnmrzCcScjj+VCskkTV7sHKkXt5TEtpikVLPVua45TEiHkmm1kb1PDfvRSzTlN8wMemATVNhAz9mWMrefacTfcJNXXd/hg6A8dmTfTdlXQeXswFMweGEn9vDrq0wCrEOJ97Zz/sceSbt2ylnZsfQrglEk8FbQeAaiwhpADxT26ixw7s/wmoIWjhqEaTHzxtXC4G7JeYqvQXyCAy7j2ED8zHfgN4P1WhYBtN0nQP83FrNV8RTZBWi/HGPPc8bK8/nfY0NJeoVTI9ceNDNRbPbkg8UX4YjxI3SwIXafaVIV8na23BvBX3FjJ0uRvSRgN9fVkjzJc1Rfy84kuuvB3TH0vFbbIqSFFs3ADBGrNNuHPRnARwLOHeoWKFIwcHfb6oNLSFAIgFzf4X1kailwvmFfZLQvRhFckpPRWQuLpIKu6agJ1k6xiuwGaraHcnJDKsFhFZsSZf+gcL8ddCM6MrPxkFpxGTZ2YyJ5Po4XAFa6TkfPiVgLHu4izVfdazT5H2l4065rTYr8nh0vnqxKmsYAq1ZWP5XdbL4rCnSfON2qdVEYuq4jMHBbBZZJ2SGNncC4shgCWZO2BQaQQ1jO9OBZspdeKU0pIJP4pX/Tg7Fl630wwCm1BPW3QqCV8Pd+3WQMeKvYrG4r3JFvjlVi7r5Pb7TZr6Q= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?hFVxl4jjqgXJNdOLTaielgSi/S2ZJKdzaxPv5dVDQsMtGO7Rs1dgSP6SX+f5?= =?us-ascii?Q?es+qk3gZ0XffWaGilQKDUJWNKMq+79+DaI5ugBDx39mRg25k1UhbzwLBHnY1?= =?us-ascii?Q?0WqR854G4cru/z3aaeU7WaBbsLOsCOtIxy3czcreH+KTjW9ALYBjx3z1IlzK?= =?us-ascii?Q?sR1Lp8e4VPTe1TFQe1dGT3BRaIc2ZaYKUVWgEmsf65oexKD7XgHQ1iRYB/dk?= =?us-ascii?Q?uupAsLTWO2k6r3Jcw7diXDY7RQ2vSmE09bfVGMF7MeS87I64UXAKWq5uLrI1?= =?us-ascii?Q?+DmZfB97tPg2aldN15KxQLGoGAxpWL6GUsTV+mhPELXewWambSTww0r83slh?= =?us-ascii?Q?0BWyoIsP6h1WnktAdP65a3QGcZZOxRmrkreQKynTjNvyy2OQCsd9HOtBFGmX?= =?us-ascii?Q?vsckLvaUirVM2Nd6/gE5kVhAvRkaHn2eelQZ9HG9dzzbZj3OAMuhmLCAUNpS?= =?us-ascii?Q?QNj8eCNftOSGKfIHoiZuXIXiLpl8EoiRKzmcKWhRUm0GoiajDUqxh74SgqL6?= =?us-ascii?Q?/TD0HQsuneP3LtrZ6jsZjgDK1Bn1Le3mxomZsjhkYJVdq5qudFB3AvDmXyGh?= =?us-ascii?Q?jOBYzj3e/AnL2cY07Bywy++ZjpvxnDmFia0WkiZkSR5nIR7ZcQCQYuq/lhPz?= =?us-ascii?Q?ee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?= =?us-ascii?Q?WL8rCYhgXQH/fdJtpdykKVn+UF0INpl/fOZhY43qOJ7tqoOkqsMgergOWv4D?= =?us-ascii?Q?J1UxHMNbosivhk/bUtKedrIYKAjQnSl/YY/vdFbeHDM8?= MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR12MB7031.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06037ee0-e4aa-41e0-150b-08dc164148f7 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jan 2024 03:14:43.2181 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: jYXOWkEytp8BCColc85cLHeGadDXBGFwDZkRCEykAGqMfuyekFfyEci9ZrG3sG+dOQS0fdfB2FxC9HgUby9VfA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6047 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,nicklew@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: FT3YOxlftBtwlt1UkyPTetnNx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" 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=vbz05IWT; dmarc=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; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") Please see my comments below. Regards, Nickle > -----Original Message----- > From: abner.chang@amd.com > Sent: Friday, January 12, 2024 11:26 AM > To: devel@edk2.groups.io > Cc: Nickle Wang ; Igor Kulchytskyy > Subject: [edk2-redfish-client][PATCH 2/3] > RedfishClientPkg/RedfishFeatureUtilityLib: Add two helper functions >=20 > External email: Use caution opening links or attachments >=20 >=20 > From: Abner Chang >=20 > - Add RedfishRemoveUnchangeableProperties () to remove > unchangeable Redfish properties such as @OData.id. > - Add DestoryRedfishCharArray () to free Redfish string > array. >=20 > Signed-off-by: Abner Chang > Cc: Nickle Wang > Cc: Igor Kulchytskyy > --- > .../RedfishFeatureUtilityLib.inf | 1 + > .../Library/RedfishFeatureUtilityLib.h | 35 ++++++++ > .../RedfishFeatureUtilityLib.c | 79 +++++++++++++++++++ > 3 files changed, 115 insertions(+) >=20 > diff --git > a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib.inf > b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib.inf > index 63330c8e9d..d8f3da3732 100644 > --- > a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib.inf > +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUt > +++ ilityLib.inf > @@ -37,6 +37,7 @@ > [LibraryClasses] > BaseLib > BaseMemoryLib > + ConverterCommonLib > DebugLib > MemoryAllocationLib > RedfishLib > diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h > b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h > index 0f8aede5c4..1b6d3f4cf8 100644 > --- a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h > +++ b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h > @@ -821,6 +821,23 @@ AddRedfishCharArray ( > IN UINTN ArraySize > ); >=20 > +/** > + > + Destroy Redfish string array > + > + @param[in] Head The head of string array. > + @param[in] ArraySize The size of StringArray. > + > + @retval EFI_SUCCESS String array is destroyed successfully. > + @retval Others Error happens > + > +**/ > +EFI_STATUS > +DestoryRedfishCharArray ( > + IN RedfishCS_char_Array *Head, > + IN UINTN ArraySize > + ); > + > /** >=20 > Create numeric array and append to array node in Redfish JSON convert = format. > @@ -1024,4 +1041,22 @@ ValidateRedfishStringArrayValues ( > OUT BOOLEAN *ValueChanged > ); >=20 > +/** > + This function removes the unchangeable Redfish properties from input > JsonString. > + New JSON string is returned in JsonString and the memory of original > +pointer to input > + JsonString was freed. Caller is responsible to free the memory > +pointed by output > + JsonString. > + > + @param[in,out] JsonString On input, this is the pointer to original = JSON string. > + On output, this is the new pointer to the = updated JSON string. > + > + @retval EFI_SUCCESS The unchangeable Redfish properties were removed > from original JSON string. > + @retval Others There are problems to remove unchangeable Redfis= h > properties. > + > +**/ > +EFI_STATUS > +RedfishRemoveUnchangeableProperties ( > + IN OUT CHAR8 **JsonString > + ); 1) I am thinking that can we use "ReadOnly" instead of "Unchangeable"? 2) Can we have two parameters for input and output string? Caller can decid= e when to release input string and this function does not do this for calle= r. For example: RedfishRemoveReadOnlyProperties ( IN CHAR8 *JsonString, OUT CHAR8 **ModifedString ); > + > #endif > diff --git > a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib.c > b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib.c > index aa723264e8..b16a811bb1 100644 > --- > a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib.c > +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUt > +++ ilityLib.c > @@ -3412,6 +3412,40 @@ AddRedfishCharArray ( > return EFI_SUCCESS; > } >=20 > +/** > + > + Destroy Redfish string array > + > + @param[in] Head The head of string array. > + @param[in] ArraySize The size of StringArray. > + > + @retval EFI_SUCCESS String array is destroyed successfully. > + @retval Others Error happens > + > +**/ > +EFI_STATUS > +DestoryRedfishCharArray ( > + IN RedfishCS_char_Array *Head, > + IN UINTN ArraySize > + ) > +{ > + UINTN Index; > + RedfishCS_char_Array *NextPointer; > + > + if ((Head =3D=3D NULL) || (ArraySize =3D=3D 0)) { > + return EFI_INVALID_PARAMETER; > + } > + > + for (Index =3D 0; Index < ArraySize; Index++) { > + NextPointer =3D Head->Next; > + if (Head !=3D NULL) { > + FreePool (Head); I suggest setting Head to NULL after FreePool call. So, no one can use this= memory by accident. > + } > + Head =3D NextPointer; > + } > + return EFI_SUCCESS; > +} > + > /** >=20 > Create numeric array and append to array node in Redfish JSON convert = format. > @@ -3935,6 +3969,51 @@ ValidateRedfishStringArrayValues ( > return EFI_SUCCESS; > } >=20 > +/** > + This function removes the unchangeable Redfish properties from input > JsonString. > + New JSON string is returned in JsonString and the memory of original > +pointer to input > + JsonString was freed. Caller is responsible to free the memory > +pointed by output > + JsonString. > + > + @param[in,out] JsonString On input, this is the pointer to original = JSON string. > + On output, this is the new pointer to the = updated JSON string. > + > + @retval EFI_SUCCESS The unchangeable Redfish properties were removed > from original JSON string. > + @retval Others There are problems to remove unchangeable Redfis= h > properties. > + > +**/ > +EFI_STATUS > +RedfishRemoveUnchangeableProperties ( > + IN OUT CHAR8 **JsonString > + ) > +{ > + RedfishCS_status Status; > + CHAR8 *UpdatedJsonString; > + > + if ((JsonString =3D=3D NULL) || (*JsonString =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + UpdatedJsonString =3D AllocateZeroPool (AsciiStrSize (*JsonString)); > + if (UpdatedJsonString =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Insufficient memory for > UpdatedJsonString.\n", __func__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + Status =3D RemoveUnchangeableProperties ( > + (RedfishCS_char *)*JsonString, > + (RedfishCS_char *)UpdatedJsonString, > + (RedfishCS_uint32)AsciiStrSize (*JsonString) > + ); > + if (Status !=3D RedfishCS_status_success) { > + return EFI_DEVICE_ERROR; > + } > + > + FreePool (*JsonString); > + *JsonString =3D UpdatedJsonString; > + return EFI_SUCCESS; > +} > + > /** >=20 > Install Boot Maintenance Manager Menu driver. > -- > 2.37.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113862): https://edk2.groups.io/g/devel/message/113862 Mute This Topic: https://groups.io/mt/103676919/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-