iASL: remove unneeded NULL checks
diff mbox series

Message ID 20191127130601.30854-1-colin.king@canonical.com
State Accepted
Headers show
Series
  • iASL: remove unneeded NULL checks
Related show

Commit Message

Colin King Nov. 27, 2019, 1:06 p.m. UTC
From: Erik Schmauss <erik.schmauss@intel.com>

They are unneeded because these functions do not return NULL. In the
case that these functions fail, they end up aborting the entire
program rather than returning NULL.

Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
(modified to match fwts src/acpica path)
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpica/source/compiler/aslfiles.c  |  6 ------
 src/acpica/source/compiler/dtcompile.c | 12 +++---------
 2 files changed, 3 insertions(+), 15 deletions(-)

Comments

Alex Hung Dec. 5, 2019, 3:22 a.m. UTC | #1
On 2019-11-27 6:06 a.m., Colin King wrote:
> From: Erik Schmauss <erik.schmauss@intel.com>
> 
> They are unneeded because these functions do not return NULL. In the
> case that these functions fail, they end up aborting the entire
> program rather than returning NULL.
> 
> Reported-by: Colin Ian King <colin.king@canonical.com>
> Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
> (modified to match fwts src/acpica path)
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpica/source/compiler/aslfiles.c  |  6 ------
>   src/acpica/source/compiler/dtcompile.c | 12 +++---------
>   2 files changed, 3 insertions(+), 15 deletions(-)
> 
> diff --git a/src/acpica/source/compiler/aslfiles.c b/src/acpica/source/compiler/aslfiles.c
> index b9208c7c..23acc470 100644
> --- a/src/acpica/source/compiler/aslfiles.c
> +++ b/src/acpica/source/compiler/aslfiles.c
> @@ -207,12 +207,6 @@ FlInitOneFile (
>       NewFileNode = ACPI_CAST_PTR (ASL_GLOBAL_FILE_NODE,
>           UtLocalCacheCalloc (sizeof (ASL_GLOBAL_FILE_NODE)));
>   
> -    if (!NewFileNode)
> -    {
> -        AslError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, NULL, NULL);
> -        return (AE_NO_MEMORY);
> -    }
> -
>       NewFileNode->ParserErrorDetected = FALSE;
>       NewFileNode->Next = AslGbl_FilesList;
>   
> diff --git a/src/acpica/source/compiler/dtcompile.c b/src/acpica/source/compiler/dtcompile.c
> index bdd8c1b7..80970822 100644
> --- a/src/acpica/source/compiler/dtcompile.c
> +++ b/src/acpica/source/compiler/dtcompile.c
> @@ -276,10 +276,7 @@ DtDoCompile (
>   
>       if (ACPI_FAILURE (Status))
>       {
> -        if (FileNode)
> -        {
> -            FileNode->ParserErrorDetected = TRUE;
> -        }
> +        FileNode->ParserErrorDetected = TRUE;
>   
>           /* TBD: temporary error message. Msgs should come from function above */
>   
> @@ -306,11 +303,8 @@ DtDoCompile (
>   
>       /* Save the compile time statistics to the current file node */
>   
> -    if (FileNode)
> -    {
> -        FileNode->TotalFields = AslGbl_InputFieldCount;
> -        FileNode->OutputByteLength = AslGbl_TableLength;
> -    }
> +    FileNode->TotalFields = AslGbl_InputFieldCount;
> +    FileNode->OutputByteLength = AslGbl_TableLength;
>   
>       return (Status);
>   }
> 


Acked-by: Alex Hung <alex.hung@canonical.com>
ivanhu Dec. 6, 2019, 2:15 a.m. UTC | #2
On 11/27/19 9:06 PM, Colin King wrote:
> From: Erik Schmauss <erik.schmauss@intel.com>
> 
> They are unneeded because these functions do not return NULL. In the
> case that these functions fail, they end up aborting the entire
> program rather than returning NULL.
> 
> Reported-by: Colin Ian King <colin.king@canonical.com>
> Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
> (modified to match fwts src/acpica path)
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpica/source/compiler/aslfiles.c  |  6 ------
>  src/acpica/source/compiler/dtcompile.c | 12 +++---------
>  2 files changed, 3 insertions(+), 15 deletions(-)
> 
> diff --git a/src/acpica/source/compiler/aslfiles.c b/src/acpica/source/compiler/aslfiles.c
> index b9208c7c..23acc470 100644
> --- a/src/acpica/source/compiler/aslfiles.c
> +++ b/src/acpica/source/compiler/aslfiles.c
> @@ -207,12 +207,6 @@ FlInitOneFile (
>      NewFileNode = ACPI_CAST_PTR (ASL_GLOBAL_FILE_NODE,
>          UtLocalCacheCalloc (sizeof (ASL_GLOBAL_FILE_NODE)));
>  
> -    if (!NewFileNode)
> -    {
> -        AslError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, NULL, NULL);
> -        return (AE_NO_MEMORY);
> -    }
> -
>      NewFileNode->ParserErrorDetected = FALSE;
>      NewFileNode->Next = AslGbl_FilesList;
>  
> diff --git a/src/acpica/source/compiler/dtcompile.c b/src/acpica/source/compiler/dtcompile.c
> index bdd8c1b7..80970822 100644
> --- a/src/acpica/source/compiler/dtcompile.c
> +++ b/src/acpica/source/compiler/dtcompile.c
> @@ -276,10 +276,7 @@ DtDoCompile (
>  
>      if (ACPI_FAILURE (Status))
>      {
> -        if (FileNode)
> -        {
> -            FileNode->ParserErrorDetected = TRUE;
> -        }
> +        FileNode->ParserErrorDetected = TRUE;
>  
>          /* TBD: temporary error message. Msgs should come from function above */
>  
> @@ -306,11 +303,8 @@ DtDoCompile (
>  
>      /* Save the compile time statistics to the current file node */
>  
> -    if (FileNode)
> -    {
> -        FileNode->TotalFields = AslGbl_InputFieldCount;
> -        FileNode->OutputByteLength = AslGbl_TableLength;
> -    }
> +    FileNode->TotalFields = AslGbl_InputFieldCount;
> +    FileNode->OutputByteLength = AslGbl_TableLength;
>  
>      return (Status);
>  }
> 

Acked-by: Ivan Hu <ivan.hu@canonical.com>

Patch
diff mbox series

diff --git a/src/acpica/source/compiler/aslfiles.c b/src/acpica/source/compiler/aslfiles.c
index b9208c7c..23acc470 100644
--- a/src/acpica/source/compiler/aslfiles.c
+++ b/src/acpica/source/compiler/aslfiles.c
@@ -207,12 +207,6 @@  FlInitOneFile (
     NewFileNode = ACPI_CAST_PTR (ASL_GLOBAL_FILE_NODE,
         UtLocalCacheCalloc (sizeof (ASL_GLOBAL_FILE_NODE)));
 
-    if (!NewFileNode)
-    {
-        AslError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, NULL, NULL);
-        return (AE_NO_MEMORY);
-    }
-
     NewFileNode->ParserErrorDetected = FALSE;
     NewFileNode->Next = AslGbl_FilesList;
 
diff --git a/src/acpica/source/compiler/dtcompile.c b/src/acpica/source/compiler/dtcompile.c
index bdd8c1b7..80970822 100644
--- a/src/acpica/source/compiler/dtcompile.c
+++ b/src/acpica/source/compiler/dtcompile.c
@@ -276,10 +276,7 @@  DtDoCompile (
 
     if (ACPI_FAILURE (Status))
     {
-        if (FileNode)
-        {
-            FileNode->ParserErrorDetected = TRUE;
-        }
+        FileNode->ParserErrorDetected = TRUE;
 
         /* TBD: temporary error message. Msgs should come from function above */
 
@@ -306,11 +303,8 @@  DtDoCompile (
 
     /* Save the compile time statistics to the current file node */
 
-    if (FileNode)
-    {
-        FileNode->TotalFields = AslGbl_InputFieldCount;
-        FileNode->OutputByteLength = AslGbl_TableLength;
-    }
+    FileNode->TotalFields = AslGbl_InputFieldCount;
+    FileNode->OutputByteLength = AslGbl_TableLength;
 
     return (Status);
 }