From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.13843.1633620767435245430 for ; Thu, 07 Oct 2021 08:32:49 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pierre.gondois@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A8FA4113E; Thu, 7 Oct 2021 08:32:48 -0700 (PDT) Received: from e120189.arm.com (unknown [10.57.72.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A87543F66F; Thu, 7 Oct 2021 08:32:47 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [PATCH v2 08/21] DynamicTablesPkg: Update error handling for node creation Date: Thu, 7 Oct 2021 16:31:57 +0100 Message-Id: <20211007153210.26608-9-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211007153210.26608-1-Pierre.Gondois@arm.com> References: <20211007153210.26608-1-Pierre.Gondois@arm.com> From: Pierre Gondois 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 --- 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 ( -- 2.17.1