From: "Nickle Wang via groups.io" <nicklew=nvidia.com@groups.io>
To: <devel@edk2.groups.io>
Cc: Abner Chang <abner.chang@amd.com>, Igor Kulchytskyy <igork@ami.com>
Subject: [edk2-devel] [edk2-redfish-client][PATCH 10/13] RedfishClientPkg/ComputerSystemDxe: ues RedfishHttpLib
Date: Thu, 29 Feb 2024 16:54:55 +0800 [thread overview]
Message-ID: <20240229085455.112664-1-nicklew@nvidia.com> (raw)
Use EDK2 RedfishHttpLib to replace RedfishHttpCacheLib and RedfishLib
Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
---
.../v1_13_0/Dxe/ComputerSystemDxe.inf | 3 +-
.../v1_5_0/Dxe/ComputerSystemDxe.inf | 3 +-
.../v1_13_0/Common/ComputerSystemCommon.c | 68 +++++++++------
.../v1_13_0/Dxe/ComputerSystemDxe.c | 85 ++++---------------
.../v1_5_0/Common/ComputerSystemCommon.c | 68 +++++++++------
.../v1_5_0/Dxe/ComputerSystemDxe.c | 84 ++++--------------
6 files changed, 116 insertions(+), 195 deletions(-)
diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.inf b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.inf
index be1c2164d..40403ac7f 100644
--- a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.inf
+++ b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.inf
@@ -32,13 +32,12 @@
BaseMemoryLib
DebugLib
EdkIIRedfishResourceConfigLib
- RedfishLib
+ RedfishHttpLib
RedfishFeatureUtilityLib
RedfishResourceIdentifyLib
UefiLib
UefiDriverEntryPoint
RedfishAddendumLib
- RedfishHttpCacheLib
[Protocols]
gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED
diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.inf b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.inf
index 4e7dc5c7c..46ac2d4e5 100644
--- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.inf
+++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.inf
@@ -32,13 +32,12 @@
BaseMemoryLib
DebugLib
EdkIIRedfishResourceConfigLib
- RedfishLib
+ RedfishHttpLib
RedfishFeatureUtilityLib
RedfishResourceIdentifyLib
UefiLib
UefiDriverEntryPoint
RedfishAddendumLib
- RedfishHttpCacheLib
[Protocols]
gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED
diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.c b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.c
index d69fc176a..df22a1c90 100644
--- a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.c
+++ b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.c
@@ -2,7 +2,7 @@
Redfish feature driver implementation - common functions
(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
- Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -407,18 +407,18 @@ ProvisioningComputerSystemResource (
IN EFI_STRING ConfigureLang
)
{
- CHAR8 *Json;
- CHAR8 *JsonWithAddendum;
- EFI_STATUS Status;
- EFI_STRING NewResourceLocation;
- CHAR8 *EtagStr;
- CHAR8 ResourceId[16];
+ CHAR8 *Json;
+ CHAR8 *JsonWithAddendum;
+ EFI_STATUS Status;
+ EFI_STRING NewResourceLocation;
+ CHAR8 ResourceId[16];
+ REDFISH_RESPONSE Response;
if (IS_EMPTY_STRING (ConfigureLang) || (Private == NULL)) {
return EFI_INVALID_PARAMETER;
}
- EtagStr = NULL;
+ ZeroMem (&Response, sizeof (REDFISH_RESPONSE));
AsciiSPrint (ResourceId, sizeof (ResourceId), "%d", Index);
Status = ProvisioningComputerSystemProperties (
@@ -466,27 +466,31 @@ ProvisioningComputerSystemResource (
JsonWithAddendum = NULL;
}
- Status = CreatePayloadToPostResource (Private->RedfishService, Private->Payload, Json, &NewResourceLocation, &EtagStr);
+ Status = RedfishHttpPostResource (Private->RedfishService, Private->Uri, Json, &Response);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: post ComputerSystem resource for %s failed: %r\n", __func__, ConfigureLang, Status));
+ DEBUG ((DEBUG_ERROR, "%a, post Bios resource for %s failed: %r\n", __func__, ConfigureLang, Status));
goto RELEASE_RESOURCE;
}
- ASSERT (NewResourceLocation != NULL);
+ //
+ // Per Redfish spec. the URL of new resource will be returned in "Location" header.
+ //
+ Status = GetHttpResponseLocation (&Response, &NewResourceLocation);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: cannot find new location: %r\n", __func__, Status));
+ goto RELEASE_RESOURCE;
+ }
//
// Keep location of new resource.
//
if (NewResourceLocation != NULL) {
+ DEBUG ((DEBUG_MANAGEABILITY, "%a: Location: %s\n", __func__, NewResourceLocation));
RedfishSetRedfishUri (ConfigureLang, NewResourceLocation);
}
RELEASE_RESOURCE:
- if (EtagStr != NULL) {
- FreePool (EtagStr);
- }
-
if (NewResourceLocation != NULL) {
FreePool (NewResourceLocation);
}
@@ -495,6 +499,8 @@ RELEASE_RESOURCE:
FreePool (Json);
}
+ RedfishHttpFreeResponse (&Response);
+
return Status;
}
@@ -537,10 +543,11 @@ ProvisioningComputerSystemExistResource (
IN REDFISH_RESOURCE_COMMON_PRIVATE *Private
)
{
- EFI_STATUS Status;
- EFI_STRING ConfigureLang;
- CHAR8 *Json;
- CHAR8 *JsonWithAddendum;
+ EFI_STATUS Status;
+ EFI_STRING ConfigureLang;
+ CHAR8 *Json;
+ CHAR8 *JsonWithAddendum;
+ REDFISH_RESPONSE Response;
if (Private == NULL) {
return EFI_INVALID_PARAMETER;
@@ -548,6 +555,7 @@ ProvisioningComputerSystemExistResource (
Json = NULL;
ConfigureLang = NULL;
+ ZeroMem (&Response, sizeof (REDFISH_RESPONSE));
ConfigureLang = RedfishGetConfigLanguage (Private->Uri);
if (ConfigureLang == NULL) {
@@ -608,15 +616,17 @@ ProvisioningComputerSystemExistResource (
DEBUG ((DEBUG_MANAGEABILITY, "%a: provisioning existing resource for %s\n", __func__, ConfigureLang));
//
- // PUT back to instance
+ // PATCH back to instance
//
- Status = CreatePayloadToPatchResource (Private->RedfishService, Private->Payload, Json, NULL);
+ Status = RedfishHttpPatchResource (Private->RedfishService, Private->Uri, Json, &Response);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n", __func__, ConfigureLang, Status));
}
ON_RELEASE:
+ RedfishHttpFreeResponse (&Response);
+
if (Json != NULL) {
FreePool (Json);
}
@@ -736,10 +746,11 @@ RedfishUpdateResourceCommon (
IN CHAR8 *InputJson
)
{
- EFI_STATUS Status;
- CHAR8 *Json;
- CHAR8 *JsonWithAddendum;
- EFI_STRING ConfigureLang;
+ EFI_STATUS Status;
+ CHAR8 *Json;
+ CHAR8 *JsonWithAddendum;
+ EFI_STRING ConfigureLang;
+ REDFISH_RESPONSE Response;
if ((Private == NULL) || IS_EMPTY_STRING (InputJson)) {
return EFI_INVALID_PARAMETER;
@@ -747,6 +758,7 @@ RedfishUpdateResourceCommon (
Json = NULL;
ConfigureLang = NULL;
+ ZeroMem (&Response, sizeof (REDFISH_RESPONSE));
ConfigureLang = RedfishGetConfigLanguage (Private->Uri);
if (ConfigureLang == NULL) {
@@ -807,15 +819,17 @@ RedfishUpdateResourceCommon (
DEBUG ((REDFISH_DEBUG_TRACE, "%a: update resource for %s\n", __func__, ConfigureLang));
//
- // PUT back to instance
+ // PATCH back to instance
//
- Status = CreatePayloadToPatchResource (Private->RedfishService, Private->Payload, Json, NULL);
+ Status = RedfishHttpPatchResource (Private->RedfishService, Private->Uri, Json, &Response);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n", __func__, ConfigureLang, Status));
}
ON_RELEASE:
+ RedfishHttpFreeResponse (&Response);
+
if (Json != NULL) {
FreePool (Json);
}
diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.c b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.c
index 174a8176a..1235760a1 100644
--- a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.c
+++ b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.c
@@ -51,7 +51,7 @@ RedfishResourceProvisioningResource (
}
ZeroMem (&Response, sizeof (Response));
- Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -74,16 +74,8 @@ RedfishResourceProvisioningResource (
//
// Release resource
//
- if (Private->Payload != NULL) {
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
- Private->Payload = NULL;
- }
-
+ RedfishHttpFreeResponse (&Response);
+ Private->Payload = NULL;
return Status;
}
@@ -123,7 +115,7 @@ RedfishResourceConsumeResource (
}
ZeroMem (&Response, sizeof (Response));
- Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -175,27 +167,9 @@ RedfishResourceConsumeResource (
//
// Release resource
//
- if (Private->Payload != NULL) {
- if (Response.Payload != NULL) {
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
- }
-
- if (PendingSettingResponse.Payload != NULL) {
- RedfishFreeResponse (
- PendingSettingResponse.StatusCode,
- PendingSettingResponse.HeaderCount,
- PendingSettingResponse.Headers,
- PendingSettingResponse.Payload
- );
- }
-
- Private->Payload = NULL;
- }
+ RedfishHttpFreeResponse (&Response);
+ RedfishHttpFreeResponse (&PendingSettingResponse);
+ Private->Payload = NULL;
if (Private->Json != NULL) {
FreePool (Private->Json);
@@ -269,7 +243,7 @@ RedfishResourceUpdate (
}
ZeroMem (&Response, sizeof (Response));
- Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -295,16 +269,8 @@ RedfishResourceUpdate (
//
// Release resource
//
- if (Private->Payload != NULL) {
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
- RedfishHttpResetResource (Uri);
- Private->Payload = NULL;
- }
+ RedfishHttpFreeResponse (&Response);
+ Private->Payload = NULL;
if (Private->Json != NULL) {
FreePool (Private->Json);
@@ -347,7 +313,7 @@ RedfishResourceCheck (
}
ZeroMem (&Response, sizeof (Response));
- Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -377,15 +343,8 @@ RedfishResourceCheck (
FreePool (Etag);
}
- if (Private->Payload != NULL) {
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
- Private->Payload = NULL;
- }
+ RedfishHttpFreeResponse (&Response);
+ Private->Payload = NULL;
if (Private->Json != NULL) {
FreePool (Private->Json);
@@ -428,7 +387,7 @@ RedfishResourceIdentify (
}
ZeroMem (&Response, sizeof (Response));
- Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -449,15 +408,8 @@ RedfishResourceIdentify (
//
// Release resource
//
- if (Private->Payload != NULL) {
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
- Private->Payload = NULL;
- }
+ RedfishHttpFreeResponse (&Response);
+ Private->Payload = NULL;
if (Private->Json != NULL) {
FreePool (Private->Json);
@@ -539,11 +491,6 @@ RedfishResourceStop (
Private->RedfishService = NULL;
}
- if (Private->Payload != NULL) {
- RedfishCleanupPayload (Private->Payload);
- Private->Payload = NULL;
- }
-
return EFI_SUCCESS;
}
diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c
index 11bcb5f76..c383cad59 100644
--- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c
+++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c
@@ -2,7 +2,7 @@
Redfish feature driver implementation - common functions
(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
- Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -1277,18 +1277,18 @@ ProvisioningComputerSystemResource (
IN EFI_STRING ConfigureLang
)
{
- CHAR8 *Json;
- CHAR8 *JsonWithAddendum;
- EFI_STATUS Status;
- EFI_STRING NewResourceLocation;
- CHAR8 *EtagStr;
- CHAR8 ResourceId[16];
+ CHAR8 *Json;
+ CHAR8 *JsonWithAddendum;
+ EFI_STATUS Status;
+ EFI_STRING NewResourceLocation;
+ CHAR8 ResourceId[16];
+ REDFISH_RESPONSE Response;
if (IS_EMPTY_STRING (ConfigureLang) || (Private == NULL)) {
return EFI_INVALID_PARAMETER;
}
- EtagStr = NULL;
+ ZeroMem (&Response, sizeof (REDFISH_RESPONSE));
AsciiSPrint (ResourceId, sizeof (ResourceId), "%d", Index);
Status = ProvisioningComputerSystemProperties (
@@ -1336,27 +1336,31 @@ ProvisioningComputerSystemResource (
JsonWithAddendum = NULL;
}
- Status = CreatePayloadToPostResource (Private->RedfishService, Private->Payload, Json, &NewResourceLocation, &EtagStr);
+ Status = RedfishHttpPostResource (Private->RedfishService, Private->Uri, Json, &Response);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: post ComputerSystem resource for %s failed: %r\n", __func__, ConfigureLang, Status));
+ DEBUG ((DEBUG_ERROR, "%a, post Bios resource for %s failed: %r\n", __func__, ConfigureLang, Status));
goto RELEASE_RESOURCE;
}
- ASSERT (NewResourceLocation != NULL);
+ //
+ // Per Redfish spec. the URL of new resource will be returned in "Location" header.
+ //
+ Status = GetHttpResponseLocation (&Response, &NewResourceLocation);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: cannot find new location: %r\n", __func__, Status));
+ goto RELEASE_RESOURCE;
+ }
//
// Keep location of new resource.
//
if (NewResourceLocation != NULL) {
+ DEBUG ((DEBUG_MANAGEABILITY, "%a: Location: %s\n", __func__, NewResourceLocation));
RedfishSetRedfishUri (ConfigureLang, NewResourceLocation);
}
RELEASE_RESOURCE:
- if (EtagStr != NULL) {
- FreePool (EtagStr);
- }
-
if (NewResourceLocation != NULL) {
FreePool (NewResourceLocation);
}
@@ -1365,6 +1369,8 @@ RELEASE_RESOURCE:
FreePool (Json);
}
+ RedfishHttpFreeResponse (&Response);
+
return Status;
}
@@ -1407,10 +1413,11 @@ ProvisioningComputerSystemExistResource (
IN REDFISH_RESOURCE_COMMON_PRIVATE *Private
)
{
- EFI_STATUS Status;
- EFI_STRING ConfigureLang;
- CHAR8 *Json;
- CHAR8 *JsonWithAddendum;
+ EFI_STATUS Status;
+ EFI_STRING ConfigureLang;
+ CHAR8 *Json;
+ CHAR8 *JsonWithAddendum;
+ REDFISH_RESPONSE Response;
if (Private == NULL) {
return EFI_INVALID_PARAMETER;
@@ -1418,6 +1425,7 @@ ProvisioningComputerSystemExistResource (
Json = NULL;
ConfigureLang = NULL;
+ ZeroMem (&Response, sizeof (REDFISH_RESPONSE));
ConfigureLang = RedfishGetConfigLanguage (Private->Uri);
if (ConfigureLang == NULL) {
@@ -1478,15 +1486,17 @@ ProvisioningComputerSystemExistResource (
DEBUG ((DEBUG_MANAGEABILITY, "%a: provisioning existing resource for %s\n", __func__, ConfigureLang));
//
- // PUT back to instance
+ // PATCH back to instance
//
- Status = CreatePayloadToPatchResource (Private->RedfishService, Private->Payload, Json, NULL);
+ Status = RedfishHttpPatchResource (Private->RedfishService, Private->Uri, Json, &Response);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n", __func__, ConfigureLang, Status));
}
ON_RELEASE:
+ RedfishHttpFreeResponse (&Response);
+
if (Json != NULL) {
FreePool (Json);
}
@@ -1606,10 +1616,11 @@ RedfishUpdateResourceCommon (
IN CHAR8 *InputJson
)
{
- EFI_STATUS Status;
- CHAR8 *Json;
- CHAR8 *JsonWithAddendum;
- EFI_STRING ConfigureLang;
+ EFI_STATUS Status;
+ CHAR8 *Json;
+ CHAR8 *JsonWithAddendum;
+ EFI_STRING ConfigureLang;
+ REDFISH_RESPONSE Response;
if ((Private == NULL) || IS_EMPTY_STRING (InputJson)) {
return EFI_INVALID_PARAMETER;
@@ -1617,6 +1628,7 @@ RedfishUpdateResourceCommon (
Json = NULL;
ConfigureLang = NULL;
+ ZeroMem (&Response, sizeof (REDFISH_RESPONSE));
ConfigureLang = RedfishGetConfigLanguage (Private->Uri);
if (ConfigureLang == NULL) {
@@ -1677,15 +1689,17 @@ RedfishUpdateResourceCommon (
DEBUG ((REDFISH_DEBUG_TRACE, "%a: update resource for %s\n", __func__, ConfigureLang));
//
- // PUT back to instance
+ // PATCH back to instance
//
- Status = CreatePayloadToPatchResource (Private->RedfishService, Private->Payload, Json, NULL);
+ Status = RedfishHttpPatchResource (Private->RedfishService, Private->Uri, Json, &Response);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n", __func__, ConfigureLang, Status));
}
ON_RELEASE:
+ RedfishHttpFreeResponse (&Response);
+
if (Json != NULL) {
FreePool (Json);
}
diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c
index 174a8176a..5207362da 100644
--- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c
+++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c
@@ -51,7 +51,7 @@ RedfishResourceProvisioningResource (
}
ZeroMem (&Response, sizeof (Response));
- Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -74,15 +74,8 @@ RedfishResourceProvisioningResource (
//
// Release resource
//
- if (Private->Payload != NULL) {
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
- Private->Payload = NULL;
- }
+ RedfishHttpFreeResponse (&Response);
+ Private->Payload = NULL;
return Status;
}
@@ -123,7 +116,7 @@ RedfishResourceConsumeResource (
}
ZeroMem (&Response, sizeof (Response));
- Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -175,27 +168,9 @@ RedfishResourceConsumeResource (
//
// Release resource
//
- if (Private->Payload != NULL) {
- if (Response.Payload != NULL) {
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
- }
-
- if (PendingSettingResponse.Payload != NULL) {
- RedfishFreeResponse (
- PendingSettingResponse.StatusCode,
- PendingSettingResponse.HeaderCount,
- PendingSettingResponse.Headers,
- PendingSettingResponse.Payload
- );
- }
-
- Private->Payload = NULL;
- }
+ RedfishHttpFreeResponse (&Response);
+ RedfishHttpFreeResponse (&PendingSettingResponse);
+ Private->Payload = NULL;
if (Private->Json != NULL) {
FreePool (Private->Json);
@@ -269,7 +244,7 @@ RedfishResourceUpdate (
}
ZeroMem (&Response, sizeof (Response));
- Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -295,16 +270,8 @@ RedfishResourceUpdate (
//
// Release resource
//
- if (Private->Payload != NULL) {
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
- RedfishHttpResetResource (Uri);
- Private->Payload = NULL;
- }
+ RedfishHttpFreeResponse (&Response);
+ Private->Payload = NULL;
if (Private->Json != NULL) {
FreePool (Private->Json);
@@ -347,7 +314,7 @@ RedfishResourceCheck (
}
ZeroMem (&Response, sizeof (Response));
- Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -377,15 +344,8 @@ RedfishResourceCheck (
FreePool (Etag);
}
- if (Private->Payload != NULL) {
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
- Private->Payload = NULL;
- }
+ RedfishHttpFreeResponse (&Response);
+ Private->Payload = NULL;
if (Private->Json != NULL) {
FreePool (Private->Json);
@@ -428,7 +388,7 @@ RedfishResourceIdentify (
}
ZeroMem (&Response, sizeof (Response));
- Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -449,15 +409,8 @@ RedfishResourceIdentify (
//
// Release resource
//
- if (Private->Payload != NULL) {
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
- Private->Payload = NULL;
- }
+ RedfishHttpFreeResponse (&Response);
+ Private->Payload = NULL;
if (Private->Json != NULL) {
FreePool (Private->Json);
@@ -539,11 +492,6 @@ RedfishResourceStop (
Private->RedfishService = NULL;
}
- if (Private->Payload != NULL) {
- RedfishCleanupPayload (Private->Payload);
- Private->Payload = NULL;
- }
-
return EFI_SUCCESS;
}
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116150): https://edk2.groups.io/g/devel/message/116150
Mute This Topic: https://groups.io/mt/104640233/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
reply other threads:[~2024-02-29 8:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240229085455.112664-1-nicklew@nvidia.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox