public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [edk2-redfish-client][PATCH 1/3] RedfishClientPkg/jansson: Define json_object_del
@ 2024-01-12  3:26 Chang, Abner via groups.io
  2024-01-12  3:26 ` [edk2-devel] [edk2-redfish-client][PATCH 2/3] RedfishClientPkg/RedfishFeatureUtilityLib: Add two helper functions Chang, Abner via groups.io
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Chang, Abner via groups.io @ 2024-01-12  3:26 UTC (permalink / raw)
  To: devel; +Cc: Nickle Wang, Igor Kulchytskyy

From: Abner Chang <abner.chang@amd.com>

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
---
 RedfishClientPkg/PrivateInclude/jansson.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/RedfishClientPkg/PrivateInclude/jansson.h b/RedfishClientPkg/PrivateInclude/jansson.h
index 900c7e39c6..6b6391428f 100644
--- a/RedfishClientPkg/PrivateInclude/jansson.h
+++ b/RedfishClientPkg/PrivateInclude/jansson.h
@@ -44,6 +44,7 @@ typedef EDKII_JSON_TYPE   json_type;
 #define json_array_append_new(json_t_array, json_t)  JsonArrayAppendValue(json_t_array, json_t)
 #define json_object_set_new(json_t, key, value)      JsonObjectSetValue(json_t, key, value)
 #define json_decref(json_t)                          JsonDecreaseReference(json_t)
+#define json_object_del(json_t, key)                 JsonObjectDelete(json_t, key)
 #define json_integer_value(json_t)                   JsonValueGetInteger(json_t)
 #define json_is_object(json_t)                       JsonValueIsObject(json_t)
 #define json_is_array(json_t)                        JsonValueIsArray(json_t)
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113647): https://edk2.groups.io/g/devel/message/113647
Mute This Topic: https://groups.io/mt/103676918/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [edk2-devel] [edk2-redfish-client][PATCH 2/3] RedfishClientPkg/RedfishFeatureUtilityLib: Add two helper functions
  2024-01-12  3:26 [edk2-devel] [edk2-redfish-client][PATCH 1/3] RedfishClientPkg/jansson: Define json_object_del Chang, Abner via groups.io
@ 2024-01-12  3:26 ` Chang, Abner via groups.io
  2024-01-16  3:14   ` Nickle Wang via groups.io
  2024-01-12  3:26 ` [edk2-devel] [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib: Function to remove Redfish unchangeable properties Chang, Abner via groups.io
  2024-01-16  3:07 ` [edk2-devel] [edk2-redfish-client][PATCH 1/3] RedfishClientPkg/jansson: Define json_object_del Nickle Wang via groups.io
  2 siblings, 1 reply; 9+ messages in thread
From: Chang, Abner via groups.io @ 2024-01-12  3:26 UTC (permalink / raw)
  To: devel; +Cc: Nickle Wang, Igor Kulchytskyy

From: Abner Chang <abner.chang@amd.com>

- Add RedfishRemoveUnchangeableProperties () to remove
  unchangeable Redfish properties such as @OData.id.
- Add DestoryRedfishCharArray () to free Redfish string
  array.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
---
 .../RedfishFeatureUtilityLib.inf              |  1 +
 .../Library/RedfishFeatureUtilityLib.h        | 35 ++++++++
 .../RedfishFeatureUtilityLib.c                | 79 +++++++++++++++++++
 3 files changed, 115 insertions(+)

diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf
index 63330c8e9d..d8f3da3732 100644
--- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf
+++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.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
   );
 
+/**
+
+  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
+  );
+
 /**
 
   Create numeric array and append to array node in Redfish JSON convert format.
@@ -1024,4 +1041,22 @@ ValidateRedfishStringArrayValues (
   OUT BOOLEAN              *ValueChanged
   );
 
+/**
+  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 Redfish properties.
+
+**/
+EFI_STATUS
+RedfishRemoveUnchangeableProperties (
+  IN OUT  CHAR8  **JsonString
+  );
+
 #endif
diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
index aa723264e8..b16a811bb1 100644
--- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
+++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
@@ -3412,6 +3412,40 @@ AddRedfishCharArray (
   return EFI_SUCCESS;
 }
 
+/**
+
+  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 == NULL) || (ArraySize == 0)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  for (Index = 0; Index < ArraySize; Index++) {
+    NextPointer = Head->Next;
+    if (Head != NULL) {
+      FreePool (Head);
+    }
+    Head = NextPointer;
+  }
+  return EFI_SUCCESS;
+}
+
 /**
 
   Create numeric array and append to array node in Redfish JSON convert format.
@@ -3935,6 +3969,51 @@ ValidateRedfishStringArrayValues (
   return EFI_SUCCESS;
 }
 
+/**
+  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 Redfish properties.
+
+**/
+EFI_STATUS
+RedfishRemoveUnchangeableProperties (
+  IN OUT  CHAR8  **JsonString
+  )
+{
+  RedfishCS_status  Status;
+  CHAR8             *UpdatedJsonString;
+
+  if ((JsonString == NULL) || (*JsonString == NULL)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  UpdatedJsonString = AllocateZeroPool (AsciiStrSize (*JsonString));
+  if (UpdatedJsonString == NULL) {
+    DEBUG ((DEBUG_ERROR, "%a: Insufficient memory for UpdatedJsonString.\n", __func__));
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  Status = RemoveUnchangeableProperties (
+             (RedfishCS_char *)*JsonString,
+             (RedfishCS_char *)UpdatedJsonString,
+             (RedfishCS_uint32)AsciiStrSize (*JsonString)
+             );
+  if (Status != RedfishCS_status_success) {
+    return EFI_DEVICE_ERROR;
+  }
+
+  FreePool (*JsonString);
+  *JsonString = UpdatedJsonString;
+  return EFI_SUCCESS;
+}
+
 /**
 
   Install Boot Maintenance Manager Menu driver.
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113648): https://edk2.groups.io/g/devel/message/113648
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]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [edk2-devel] [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib: Function to remove Redfish unchangeable properties
  2024-01-12  3:26 [edk2-devel] [edk2-redfish-client][PATCH 1/3] RedfishClientPkg/jansson: Define json_object_del Chang, Abner via groups.io
  2024-01-12  3:26 ` [edk2-devel] [edk2-redfish-client][PATCH 2/3] RedfishClientPkg/RedfishFeatureUtilityLib: Add two helper functions Chang, Abner via groups.io
@ 2024-01-12  3:26 ` Chang, Abner via groups.io
  2024-01-16  3:17   ` Nickle Wang via groups.io
  2024-01-16  3:07 ` [edk2-devel] [edk2-redfish-client][PATCH 1/3] RedfishClientPkg/jansson: Define json_object_del Nickle Wang via groups.io
  2 siblings, 1 reply; 9+ messages in thread
From: Chang, Abner via groups.io @ 2024-01-12  3:26 UTC (permalink / raw)
  To: devel; +Cc: Nickle Wang, Igor Kulchytskyy

From: Abner Chang <abner.chang@amd.com>

Update RedfishCsCommon.c to add a function to remove Redfish
unchangeable properties.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
---
 .../ConverterLib/include/RedfishCsCommon.h    | 20 +++++++
 .../ConverterLib/src/RedfishCsCommon.c        | 55 +++++++++++++++++++
 2 files changed, 75 insertions(+)

diff --git a/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h b/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
index e454ab0b73..f5278015aa 100644
--- a/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
+++ b/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
@@ -104,6 +104,26 @@ DestoryCsMemory (
   RedfishCS_void  *rootCs
   );
 
+/**
+  This function removes the unchangeable Redfish properties from JSON raw text
+  The content in JsonString is left unmodified, the caller has to give enoungh
+  memory pointed by NewJsonBuffer in the size of BufferSize.
+
+  JsonString     Input JSON raw string
+  NewJsonBuffer  Pointer to memory for the updated JSON raw string in
+                 size of BuufferSize.
+  BuufferSize    The buffer size of NewJsonBuffer
+
+  Return RedfishCS_status.
+
+**/
+RedfishCS_status
+RemoveUnchangeableProperties (
+   RedfishCS_char   *JsonString,
+   RedfishCS_char   *NewJsonBuffer,
+   RedfishCS_uint32  BuufferSize
+   );
+
 typedef struct _RedfishCS_char_Array          RedfishCS_char_Array;
 typedef struct _RedfishCS_int64_Array         RedfishCS_int64_Array;
 typedef struct _RedfishCS_bool_Array          RedfishCS_bool_Array;
diff --git a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
index fd31e5296b..c6996d7d5d 100644
--- a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
+++ b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
@@ -1461,3 +1461,58 @@ CsEmptyPropLinkToJson (
 
   return RedfishCS_status_success;
 }
+
+/**
+  This function removes the unchangeable Redfish properties from JSON raw text
+  The content in JsonString is left unmodified, the caller has to give enoungh
+  memory pointed by NewJsonBuffer in the size of BufferSize.
+
+  JsonString     Input JSON raw string
+  NewJsonBuffer  Pointer to memory for the updated JSON raw string in
+                 size of BuufferSize.
+  BuufferSize    The buffer size of NewJsonBuffer
+
+  Return RedfishCS_status.
+
+**/
+RedfishCS_status
+RemoveUnchangeableProperties (
+   RedfishCS_char   *JsonString,
+   RedfishCS_char   *NewJsonBuffer,
+   RedfishCS_uint32  BuufferSize
+   )
+{
+  json_t            *JsonObj;
+  RedfishCS_char    *TempChar;
+  RedfishCS_status  Status;
+
+  if ((JsonString == NULL) || (NewJsonBuffer == NULL)) {
+    return RedfishCS_status_invalid_parameter;
+  }
+
+  JsonObj = json_loads (JsonString, 0, NULL);
+  if (JsonObj == NULL) {
+    return RedfishCS_status_unknown_error;
+  }
+
+  json_object_del (JsonObj, "@odata.type");
+  json_object_del (JsonObj, "@odata.id");
+  json_object_del (JsonObj, "Id");
+  json_object_del (JsonObj, "Name");
+
+  TempChar = json_dumps ((json_t *)JsonObj, JSON_INDENT (2));
+  if (TempChar != NULL) {
+    if ((strlen (TempChar) + 1) > BuufferSize) {
+      Status = RedfishCS_status_insufficient_memory;
+    } else {
+      memcpy (NewJsonBuffer, TempChar, strlen (TempChar) + 1);
+      free (TempChar);
+      Status = RedfishCS_status_success;
+    }
+  } else {
+    Status = RedfishCS_status_unknown_error;
+  }
+  json_decref(JsonObj);
+  return Status;
+}
+
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113649): https://edk2.groups.io/g/devel/message/113649
Mute This Topic: https://groups.io/mt/103676920/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [edk2-redfish-client][PATCH 1/3] RedfishClientPkg/jansson: Define json_object_del
  2024-01-12  3:26 [edk2-devel] [edk2-redfish-client][PATCH 1/3] RedfishClientPkg/jansson: Define json_object_del Chang, Abner via groups.io
  2024-01-12  3:26 ` [edk2-devel] [edk2-redfish-client][PATCH 2/3] RedfishClientPkg/RedfishFeatureUtilityLib: Add two helper functions Chang, Abner via groups.io
  2024-01-12  3:26 ` [edk2-devel] [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib: Function to remove Redfish unchangeable properties Chang, Abner via groups.io
@ 2024-01-16  3:07 ` Nickle Wang via groups.io
  2 siblings, 0 replies; 9+ messages in thread
From: Nickle Wang via groups.io @ 2024-01-16  3:07 UTC (permalink / raw)
  To: abner.chang@amd.com, devel@edk2.groups.io; +Cc: Igor Kulchytskyy



Reviewed-by: Nickle Wang <nicklew@nvidia.com>

Regards,
Nickle

> -----Original Message-----
> From: abner.chang@amd.com <abner.chang@amd.com>
> Sent: Friday, January 12, 2024 11:26 AM
> To: devel@edk2.groups.io
> Cc: Nickle Wang <nicklew@nvidia.com>; Igor Kulchytskyy <igork@ami.com>
> Subject: [edk2-redfish-client][PATCH 1/3] RedfishClientPkg/jansson: Define
> json_object_del
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Abner Chang <abner.chang@amd.com>
> 
> Signed-off-by: Abner Chang <abner.chang@amd.com>
> Cc: Nickle Wang <nicklew@nvidia.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> ---
>  RedfishClientPkg/PrivateInclude/jansson.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/RedfishClientPkg/PrivateInclude/jansson.h
> b/RedfishClientPkg/PrivateInclude/jansson.h
> index 900c7e39c6..6b6391428f 100644
> --- a/RedfishClientPkg/PrivateInclude/jansson.h
> +++ b/RedfishClientPkg/PrivateInclude/jansson.h
> @@ -44,6 +44,7 @@ typedef EDKII_JSON_TYPE   json_type;
>  #define json_array_append_new(json_t_array, json_t)
> JsonArrayAppendValue(json_t_array, json_t)
>  #define json_object_set_new(json_t, key, value)      JsonObjectSetValue(json_t,
> key, value)
>  #define json_decref(json_t)                          JsonDecreaseReference(json_t)
> +#define json_object_del(json_t, key)                 JsonObjectDelete(json_t, key)
>  #define json_integer_value(json_t)                   JsonValueGetInteger(json_t)
>  #define json_is_object(json_t)                       JsonValueIsObject(json_t)
>  #define json_is_array(json_t)                        JsonValueIsArray(json_t)
> --
> 2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113861): https://edk2.groups.io/g/devel/message/113861
Mute This Topic: https://groups.io/mt/103676918/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [edk2-redfish-client][PATCH 2/3] RedfishClientPkg/RedfishFeatureUtilityLib: Add two helper functions
  2024-01-12  3:26 ` [edk2-devel] [edk2-redfish-client][PATCH 2/3] RedfishClientPkg/RedfishFeatureUtilityLib: Add two helper functions Chang, Abner via groups.io
@ 2024-01-16  3:14   ` Nickle Wang via groups.io
  0 siblings, 0 replies; 9+ messages in thread
From: Nickle Wang via groups.io @ 2024-01-16  3:14 UTC (permalink / raw)
  To: abner.chang@amd.com, devel@edk2.groups.io; +Cc: Igor Kulchytskyy

Please see my comments below.

Regards,
Nickle

> -----Original Message-----
> From: abner.chang@amd.com <abner.chang@amd.com>
> Sent: Friday, January 12, 2024 11:26 AM
> To: devel@edk2.groups.io
> Cc: Nickle Wang <nicklew@nvidia.com>; Igor Kulchytskyy <igork@ami.com>
> Subject: [edk2-redfish-client][PATCH 2/3]
> RedfishClientPkg/RedfishFeatureUtilityLib: Add two helper functions
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Abner Chang <abner.chang@amd.com>
> 
> - Add RedfishRemoveUnchangeableProperties () to remove
>   unchangeable Redfish properties such as @OData.id.
> - Add DestoryRedfishCharArray () to free Redfish string
>   array.
> 
> Signed-off-by: Abner Chang <abner.chang@amd.com>
> Cc: Nickle Wang <nicklew@nvidia.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> ---
>  .../RedfishFeatureUtilityLib.inf              |  1 +
>  .../Library/RedfishFeatureUtilityLib.h        | 35 ++++++++
>  .../RedfishFeatureUtilityLib.c                | 79 +++++++++++++++++++
>  3 files changed, 115 insertions(+)
> 
> diff --git
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf
> b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf
> index 63330c8e9d..d8f3da3732 100644
> ---
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.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
>    );
> 
> +/**
> +
> +  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
> +  );
> +
>  /**
> 
>    Create numeric array and append to array node in Redfish JSON convert format.
> @@ -1024,4 +1041,22 @@ ValidateRedfishStringArrayValues (
>    OUT BOOLEAN              *ValueChanged
>    );
> 
> +/**
> +  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 Redfish
> 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 decide when to release input string and this function does not do this for caller.

For example:

RedfishRemoveReadOnlyProperties (
IN CHAR8      *JsonString,
OUT CHAR8 **ModifedString
);

> +
>  #endif
> diff --git
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
> b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
> index aa723264e8..b16a811bb1 100644
> ---
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
> +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUt
> +++ ilityLib.c
> @@ -3412,6 +3412,40 @@ AddRedfishCharArray (
>    return EFI_SUCCESS;
>  }
> 
> +/**
> +
> +  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 == NULL) || (ArraySize == 0)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  for (Index = 0; Index < ArraySize; Index++) {
> +    NextPointer = Head->Next;
> +    if (Head != NULL) {
> +      FreePool (Head);


I suggest setting Head to NULL after FreePool call. So, no one can use this memory by accident.


> +    }
> +    Head = NextPointer;
> +  }
> +  return EFI_SUCCESS;
> +}
> +
>  /**
> 
>    Create numeric array and append to array node in Redfish JSON convert format.
> @@ -3935,6 +3969,51 @@ ValidateRedfishStringArrayValues (
>    return EFI_SUCCESS;
>  }
> 
> +/**
> +  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 Redfish
> properties.
> +
> +**/
> +EFI_STATUS
> +RedfishRemoveUnchangeableProperties (
> +  IN OUT  CHAR8  **JsonString
> +  )
> +{
> +  RedfishCS_status  Status;
> +  CHAR8             *UpdatedJsonString;
> +
> +  if ((JsonString == NULL) || (*JsonString == NULL)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  UpdatedJsonString = AllocateZeroPool (AsciiStrSize (*JsonString));
> + if (UpdatedJsonString == NULL) {
> +    DEBUG ((DEBUG_ERROR, "%a: Insufficient memory for
> UpdatedJsonString.\n", __func__));
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +
> +  Status = RemoveUnchangeableProperties (
> +             (RedfishCS_char *)*JsonString,
> +             (RedfishCS_char *)UpdatedJsonString,
> +             (RedfishCS_uint32)AsciiStrSize (*JsonString)
> +             );
> +  if (Status != RedfishCS_status_success) {
> +    return EFI_DEVICE_ERROR;
> +  }
> +
> +  FreePool (*JsonString);
> +  *JsonString = UpdatedJsonString;
> +  return EFI_SUCCESS;
> +}
> +
>  /**
> 
>    Install Boot Maintenance Manager Menu driver.
> --
> 2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
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]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib: Function to remove Redfish unchangeable properties
  2024-01-12  3:26 ` [edk2-devel] [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib: Function to remove Redfish unchangeable properties Chang, Abner via groups.io
@ 2024-01-16  3:17   ` Nickle Wang via groups.io
  2024-01-16  4:08     ` Chang, Abner via groups.io
  0 siblings, 1 reply; 9+ messages in thread
From: Nickle Wang via groups.io @ 2024-01-16  3:17 UTC (permalink / raw)
  To: abner.chang@amd.com, devel@edk2.groups.io; +Cc: Igor Kulchytskyy

I found typos. Please see below.

Regards,
Nickle

> -----Original Message-----
> From: abner.chang@amd.com <abner.chang@amd.com>
> Sent: Friday, January 12, 2024 11:26 AM
> To: devel@edk2.groups.io
> Cc: Nickle Wang <nicklew@nvidia.com>; Igor Kulchytskyy <igork@ami.com>
> Subject: [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib:
> Function to remove Redfish unchangeable properties
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Abner Chang <abner.chang@amd.com>
> 
> Update RedfishCsCommon.c to add a function to remove Redfish unchangeable
> properties.
> 
> Signed-off-by: Abner Chang <abner.chang@amd.com>
> Cc: Nickle Wang <nicklew@nvidia.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> ---
>  .../ConverterLib/include/RedfishCsCommon.h    | 20 +++++++
>  .../ConverterLib/src/RedfishCsCommon.c        | 55 +++++++++++++++++++
>  2 files changed, 75 insertions(+)
> 
> diff --git a/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> b/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> index e454ab0b73..f5278015aa 100644
> --- a/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> +++ b/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> @@ -104,6 +104,26 @@ DestoryCsMemory (
>    RedfishCS_void  *rootCs
>    );
> 
> +/**
> +  This function removes the unchangeable Redfish properties from JSON
> +raw text
> +  The content in JsonString is left unmodified, the caller has to give
> +enoungh
> +  memory pointed by NewJsonBuffer in the size of BufferSize.
> +
> +  JsonString     Input JSON raw string
> +  NewJsonBuffer  Pointer to memory for the updated JSON raw string in
> +                 size of BuufferSize.
> +  BuufferSize    The buffer size of NewJsonBuffer
> +
> +  Return RedfishCS_status.
> +
> +**/
> +RedfishCS_status
> +RemoveUnchangeableProperties (
> +   RedfishCS_char   *JsonString,
> +   RedfishCS_char   *NewJsonBuffer,
> +   RedfishCS_uint32  BuufferSize
> +   );

BufferSize. You have double 'u' above.  And how about to use ReadOnly instead of "Unchangeable"?


> +
>  typedef struct _RedfishCS_char_Array          RedfishCS_char_Array;
>  typedef struct _RedfishCS_int64_Array         RedfishCS_int64_Array;
>  typedef struct _RedfishCS_bool_Array          RedfishCS_bool_Array;
> diff --git a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> index fd31e5296b..c6996d7d5d 100644
> --- a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> +++ b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> @@ -1461,3 +1461,58 @@ CsEmptyPropLinkToJson (
> 
>    return RedfishCS_status_success;
>  }
> +
> +/**
> +  This function removes the unchangeable Redfish properties from JSON
> +raw text
> +  The content in JsonString is left unmodified, the caller has to give
> +enoungh
> +  memory pointed by NewJsonBuffer in the size of BufferSize.
> +
> +  JsonString     Input JSON raw string
> +  NewJsonBuffer  Pointer to memory for the updated JSON raw string in
> +                 size of BuufferSize.
> +  BuufferSize    The buffer size of NewJsonBuffer
> +
> +  Return RedfishCS_status.
> +
> +**/
> +RedfishCS_status
> +RemoveUnchangeableProperties (
> +   RedfishCS_char   *JsonString,
> +   RedfishCS_char   *NewJsonBuffer,
> +   RedfishCS_uint32  BuufferSize
> +   )


BufferSize. You have double 'u' above.


> +{
> +  json_t            *JsonObj;
> +  RedfishCS_char    *TempChar;
> +  RedfishCS_status  Status;
> +
> +  if ((JsonString == NULL) || (NewJsonBuffer == NULL)) {
> +    return RedfishCS_status_invalid_parameter;
> +  }
> +
> +  JsonObj = json_loads (JsonString, 0, NULL);  if (JsonObj == NULL) {
> +    return RedfishCS_status_unknown_error;  }
> +
> +  json_object_del (JsonObj, "@odata.type");  json_object_del (JsonObj,
> + "@odata.id");  json_object_del (JsonObj, "Id");  json_object_del
> + (JsonObj, "Name");
> +
> +  TempChar = json_dumps ((json_t *)JsonObj, JSON_INDENT (2));
> +  if (TempChar != NULL) {
> +    if ((strlen (TempChar) + 1) > BuufferSize) {
> +      Status = RedfishCS_status_insufficient_memory;
> +    } else {
> +      memcpy (NewJsonBuffer, TempChar, strlen (TempChar) + 1);
> +      free (TempChar);
> +      Status = RedfishCS_status_success;
> +    }
> +  } else {
> +    Status = RedfishCS_status_unknown_error;
> +  }
> +  json_decref(JsonObj);
> +  return Status;
> +}
> +
> --
> 2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113863): https://edk2.groups.io/g/devel/message/113863
Mute This Topic: https://groups.io/mt/103676920/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib: Function to remove Redfish unchangeable properties
  2024-01-16  3:17   ` Nickle Wang via groups.io
@ 2024-01-16  4:08     ` Chang, Abner via groups.io
  2024-01-16  6:20       ` Nickle Wang via groups.io
  0 siblings, 1 reply; 9+ messages in thread
From: Chang, Abner via groups.io @ 2024-01-16  4:08 UTC (permalink / raw)
  To: Nickle Wang, devel@edk2.groups.io; +Cc: Igor Kulchytskyy

[AMD Official Use Only - General]

> -----Original Message-----
> From: Nickle Wang <nicklew@nvidia.com>
> Sent: Tuesday, January 16, 2024 11:18 AM
> To: Chang, Abner <Abner.Chang@amd.com>; devel@edk2.groups.io
> Cc: Igor Kulchytskyy <igork@ami.com>
> Subject: RE: [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib:
> Function to remove Redfish unchangeable properties
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> I found typos. Please see below.
>
> Regards,
> Nickle
>
> > -----Original Message-----
> > From: abner.chang@amd.com <abner.chang@amd.com>
> > Sent: Friday, January 12, 2024 11:26 AM
> > To: devel@edk2.groups.io
> > Cc: Nickle Wang <nicklew@nvidia.com>; Igor Kulchytskyy <igork@ami.com>
> > Subject: [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib:
> > Function to remove Redfish unchangeable properties
> >
> > External email: Use caution opening links or attachments
> >
> >
> > From: Abner Chang <abner.chang@amd.com>
> >
> > Update RedfishCsCommon.c to add a function to remove Redfish
> unchangeable
> > properties.
> >
> > Signed-off-by: Abner Chang <abner.chang@amd.com>
> > Cc: Nickle Wang <nicklew@nvidia.com>
> > Cc: Igor Kulchytskyy <igork@ami.com>
> > ---
> >  .../ConverterLib/include/RedfishCsCommon.h    | 20 +++++++
> >  .../ConverterLib/src/RedfishCsCommon.c        | 55 +++++++++++++++++++
> >  2 files changed, 75 insertions(+)
> >
> > diff --git a/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> > b/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> > index e454ab0b73..f5278015aa 100644
> > --- a/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> > +++ b/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> > @@ -104,6 +104,26 @@ DestoryCsMemory (
> >    RedfishCS_void  *rootCs
> >    );
> >
> > +/**
> > +  This function removes the unchangeable Redfish properties from JSON
> > +raw text
> > +  The content in JsonString is left unmodified, the caller has to give
> > +enoungh
> > +  memory pointed by NewJsonBuffer in the size of BufferSize.
> > +
> > +  JsonString     Input JSON raw string
> > +  NewJsonBuffer  Pointer to memory for the updated JSON raw string in
> > +                 size of BuufferSize.
> > +  BuufferSize    The buffer size of NewJsonBuffer
> > +
> > +  Return RedfishCS_status.
> > +
> > +**/
> > +RedfishCS_status
> > +RemoveUnchangeableProperties (
> > +   RedfishCS_char   *JsonString,
> > +   RedfishCS_char   *NewJsonBuffer,
> > +   RedfishCS_uint32  BuufferSize
> > +   );
>
> BufferSize. You have double 'u' above.  And how about to use ReadOnly
> instead of "Unchangeable"?
Thanks for catching the typo.

I didn't choose ReadOnly is because at BIOS perspective as a provider, we still update the read only property defined in schema such as BootOptions. Thus I thought to use ReadOnly is not quite accurate. How do you think?

Abner

>
>
> > +
> >  typedef struct _RedfishCS_char_Array          RedfishCS_char_Array;
> >  typedef struct _RedfishCS_int64_Array         RedfishCS_int64_Array;
> >  typedef struct _RedfishCS_bool_Array          RedfishCS_bool_Array;
> > diff --git a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> > b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> > index fd31e5296b..c6996d7d5d 100644
> > --- a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> > +++ b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> > @@ -1461,3 +1461,58 @@ CsEmptyPropLinkToJson (
> >
> >    return RedfishCS_status_success;
> >  }
> > +
> > +/**
> > +  This function removes the unchangeable Redfish properties from JSON
> > +raw text
> > +  The content in JsonString is left unmodified, the caller has to give
> > +enoungh
> > +  memory pointed by NewJsonBuffer in the size of BufferSize.
> > +
> > +  JsonString     Input JSON raw string
> > +  NewJsonBuffer  Pointer to memory for the updated JSON raw string in
> > +                 size of BuufferSize.
> > +  BuufferSize    The buffer size of NewJsonBuffer
> > +
> > +  Return RedfishCS_status.
> > +
> > +**/
> > +RedfishCS_status
> > +RemoveUnchangeableProperties (
> > +   RedfishCS_char   *JsonString,
> > +   RedfishCS_char   *NewJsonBuffer,
> > +   RedfishCS_uint32  BuufferSize
> > +   )
>
>
> BufferSize. You have double 'u' above.
>
>
> > +{
> > +  json_t            *JsonObj;
> > +  RedfishCS_char    *TempChar;
> > +  RedfishCS_status  Status;
> > +
> > +  if ((JsonString == NULL) || (NewJsonBuffer == NULL)) {
> > +    return RedfishCS_status_invalid_parameter;
> > +  }
> > +
> > +  JsonObj = json_loads (JsonString, 0, NULL);  if (JsonObj == NULL) {
> > +    return RedfishCS_status_unknown_error;  }
> > +
> > +  json_object_del (JsonObj, "@odata.type");  json_object_del (JsonObj,
> > + "@odata.id");  json_object_del (JsonObj, "Id");  json_object_del
> > + (JsonObj, "Name");
> > +
> > +  TempChar = json_dumps ((json_t *)JsonObj, JSON_INDENT (2));
> > +  if (TempChar != NULL) {
> > +    if ((strlen (TempChar) + 1) > BuufferSize) {
> > +      Status = RedfishCS_status_insufficient_memory;
> > +    } else {
> > +      memcpy (NewJsonBuffer, TempChar, strlen (TempChar) + 1);
> > +      free (TempChar);
> > +      Status = RedfishCS_status_success;
> > +    }
> > +  } else {
> > +    Status = RedfishCS_status_unknown_error;
> > +  }
> > +  json_decref(JsonObj);
> > +  return Status;
> > +}
> > +
> > --
> > 2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113864): https://edk2.groups.io/g/devel/message/113864
Mute This Topic: https://groups.io/mt/103676920/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib: Function to remove Redfish unchangeable properties
  2024-01-16  4:08     ` Chang, Abner via groups.io
@ 2024-01-16  6:20       ` Nickle Wang via groups.io
  2024-01-16  8:31         ` Chang, Abner via groups.io
  0 siblings, 1 reply; 9+ messages in thread
From: Nickle Wang via groups.io @ 2024-01-16  6:20 UTC (permalink / raw)
  To: Chang, Abner, devel@edk2.groups.io; +Cc: Igor Kulchytskyy

> I didn't choose ReadOnly is because at BIOS perspective as a provider, we still
> update the read only property defined in schema such as BootOptions. Thus I
> thought to use ReadOnly is not quite accurate. How do you think?

I see. Thanks for your explanation. Please fix the typos and keep the function name untouched.

Regards,
Nickle

> -----Original Message-----
> From: Chang, Abner <Abner.Chang@amd.com>
> Sent: Tuesday, January 16, 2024 12:08 PM
> To: Nickle Wang <nicklew@nvidia.com>; devel@edk2.groups.io
> Cc: Igor Kulchytskyy <igork@ami.com>
> Subject: RE: [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib:
> Function to remove Redfish unchangeable properties
> 
> External email: Use caution opening links or attachments
> 
> 
> [AMD Official Use Only - General]
> 
> > -----Original Message-----
> > From: Nickle Wang <nicklew@nvidia.com>
> > Sent: Tuesday, January 16, 2024 11:18 AM
> > To: Chang, Abner <Abner.Chang@amd.com>; devel@edk2.groups.io
> > Cc: Igor Kulchytskyy <igork@ami.com>
> > Subject: RE: [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib:
> > Function to remove Redfish unchangeable properties
> >
> > Caution: This message originated from an External Source. Use proper
> > caution when opening attachments, clicking links, or responding.
> >
> >
> > I found typos. Please see below.
> >
> > Regards,
> > Nickle
> >
> > > -----Original Message-----
> > > From: abner.chang@amd.com <abner.chang@amd.com>
> > > Sent: Friday, January 12, 2024 11:26 AM
> > > To: devel@edk2.groups.io
> > > Cc: Nickle Wang <nicklew@nvidia.com>; Igor Kulchytskyy
> > > <igork@ami.com>
> > > Subject: [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib:
> > > Function to remove Redfish unchangeable properties
> > >
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > From: Abner Chang <abner.chang@amd.com>
> > >
> > > Update RedfishCsCommon.c to add a function to remove Redfish
> > unchangeable
> > > properties.
> > >
> > > Signed-off-by: Abner Chang <abner.chang@amd.com>
> > > Cc: Nickle Wang <nicklew@nvidia.com>
> > > Cc: Igor Kulchytskyy <igork@ami.com>
> > > ---
> > >  .../ConverterLib/include/RedfishCsCommon.h    | 20 +++++++
> > >  .../ConverterLib/src/RedfishCsCommon.c        | 55 +++++++++++++++++++
> > >  2 files changed, 75 insertions(+)
> > >
> > > diff --git a/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> > > b/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> > > index e454ab0b73..f5278015aa 100644
> > > --- a/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> > > +++ b/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> > > @@ -104,6 +104,26 @@ DestoryCsMemory (
> > >    RedfishCS_void  *rootCs
> > >    );
> > >
> > > +/**
> > > +  This function removes the unchangeable Redfish properties from
> > > +JSON raw text
> > > +  The content in JsonString is left unmodified, the caller has to
> > > +give enoungh
> > > +  memory pointed by NewJsonBuffer in the size of BufferSize.
> > > +
> > > +  JsonString     Input JSON raw string
> > > +  NewJsonBuffer  Pointer to memory for the updated JSON raw string in
> > > +                 size of BuufferSize.
> > > +  BuufferSize    The buffer size of NewJsonBuffer
> > > +
> > > +  Return RedfishCS_status.
> > > +
> > > +**/
> > > +RedfishCS_status
> > > +RemoveUnchangeableProperties (
> > > +   RedfishCS_char   *JsonString,
> > > +   RedfishCS_char   *NewJsonBuffer,
> > > +   RedfishCS_uint32  BuufferSize
> > > +   );
> >
> > BufferSize. You have double 'u' above.  And how about to use ReadOnly
> > instead of "Unchangeable"?
> Thanks for catching the typo.
> 
> I didn't choose ReadOnly is because at BIOS perspective as a provider, we still
> update the read only property defined in schema such as BootOptions. Thus I
> thought to use ReadOnly is not quite accurate. How do you think?
> 
> Abner
> 
> >
> >
> > > +
> > >  typedef struct _RedfishCS_char_Array          RedfishCS_char_Array;
> > >  typedef struct _RedfishCS_int64_Array         RedfishCS_int64_Array;
> > >  typedef struct _RedfishCS_bool_Array          RedfishCS_bool_Array;
> > > diff --git a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> > > b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> > > index fd31e5296b..c6996d7d5d 100644
> > > --- a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> > > +++ b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> > > @@ -1461,3 +1461,58 @@ CsEmptyPropLinkToJson (
> > >
> > >    return RedfishCS_status_success;
> > >  }
> > > +
> > > +/**
> > > +  This function removes the unchangeable Redfish properties from
> > > +JSON raw text
> > > +  The content in JsonString is left unmodified, the caller has to
> > > +give enoungh
> > > +  memory pointed by NewJsonBuffer in the size of BufferSize.
> > > +
> > > +  JsonString     Input JSON raw string
> > > +  NewJsonBuffer  Pointer to memory for the updated JSON raw string in
> > > +                 size of BuufferSize.
> > > +  BuufferSize    The buffer size of NewJsonBuffer
> > > +
> > > +  Return RedfishCS_status.
> > > +
> > > +**/
> > > +RedfishCS_status
> > > +RemoveUnchangeableProperties (
> > > +   RedfishCS_char   *JsonString,
> > > +   RedfishCS_char   *NewJsonBuffer,
> > > +   RedfishCS_uint32  BuufferSize
> > > +   )
> >
> >
> > BufferSize. You have double 'u' above.
> >
> >
> > > +{
> > > +  json_t            *JsonObj;
> > > +  RedfishCS_char    *TempChar;
> > > +  RedfishCS_status  Status;
> > > +
> > > +  if ((JsonString == NULL) || (NewJsonBuffer == NULL)) {
> > > +    return RedfishCS_status_invalid_parameter;
> > > +  }
> > > +
> > > +  JsonObj = json_loads (JsonString, 0, NULL);  if (JsonObj == NULL) {
> > > +    return RedfishCS_status_unknown_error;  }
> > > +
> > > +  json_object_del (JsonObj, "@odata.type");  json_object_del
> > > + (JsonObj, "@odata.id");  json_object_del (JsonObj, "Id");
> > > + json_object_del (JsonObj, "Name");
> > > +
> > > +  TempChar = json_dumps ((json_t *)JsonObj, JSON_INDENT (2));
> > > +  if (TempChar != NULL) {
> > > +    if ((strlen (TempChar) + 1) > BuufferSize) {
> > > +      Status = RedfishCS_status_insufficient_memory;
> > > +    } else {
> > > +      memcpy (NewJsonBuffer, TempChar, strlen (TempChar) + 1);
> > > +      free (TempChar);
> > > +      Status = RedfishCS_status_success;
> > > +    }
> > > +  } else {
> > > +    Status = RedfishCS_status_unknown_error;
> > > +  }
> > > +  json_decref(JsonObj);
> > > +  return Status;
> > > +}
> > > +
> > > --
> > > 2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113865): https://edk2.groups.io/g/devel/message/113865
Mute This Topic: https://groups.io/mt/103676920/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib: Function to remove Redfish unchangeable properties
  2024-01-16  6:20       ` Nickle Wang via groups.io
@ 2024-01-16  8:31         ` Chang, Abner via groups.io
  0 siblings, 0 replies; 9+ messages in thread
From: Chang, Abner via groups.io @ 2024-01-16  8:31 UTC (permalink / raw)
  To: Nickle Wang, devel@edk2.groups.io; +Cc: Igor Kulchytskyy

[AMD Official Use Only - General]

Got it and thanks.
I will fix the typo, put your RB then merge this patch.

Abner

> -----Original Message-----
> From: Nickle Wang <nicklew@nvidia.com>
> Sent: Tuesday, January 16, 2024 2:20 PM
> To: Chang, Abner <Abner.Chang@amd.com>; devel@edk2.groups.io
> Cc: Igor Kulchytskyy <igork@ami.com>
> Subject: RE: [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib:
> Function to remove Redfish unchangeable properties
>
> [AMD Official Use Only - General]
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> > I didn't choose ReadOnly is because at BIOS perspective as a provider, we still
> > update the read only property defined in schema such as BootOptions. Thus
> I
> > thought to use ReadOnly is not quite accurate. How do you think?
>
> I see. Thanks for your explanation. Please fix the typos and keep the function
> name untouched.
>
> Regards,
> Nickle
>
> > -----Original Message-----
> > From: Chang, Abner <Abner.Chang@amd.com>
> > Sent: Tuesday, January 16, 2024 12:08 PM
> > To: Nickle Wang <nicklew@nvidia.com>; devel@edk2.groups.io
> > Cc: Igor Kulchytskyy <igork@ami.com>
> > Subject: RE: [edk2-redfish-client][PATCH 3/3]
> RedfishClientPkg/ConverterLib:
> > Function to remove Redfish unchangeable properties
> >
> > External email: Use caution opening links or attachments
> >
> >
> > [AMD Official Use Only - General]
> >
> > > -----Original Message-----
> > > From: Nickle Wang <nicklew@nvidia.com>
> > > Sent: Tuesday, January 16, 2024 11:18 AM
> > > To: Chang, Abner <Abner.Chang@amd.com>; devel@edk2.groups.io
> > > Cc: Igor Kulchytskyy <igork@ami.com>
> > > Subject: RE: [edk2-redfish-client][PATCH 3/3]
> RedfishClientPkg/ConverterLib:
> > > Function to remove Redfish unchangeable properties
> > >
> > > Caution: This message originated from an External Source. Use proper
> > > caution when opening attachments, clicking links, or responding.
> > >
> > >
> > > I found typos. Please see below.
> > >
> > > Regards,
> > > Nickle
> > >
> > > > -----Original Message-----
> > > > From: abner.chang@amd.com <abner.chang@amd.com>
> > > > Sent: Friday, January 12, 2024 11:26 AM
> > > > To: devel@edk2.groups.io
> > > > Cc: Nickle Wang <nicklew@nvidia.com>; Igor Kulchytskyy
> > > > <igork@ami.com>
> > > > Subject: [edk2-redfish-client][PATCH 3/3]
> RedfishClientPkg/ConverterLib:
> > > > Function to remove Redfish unchangeable properties
> > > >
> > > > External email: Use caution opening links or attachments
> > > >
> > > >
> > > > From: Abner Chang <abner.chang@amd.com>
> > > >
> > > > Update RedfishCsCommon.c to add a function to remove Redfish
> > > unchangeable
> > > > properties.
> > > >
> > > > Signed-off-by: Abner Chang <abner.chang@amd.com>
> > > > Cc: Nickle Wang <nicklew@nvidia.com>
> > > > Cc: Igor Kulchytskyy <igork@ami.com>
> > > > ---
> > > >  .../ConverterLib/include/RedfishCsCommon.h    | 20 +++++++
> > > >  .../ConverterLib/src/RedfishCsCommon.c        | 55
> +++++++++++++++++++
> > > >  2 files changed, 75 insertions(+)
> > > >
> > > > diff --git a/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> > > > b/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> > > > index e454ab0b73..f5278015aa 100644
> > > > --- a/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> > > > +++ b/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
> > > > @@ -104,6 +104,26 @@ DestoryCsMemory (
> > > >    RedfishCS_void  *rootCs
> > > >    );
> > > >
> > > > +/**
> > > > +  This function removes the unchangeable Redfish properties from
> > > > +JSON raw text
> > > > +  The content in JsonString is left unmodified, the caller has to
> > > > +give enoungh
> > > > +  memory pointed by NewJsonBuffer in the size of BufferSize.
> > > > +
> > > > +  JsonString     Input JSON raw string
> > > > +  NewJsonBuffer  Pointer to memory for the updated JSON raw string in
> > > > +                 size of BuufferSize.
> > > > +  BuufferSize    The buffer size of NewJsonBuffer
> > > > +
> > > > +  Return RedfishCS_status.
> > > > +
> > > > +**/
> > > > +RedfishCS_status
> > > > +RemoveUnchangeableProperties (
> > > > +   RedfishCS_char   *JsonString,
> > > > +   RedfishCS_char   *NewJsonBuffer,
> > > > +   RedfishCS_uint32  BuufferSize
> > > > +   );
> > >
> > > BufferSize. You have double 'u' above.  And how about to use ReadOnly
> > > instead of "Unchangeable"?
> > Thanks for catching the typo.
> >
> > I didn't choose ReadOnly is because at BIOS perspective as a provider, we still
> > update the read only property defined in schema such as BootOptions. Thus
> I
> > thought to use ReadOnly is not quite accurate. How do you think?
> >
> > Abner
> >
> > >
> > >
> > > > +
> > > >  typedef struct _RedfishCS_char_Array          RedfishCS_char_Array;
> > > >  typedef struct _RedfishCS_int64_Array         RedfishCS_int64_Array;
> > > >  typedef struct _RedfishCS_bool_Array          RedfishCS_bool_Array;
> > > > diff --git a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> > > > b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> > > > index fd31e5296b..c6996d7d5d 100644
> > > > --- a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> > > > +++ b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
> > > > @@ -1461,3 +1461,58 @@ CsEmptyPropLinkToJson (
> > > >
> > > >    return RedfishCS_status_success;
> > > >  }
> > > > +
> > > > +/**
> > > > +  This function removes the unchangeable Redfish properties from
> > > > +JSON raw text
> > > > +  The content in JsonString is left unmodified, the caller has to
> > > > +give enoungh
> > > > +  memory pointed by NewJsonBuffer in the size of BufferSize.
> > > > +
> > > > +  JsonString     Input JSON raw string
> > > > +  NewJsonBuffer  Pointer to memory for the updated JSON raw string in
> > > > +                 size of BuufferSize.
> > > > +  BuufferSize    The buffer size of NewJsonBuffer
> > > > +
> > > > +  Return RedfishCS_status.
> > > > +
> > > > +**/
> > > > +RedfishCS_status
> > > > +RemoveUnchangeableProperties (
> > > > +   RedfishCS_char   *JsonString,
> > > > +   RedfishCS_char   *NewJsonBuffer,
> > > > +   RedfishCS_uint32  BuufferSize
> > > > +   )
> > >
> > >
> > > BufferSize. You have double 'u' above.
> > >
> > >
> > > > +{
> > > > +  json_t            *JsonObj;
> > > > +  RedfishCS_char    *TempChar;
> > > > +  RedfishCS_status  Status;
> > > > +
> > > > +  if ((JsonString == NULL) || (NewJsonBuffer == NULL)) {
> > > > +    return RedfishCS_status_invalid_parameter;
> > > > +  }
> > > > +
> > > > +  JsonObj = json_loads (JsonString, 0, NULL);  if (JsonObj == NULL) {
> > > > +    return RedfishCS_status_unknown_error;  }
> > > > +
> > > > +  json_object_del (JsonObj, "@odata.type");  json_object_del
> > > > + (JsonObj, "@odata.id");  json_object_del (JsonObj, "Id");
> > > > + json_object_del (JsonObj, "Name");
> > > > +
> > > > +  TempChar = json_dumps ((json_t *)JsonObj, JSON_INDENT (2));
> > > > +  if (TempChar != NULL) {
> > > > +    if ((strlen (TempChar) + 1) > BuufferSize) {
> > > > +      Status = RedfishCS_status_insufficient_memory;
> > > > +    } else {
> > > > +      memcpy (NewJsonBuffer, TempChar, strlen (TempChar) + 1);
> > > > +      free (TempChar);
> > > > +      Status = RedfishCS_status_success;
> > > > +    }
> > > > +  } else {
> > > > +    Status = RedfishCS_status_unknown_error;
> > > > +  }
> > > > +  json_decref(JsonObj);
> > > > +  return Status;
> > > > +}
> > > > +
> > > > --
> > > > 2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113879): https://edk2.groups.io/g/devel/message/113879
Mute This Topic: https://groups.io/mt/103676920/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-01-16  8:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-12  3:26 [edk2-devel] [edk2-redfish-client][PATCH 1/3] RedfishClientPkg/jansson: Define json_object_del Chang, Abner via groups.io
2024-01-12  3:26 ` [edk2-devel] [edk2-redfish-client][PATCH 2/3] RedfishClientPkg/RedfishFeatureUtilityLib: Add two helper functions Chang, Abner via groups.io
2024-01-16  3:14   ` Nickle Wang via groups.io
2024-01-12  3:26 ` [edk2-devel] [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib: Function to remove Redfish unchangeable properties Chang, Abner via groups.io
2024-01-16  3:17   ` Nickle Wang via groups.io
2024-01-16  4:08     ` Chang, Abner via groups.io
2024-01-16  6:20       ` Nickle Wang via groups.io
2024-01-16  8:31         ` Chang, Abner via groups.io
2024-01-16  3:07 ` [edk2-devel] [edk2-redfish-client][PATCH 1/3] RedfishClientPkg/jansson: Define json_object_del Nickle Wang via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox