Re: [PATCH v2 08/21] DynamicTablesPkg: Update error handling for node creation


Sami Mujawar
 

Hi Pierre,

Thank you for this patch.

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

On 07/10/2021 04:31 PM, Pierre.Gondois@arm.com wrote:
From: Pierre Gondois <Pierre.Gondois@arm.com>

The node creation functions:
- AmlCreateRootNode()
- AmlCreateObjectNode()
- AmlCreateDataNode()
are now resetting the input pointer where the created node is stored.
Thus, it is not necessary to set some local variables to NULL or
check a node value before trying to delete it.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c | 6 +-----
DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlClone.c | 2 --
2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index 4775b68cd974..cbfd9cbb68b6 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -148,7 +148,6 @@ AmlCodeGenString (
return EFI_INVALID_PARAMETER;
}

- ObjectNode = NULL;
DataNode = NULL;

Status = AmlCreateObjectNode (
@@ -187,10 +186,7 @@ AmlCodeGenString (
return Status;

error_handler:
- if (ObjectNode != NULL) {
- AmlDeleteTree ((AML_NODE_HEADER*)ObjectNode);
- }
-
+ AmlDeleteTree ((AML_NODE_HEADER*)ObjectNode);
return Status;
}

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlClone.c b/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlClone.c
index e09372b039f1..7aafa957a8c4 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlClone.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlClone.c
@@ -43,8 +43,6 @@ AmlCloneNode (
return EFI_INVALID_PARAMETER;
}

- *ClonedNode = NULL;
-
if (IS_AML_DATA_NODE (Node)) {
DataNode = (AML_DATA_NODE*)Node;
Status = AmlCreateDataNode (
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Join devel@edk2.groups.io to automatically receive all group messages.