From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.47]) by mx.groups.io with SMTP id smtpd.web10.8580.1688524635243376328 for ; Tue, 04 Jul 2023 19:37:15 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=xZkoXF/I; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.223.47, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YTka0XwJs1YgIfFOPNlSqYV/eHqtOXTTpt90XYtajxiwDGDvuAEyf5i0mxus6RKlB8bkVq1iHq3MrcpP0qfV7pmfpJ9mt8dOHmDVQmYCWC9gp3fvtnykLvqIrXYcWDNcw38BH7s0nwa29PF6VllnM5trqdNrR79hvZVk+6FL8G+ccew+CbtVSsfaXc3g1Rj4KyiY8nwMORSZ8t95KZo0Q8t9UtRKec6FjQujCX7kYE87u9ja5ricHkvzBp1MYvsJyPGgz2AtNkhX+K8egXZU9lEBlWdyz+qxs0vDSi63FdlC8dFz8d7aYkcdDkZNGUEdQM+IY6iL773c15qXtiRyhw== 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=dJ/WIQEKf4hDs2g05HA4NixeGJDnbnDumkMO5MDLCjk=; b=Bx3UKlprXOBfzVQGpp/uCJXBbL9LEKh0t+vgna3VOxo1FoVat0MU3PeRqtXhKaPbhsxJJ67ua1GSYIaS5++Ui/mHwTToU6G6oWAK38pbqnpjqAV9kB1K/XpY4kZzOTyhh0XKQjCqoDKwSUf9bZsfjCEBcCEgKGaciOf/cgjzdkMZzqyROhEeTrmIBy/vGw6EjcAe72/inz1+EyKoRX6vGGyfLHAtmciyVNI0DPiHguv0xwY7SGuwoDqdHuyYvN9RZAcsWSdPZ4mDkUVTxoQ8LZysRk5ijmKhRSTVJCldt2k9ejfvsN95NMEsR3PhoNHwCLSyXarJt0c62SmJTg9Xhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dJ/WIQEKf4hDs2g05HA4NixeGJDnbnDumkMO5MDLCjk=; b=xZkoXF/IWBTFggq4DCbmZS7hlBJLtI3UYUkTCou/W5swT17YaGZpeLuQKR9anay4BGgygRw44j3+m/jyq1YEMGupAxds4rpgZ1VhTqAPTl/DIO9szQyN1SRL4KeWcrl2MzfxKZu8Aq2cI9wf5PMUdXvIQtqDKTKmCmGmBWUaZks= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by SN7PR12MB8817.namprd12.prod.outlook.com (2603:10b6:806:347::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.24; Wed, 5 Jul 2023 02:37:12 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::edb0:bed8:c650:5040]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::edb0:bed8:c650:5040%6]) with mapi id 15.20.6544.024; Wed, 5 Jul 2023 02:37:12 +0000 From: "Chang, Abner" To: Nickle Wang , "devel@edk2.groups.io" CC: Igor Kulchytskyy , Nick Ramirez Subject: Re: [PATCH 3/3] RedfishPkg/JsonLib: add object clear interface Thread-Topic: [PATCH 3/3] RedfishPkg/JsonLib: add object clear interface Thread-Index: AQHZrbEwDlw4LKZtiESs3z547YZJca+qd8mA Date: Wed, 5 Jul 2023 02:37:11 +0000 Message-ID: References: <20230703132030.7271-1-nicklew@nvidia.com> In-Reply-To: <20230703132030.7271-1-nicklew@nvidia.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=87ddf2e1-cea4-43fd-a815-c885ad853f64;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=0;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-07-05T02:37:05Z;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB3966:EE_|SN7PR12MB8817:EE_ x-ms-office365-filtering-correlation-id: d8570885-962d-43b2-6b5a-08db7d00bc68 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: eStRVlNSjVp2eVPZiZ7O5YgtbcSZn3WJZCdMuSi9qwfsJs60ggLw/tydOIYMJj26tTe/N98F+JWbwhbTGo279+eAFfMy/qO+W2jPBYUizxsjScuFqPzOIpg0wbA0E6k6Z2ud9PYYioUIuZ6T0EdLC2IHxEyoYzu55Gx1mozSu4j3nLC9CWl/nb1pMYJsbT53x4saKwj3QgvrPLjk2E7+RLH/rm+gUbx2d01jqhy6F3wJVzSBL1hEE/v9E/20Cj7lKh1FOAkDMFOUPQq43oG91TlubhLHXKblkvlm+Kno2LrLh+jwdXjgUbNTA0Idvh8RfBIEyqmCSeLyzMwq6bpLxEcdpkimMGHQkk9l8/UxkLFSx/cgsmAbbiVteP8E7B2ybkYA4rQzt2muZihPw529O3ECZyprpRv9IY9wFz/c2u1u5Ibt/G8Dtho5NaoyDGC4W9mN3u56AFYUzCxHdtepwT0iTuzT00Z2Z47lu/qwe6x7h/5y/TmTxJgo8wIyU83xd8U9IGa9Or8aYH6Bu2Wh/4UtbC2LhzlgC6TgW2pjYkibTgw93AbOfDaFiIMVYch3CHuV1DjD4yclXEAw/UhadC1XvY0Ei7MHPMz+UOlX2uI= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3966.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(366004)(396003)(376002)(346002)(39860400002)(451199021)(66556008)(76116006)(4326008)(66446008)(66946007)(316002)(478600001)(66476007)(33656002)(64756008)(8676002)(8936002)(52536014)(5660300002)(2906002)(86362001)(41300700001)(55016003)(9686003)(966005)(38070700005)(110136005)(54906003)(7696005)(38100700002)(53546011)(6506007)(186003)(26005)(122000001)(71200400001)(83380400001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?UpBP9aY4oO0QILXFaVnwIsIEq4QR4k+eEWVP5B8NQ/D/8WrTGnVK+cOHTJHw?= =?us-ascii?Q?Hy1RMOgrif6GM4Sbi5oeytapGdKFEbvhWNf6i6rFA2D6OthDqfBjRKiHiWqc?= =?us-ascii?Q?ajOt/CCeSn46LjOlkLWJmrMLGptXnLd9EfFYpyZuTp5t4pLDcFj8dFnCh0Q8?= =?us-ascii?Q?KY8yfh/ncezJOv1aW0nZuLEOoaEh9CP0fzz6mlGcw6sVrSN5zfOJE1F+UCY1?= =?us-ascii?Q?PuH9hBodQNT0hJCBGJzoyZmAL7/PziI5J8kQEJWwl2dX+Eg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18UlDo11RZjSIPdAtHlGEkeZ/+vhTVU3uOO24PIOS6LyRoe1eN/o?= =?us-ascii?Q?b58ggbdcNC9Hiw6X0Phq9i7Gmro8Gy/v3/z5pL01cXAXzqX9Q6wkjn4KO8RI?= =?us-ascii?Q?I8p0zGBSIQA0Qb/Dne+TjcpgXdoz9pYFs6Dknpx+jxLYxofNrkAUJmCSVDij?= =?us-ascii?Q?wvx+/oHJVBUAuKGlZBMUx6CHKYOFrx9inMus8a8kILeCco1wR5yk6VjrKHqk?= =?us-ascii?Q?rubWRsxHWXiJrCUctwrToa0XCD5ERtWXzFmiGLDiaLRr3VbNuXn+uaM8uD5/?= =?us-ascii?Q?SAJvsCJ1Gkqa+OwsHkFBjfcq2oZmuHWEMWdqEkh6mgWufbei17na4O0TI2po?= =?us-ascii?Q?dghGb36PVUSBjpG4D3AYZXxKByCpHQwBAgOayz3hsn0ADO+WX4Q0cenDQNFr?= =?us-ascii?Q?ycIYJ7IKDc27aZsKywk=3D?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8570885-962d-43b2-6b5a-08db7d00bc68 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jul 2023 02:37:11.7240 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ORnzAMFsL7oPKu4iKvwCvFSSYnAH5qSseNSiAD00Hl81fGYx/2sCWby0dpKscZydITxt2USWvazno08CDcfO9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8817 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Reviewed-by: Abner Chang > -----Original Message----- > From: Nickle Wang > Sent: Monday, July 3, 2023 9:21 PM > To: devel@edk2.groups.io > Cc: Chang, Abner ; Igor Kulchytskyy > ; Nick Ramirez > Subject: [PATCH 3/3] RedfishPkg/JsonLib: add object clear interface > > Caution: This message originated from an External Source. Use proper caut= ion > when opening attachments, clicking links, or responding. > > > -Add JsonObjectClear() interface for application to clear > all elements in JSON object. > -Fix typo. > > Signed-off-by: Nickle Wang > Cc: Abner Chang > Cc: Igor Kulchytskyy > Cc: Nick Ramirez > --- > RedfishPkg/Include/Library/JsonLib.h | 33 +++++++++++++++++------ > RedfishPkg/Library/JsonLib/JsonLib.c | 39 ++++++++++++++++++++++------ > 2 files changed, 56 insertions(+), 16 deletions(-) > > diff --git a/RedfishPkg/Include/Library/JsonLib.h > b/RedfishPkg/Include/Library/JsonLib.h > index f98f4e779ede..8f31d9341481 100644 > --- a/RedfishPkg/Include/Library/JsonLib.h > +++ b/RedfishPkg/Include/Library/JsonLib.h > @@ -3,6 +3,7 @@ > > Copyright (c) 2019, Intel Corporation. All rights reserved.
> (C) Copyright 2021 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserve= d. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -97,7 +98,7 @@ typedef enum { > > More details for reference count strategy can refer to the API descrip= tion for > JsonValueFree(). > > - @retval The created JSON value which contains a JSON array or NUL= L if > intial a JSON array > + @retval The created JSON value which contains a JSON array or NUL= L if > initial a JSON array > is failed. > > **/ > @@ -116,7 +117,7 @@ JsonValueInitArray ( > > More details for reference count strategy can refer to the API descrip= tion for > JsonValueFree(). > > - @retval The created JSON value which contains a JSON object or NU= LL if > intial a JSON object > + @retval The created JSON value which contains a JSON object or NU= LL if > initial a JSON object > is failed. > > **/ > @@ -571,6 +572,22 @@ JsonObjectSize ( > IN EDKII_JSON_OBJECT JsonObject > ); > > +/** > + The function removes all elements from object. Returns 0 on success an= d -1 > if object is not > + a JSON object. The reference count of all removed values are decrement= ed. > + > + @param[in] JsonObject The provided JSON object. > + > + @retval EFI_ABORTED Some error occur and operation abo= rted. > + @retval EFI_SUCCESS JSON value has been appended to th= e end of > the JSON array. > + > +**/ > +EFI_STATUS > +EFIAPI > +JsonObjectClear ( > + IN EDKII_JSON_OBJECT JsonObject > + ); > + > /** > The function is used to enumerate all keys in a JSON object. > > @@ -705,7 +722,7 @@ JsonArrayAppendValue ( > More details for reference count strategy can refer to the API descrip= tion for > JsonValueFree(). > > @param[in] JsonArray The provided JSON array. > - @param[in] Index The Index position before removeme= nt. > + @param[in] Index The Index position before removal. > > @retval EFI_ABORTED Some error occur and operation abo= rted. > @retval EFI_SUCCESS The JSON array has been removed at= position > index. > @@ -722,7 +739,7 @@ JsonArrayRemoveValue ( > Dump JSON to a buffer. > > @param[in] JsonValue The provided JSON value. > - @param[in] Flags The Index position before removement. The= value > + @param[in] Flags The Index position before removal. The va= lue > could be the combination of below flags. > - EDKII_JSON_INDENT(n) > - EDKII_JSON_COMPACT > @@ -737,7 +754,7 @@ JsonArrayRemoveValue ( > > https://jansson.readthedocs.io/en/2.13/apiref.html#encoding > > @retval CHAR8 * Dump fail if NULL returned, otherwise the= buffer > - contain JSON paylaod in ASCII string. The= return > + contain JSON payload in ASCII string. The= return > value must be freed by the caller FreePoo= l(). > **/ > CHAR8 * > @@ -753,7 +770,7 @@ JsonDumpString ( > value. Only object and array represented strings can be converted > successfully, > since they are the only valid root values of a JSON text for UEFI usag= e. > > - Real number and number with exponent part are not supportted by UEFI. > + Real number and number with exponent part are not supported by UEFI. > > Caller needs to cleanup the root value by calling JsonValueFree(). > > @@ -775,7 +792,7 @@ JsonLoadString ( > /** > Load JSON from a buffer. > > - @param[in] Buffer Bufffer to the JSON payload > + @param[in] Buffer Buffier to the JSON payload > @param[in] BufferLen Length of the buffer > @param[in] Flags Flag of loading JSON buffer, the value > could be the combination of below flags. > @@ -807,7 +824,7 @@ JsonLoadBuffer ( > When the reference count drops to zero, there are no references left a= nd the > value can be destroyed. > > - This funciton decrement the reference count of EDKII_JSON_VALUE. As so= on > as > + This function decrement the reference count of EDKII_JSON_VALUE. As > soon as > a call to json_decref() drops the reference count to zero, the value i= s > destroyed and it can no longer be used. > > diff --git a/RedfishPkg/Library/JsonLib/JsonLib.c > b/RedfishPkg/Library/JsonLib/JsonLib.c > index 69f2455c00ed..9b758b940293 100644 > --- a/RedfishPkg/Library/JsonLib/JsonLib.c > +++ b/RedfishPkg/Library/JsonLib/JsonLib.c > @@ -28,7 +28,7 @@ > > More details for reference count strategy can refer to the API descrip= tion for > JsonValueFree(). > > - @retval The created JSON value which contains a JSON array or NUL= L if > intial a JSON array > + @retval The created JSON value which contains a JSON array or NUL= L if > initial a JSON array > is failed. > > **/ > @@ -50,7 +50,7 @@ JsonValueInitArray ( > > More details for reference count strategy can refer to the API descrip= tion for > JsonValueFree(). > > - @retval The created JSON value which contains a JSON object or NU= LL if > intial a JSON object > + @retval The created JSON value which contains a JSON object or NU= LL if > initial a JSON object > is failed. > > **/ > @@ -672,6 +672,29 @@ JsonObjectSize ( > return json_object_size ((json_t *)JsonObject); > } > > +/** > + The function removes all elements from object. Returns 0 on success an= d -1 > if object is not > + a JSON object. The reference count of all removed values are decrement= ed. > + > + @param[in] JsonObject The provided JSON object. > + > + @retval EFI_ABORTED Some error occur and operation abo= rted. > + @retval EFI_SUCCESS JSON value has been appended to th= e end of > the JSON array. > + > +**/ > +EFI_STATUS > +EFIAPI > +JsonObjectClear ( > + IN EDKII_JSON_OBJECT JsonObject > + ) > +{ > + if (json_object_clear ((json_t *)JsonObject) !=3D 0) { > + return EFI_ABORTED; > + } > + > + return EFI_SUCCESS; > +} > + > /** > The function is used to enumerate all keys in a JSON object. > > @@ -864,7 +887,7 @@ JsonArrayAppendValue ( > More details for reference count strategy can refer to the API descrip= tion for > JsonValueFree(). > > @param[in] JsonArray The provided JSON array. > - @param[in] Index The Index position before removeme= nt. > + @param[in] Index The Index position before removal. > > @retval EFI_ABORTED Some error occur and operation abo= rted. > @retval EFI_SUCCESS The JSON array has been removed at= position > index. > @@ -888,7 +911,7 @@ JsonArrayRemoveValue ( > Dump JSON to a buffer. > > @param[in] JsonValue The provided JSON value. > - @param[in] Flags The Index position before removement. The= value > + @param[in] Flags The Index position before removal. The va= lue > could be the combination of below flags. > - EDKII_JSON_INDENT(n) > - EDKII_JSON_COMPACT > @@ -903,7 +926,7 @@ JsonArrayRemoveValue ( > > https://jansson.readthedocs.io/en/2.13/apiref.html#encoding > > @retval CHAR8 * Dump fail if NULL returned, otherwise the= buffer > - contain JSON paylaod in ASCII string. The= return > + contain JSON payload in ASCII string. The= return > value must be freed by the caller using F= reePool(). > **/ > CHAR8 * > @@ -926,7 +949,7 @@ JsonDumpString ( > value. Only object and array represented strings can be converted > successfully, > since they are the only valid root values of a JSON text for UEFI usag= e. > > - Real number and number with exponent part are not supportted by UEFI. > + Real number and number with exponent part are not supported by UEFI. > > Caller needs to cleanup the root value by calling JsonValueFree(). > > @@ -951,7 +974,7 @@ JsonLoadString ( > /** > Load JSON from a buffer. > > - @param[in] Buffer Bufffer to the JSON payload > + @param[in] Buffer Buffier to the JSON payload > @param[in] BufferLen Length of the buffer > @param[in] Flags Flag of loading JSON buffer, the value > could be the combination of below flags. > @@ -986,7 +1009,7 @@ JsonLoadBuffer ( > When the reference count drops to zero, there are no references left a= nd the > value can be destroyed. > > - This funciton decrement the reference count of EDKII_JSON_VALUE. As so= on > as > + This function decrement the reference count of EDKII_JSON_VALUE. As > soon as > a call to json_decref() drops the reference count to zero, the value i= s > destroyed and it can no longer be used. > > -- > 2.17.1