diff mbox series

kernelscan: fix variable shadowing warning

Message ID 20210114151338.224791-1-colin.king@canonical.com
State Accepted
Headers show
Series kernelscan: fix variable shadowing warning | expand

Commit Message

Colin Ian King Jan. 14, 2021, 3:13 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Cppcheck is warning about variable name shadowing. Fix this by
renaming the top level variable 'patterns' to 'klog_patterns'.

Cleans up cppcheck warning:
src/utilities/kernelscan.c:352:16: style: Local variable 'patterns'
shadows outer variable [shadowVariable]
 klog_pattern *patterns;

src/utilities/kernelscan.c:113:22: note: Shadowed declaration
 static klog_pattern *patterns;

src/utilities/kernelscan.c:352:16: note: Shadow variable
 klog_pattern *patterns;

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

Comments

Alex Hung Jan. 14, 2021, 7:59 p.m. UTC | #1
On 2021-01-14 8:13 a.m., Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Cppcheck is warning about variable name shadowing. Fix this by
> renaming the top level variable 'patterns' to 'klog_patterns'.
> 
> Cleans up cppcheck warning:
> src/utilities/kernelscan.c:352:16: style: Local variable 'patterns'
> shadows outer variable [shadowVariable]
>  klog_pattern *patterns;
> 
> src/utilities/kernelscan.c:113:22: note: Shadowed declaration
>  static klog_pattern *patterns;
> 
> src/utilities/kernelscan.c:352:16: note: Shadow variable
>  klog_pattern *patterns;
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/utilities/kernelscan.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
> index 96e6ca4f..033e2176 100644
> --- a/src/utilities/kernelscan.c
> +++ b/src/utilities/kernelscan.c
> @@ -110,7 +110,7 @@ typedef struct {
>  /*
>   *  FWTS klog patterns, loaded from a json file
>   */
> -static klog_pattern *patterns;
> +static klog_pattern *klog_patterns;
>  
>  static unsigned int hash_size;
>  
> @@ -936,7 +936,7 @@ static int parse_kernel_message(parser *p, token *t)
>  			got_string = false;
>  
>  			if (str) {
> -				found |= klog_find(str, patterns);
> +				found |= klog_find(str, klog_patterns);
>  				free(str);
>  				str = NULL;
>  			}
> @@ -1057,10 +1057,10 @@ int main(int argc, char **argv)
>  		}
>  	}
>  
> -	patterns = klog_load("firmware_error_warning_patterns");
> +	klog_patterns = klog_load("firmware_error_warning_patterns");
>  	hash_init();
>  	parse_kernel_messages(stdin);
> -	klog_free(patterns);
> +	klog_free(klog_patterns);
>  
>  	exit(EXIT_SUCCESS);
>  }
> 

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu Jan. 18, 2021, 7:01 a.m. UTC | #2
On 1/14/21 11:13 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Cppcheck is warning about variable name shadowing. Fix this by
> renaming the top level variable 'patterns' to 'klog_patterns'.
> 
> Cleans up cppcheck warning:
> src/utilities/kernelscan.c:352:16: style: Local variable 'patterns'
> shadows outer variable [shadowVariable]
>  klog_pattern *patterns;
> 
> src/utilities/kernelscan.c:113:22: note: Shadowed declaration
>  static klog_pattern *patterns;
> 
> src/utilities/kernelscan.c:352:16: note: Shadow variable
>  klog_pattern *patterns;
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/utilities/kernelscan.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
> index 96e6ca4f..033e2176 100644
> --- a/src/utilities/kernelscan.c
> +++ b/src/utilities/kernelscan.c
> @@ -110,7 +110,7 @@ typedef struct {
>  /*
>   *  FWTS klog patterns, loaded from a json file
>   */
> -static klog_pattern *patterns;
> +static klog_pattern *klog_patterns;
>  
>  static unsigned int hash_size;
>  
> @@ -936,7 +936,7 @@ static int parse_kernel_message(parser *p, token *t)
>  			got_string = false;
>  
>  			if (str) {
> -				found |= klog_find(str, patterns);
> +				found |= klog_find(str, klog_patterns);
>  				free(str);
>  				str = NULL;
>  			}
> @@ -1057,10 +1057,10 @@ int main(int argc, char **argv)
>  		}
>  	}
>  
> -	patterns = klog_load("firmware_error_warning_patterns");
> +	klog_patterns = klog_load("firmware_error_warning_patterns");
>  	hash_init();
>  	parse_kernel_messages(stdin);
> -	klog_free(patterns);
> +	klog_free(klog_patterns);
>  
>  	exit(EXIT_SUCCESS);
>  }
> 

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

Patch

diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
index 96e6ca4f..033e2176 100644
--- a/src/utilities/kernelscan.c
+++ b/src/utilities/kernelscan.c
@@ -110,7 +110,7 @@  typedef struct {
 /*
  *  FWTS klog patterns, loaded from a json file
  */
-static klog_pattern *patterns;
+static klog_pattern *klog_patterns;
 
 static unsigned int hash_size;
 
@@ -936,7 +936,7 @@  static int parse_kernel_message(parser *p, token *t)
 			got_string = false;
 
 			if (str) {
-				found |= klog_find(str, patterns);
+				found |= klog_find(str, klog_patterns);
 				free(str);
 				str = NULL;
 			}
@@ -1057,10 +1057,10 @@  int main(int argc, char **argv)
 		}
 	}
 
-	patterns = klog_load("firmware_error_warning_patterns");
+	klog_patterns = klog_load("firmware_error_warning_patterns");
 	hash_init();
 	parse_kernel_messages(stdin);
-	klog_free(patterns);
+	klog_free(klog_patterns);
 
 	exit(EXIT_SUCCESS);
 }