ACK: [PATCH 40/46] lib: klog: reduce scope of variables

Alex Hung alex.hung at canonical.com
Tue Jan 20 08:00:32 UTC 2015


On 01/14/2015 03:04 AM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
> 
> cppcheck is picking up some minor style issues which can
> be easily fixed:
> 
> [src/lib/src/fwts_klog.c:54]:
> 	(style) The scope of the variable 'l_old_last' can be reduced.
> [src/lib/src/fwts_klog.c:56]:
> 	(style) The scope of the variable 'old' can be reduced.
> [src/lib/src/fwts_klog.c:546]:
> 	(style) The scope of the variable 'extra' can be reduced.
> [src/lib/src/fwts_klog.c:547]:
> 	(style) The scope of the variable 'rc' can be reduced.
> [src/lib/src/fwts_klog.c:548]:
> 	(style) The scope of the variable 'vector' can be reduced.
> 
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/lib/src/fwts_klog.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/src/lib/src/fwts_klog.c b/src/lib/src/fwts_klog.c
> index b38a02e..f724e41 100644
> --- a/src/lib/src/fwts_klog.c
> +++ b/src/lib/src/fwts_klog.c
> @@ -51,9 +51,8 @@ void fwts_klog_free(fwts_list *klog)
>   */
>  fwts_list *fwts_klog_find_changes(fwts_list *klog_old, fwts_list *klog_new)
>  {
> -	fwts_list_link *l_old, *l_new, *l_old_last = NULL;
> +	fwts_list_link *l_old, *l_new;
>  	fwts_list *klog_diff;
> -	char *old;
>  
>  	if (klog_new == NULL) {
>  		/* Nothing new to compare, return nothing */
> @@ -66,6 +65,9 @@ fwts_list *fwts_klog_find_changes(fwts_list *klog_old, fwts_list *klog_new)
>  		/* Nothing in old log, so clone all of new list */
>  		l_new = klog_new->head;
>  	} else {
> +		fwts_list_link *l_old_last = NULL;
> +		char *old;
> +
>  		/* Clone just the new differences */
>  
>  		/* Find last item in old log */
> @@ -543,9 +545,6 @@ static void fwts_klog_regex_find_callback(fwts_framework *fw, char *line, int re
>  	const char *error;
>  	int erroffset;
>  	pcre *re;
> -	pcre_extra *extra;
> -	int rc;
> -	int vector[1];
>  
>  	FWTS_UNUSED(fw);
>  	FWTS_UNUSED(repeated);
> @@ -553,7 +552,10 @@ static void fwts_klog_regex_find_callback(fwts_framework *fw, char *line, int re
>  
>  	re = pcre_compile(pattern, 0, &error, &erroffset, NULL);
>  	if (re != NULL) {
> -		extra = pcre_study(re, 0, &error);
> +		int rc;
> +		int vector[1];
> +		pcre_extra *extra = pcre_study(re, 0, &error);
> +
>  		if (error)
>  			return;
>  
> 

Acked-by: Alex Hung <alex.hung at canonical.com>



More information about the fwts-devel mailing list