diff mbox series

opal: mem_info: clean up pedantic static analysis warnings

Message ID 20210922085416.114900-1-colin.king@canonical.com
State Accepted
Headers show
Series opal: mem_info: clean up pedantic static analysis warnings | expand

Commit Message

Colin Ian King Sept. 22, 2021, 8:54 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Static analysis is warning that namelist may be uninitialized.
Clean this up by setting the pointer to NULL.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/opal/mem_info.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alex Hung Sept. 22, 2021, 7:05 p.m. UTC | #1
On 2021-09-22 2:54 a.m., Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Static analysis is warning that namelist may be uninitialized.
> Clean this up by setting the pointer to NULL.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/opal/mem_info.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/opal/mem_info.c b/src/opal/mem_info.c
> index ac8631d3..03b04762 100644
> --- a/src/opal/mem_info.c
> +++ b/src/opal/mem_info.c
> @@ -137,7 +137,7 @@ static int process_dimm(
>  	char *my_dir)
>  {
>  	int count, i, failures = 0;
> -	struct dirent **namelist;
> +	struct dirent **namelist = NULL;
>  	bool found = false;
>  
>  	count = scandir(my_dir, &namelist, NULL, alphasort);
> @@ -337,7 +337,7 @@ static int process_mba(
>  static int get_linux_mem_devices(fwts_framework *fw)
>  {
>  	int count, i, failures = 0;
> -	struct dirent **namelist;
> +	struct dirent **namelist = NULL;
>  	bool found = false;
>  
>  	count = scandir(DT_FS_PATH, &namelist, NULL, alphasort);
> 

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu Sept. 23, 2021, 2:41 a.m. UTC | #2
On 9/22/21 4:54 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Static analysis is warning that namelist may be uninitialized.
> Clean this up by setting the pointer to NULL.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/opal/mem_info.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/opal/mem_info.c b/src/opal/mem_info.c
> index ac8631d3..03b04762 100644
> --- a/src/opal/mem_info.c
> +++ b/src/opal/mem_info.c
> @@ -137,7 +137,7 @@ static int process_dimm(
>  	char *my_dir)
>  {
>  	int count, i, failures = 0;
> -	struct dirent **namelist;
> +	struct dirent **namelist = NULL;
>  	bool found = false;
>  
>  	count = scandir(my_dir, &namelist, NULL, alphasort);
> @@ -337,7 +337,7 @@ static int process_mba(
>  static int get_linux_mem_devices(fwts_framework *fw)
>  {
>  	int count, i, failures = 0;
> -	struct dirent **namelist;
> +	struct dirent **namelist = NULL;
>  	bool found = false;
>  
>  	count = scandir(DT_FS_PATH, &namelist, NULL, alphasort);
> 

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

Patch

diff --git a/src/opal/mem_info.c b/src/opal/mem_info.c
index ac8631d3..03b04762 100644
--- a/src/opal/mem_info.c
+++ b/src/opal/mem_info.c
@@ -137,7 +137,7 @@  static int process_dimm(
 	char *my_dir)
 {
 	int count, i, failures = 0;
-	struct dirent **namelist;
+	struct dirent **namelist = NULL;
 	bool found = false;
 
 	count = scandir(my_dir, &namelist, NULL, alphasort);
@@ -337,7 +337,7 @@  static int process_mba(
 static int get_linux_mem_devices(fwts_framework *fw)
 {
 	int count, i, failures = 0;
-	struct dirent **namelist;
+	struct dirent **namelist = NULL;
 	bool found = false;
 
 	count = scandir(DT_FS_PATH, &namelist, NULL, alphasort);