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.web09.10571.1633704405766240838 for ; Fri, 08 Oct 2021 07:46: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 9A95D1063; Fri, 8 Oct 2021 07:46:48 -0700 (PDT) Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2C5673F66F; Fri, 8 Oct 2021 07:46:46 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [PATCH v3 08/21] DynamicTablesPkg: Update error handling for node creation Date: Fri, 8 Oct 2021 15:46:19 +0100 Message-Id: <20211008144632.31894-9-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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. Reviewed-by: Sami Mujawar 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