ACK: [PATCH 36/46] lib: fwts_pm_method: reduce scope of variables

Alex Hung alex.hung at canonical.com
Tue Jan 20 07:54:18 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_pm_method.c:34]:
> 	(style) The scope of the variable 'reply' can be reduced.
> [src/lib/src/fwts_pm_method.c:111]:
> 	(style) The scope of the variable 'buffer' can be reduced.
> 
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/lib/src/fwts_pm_method.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/src/lib/src/fwts_pm_method.c b/src/lib/src/fwts_pm_method.c
> index c246fb7..2df3bfb 100644
> --- a/src/lib/src/fwts_pm_method.c
> +++ b/src/lib/src/fwts_pm_method.c
> @@ -31,11 +31,12 @@
>  static gboolean logind_do(gpointer data)
>  {
>  	GError *error = NULL;
> -	GVariant *reply;
>  	fwts_pm_method_vars *fwts_settings = (fwts_pm_method_vars *)data;
>  
>  	/* If the loop is not running, return TRUE so as to repeat the operation */
>  	if (g_main_loop_is_running (fwts_settings->gmainloop)) {
> +		GVariant *reply;
> +
>  		fwts_log_info(fwts_settings->fw, "Requesting %s action\n", fwts_settings->action);
>  		reply = g_dbus_proxy_call_sync(fwts_settings->logind_proxy,
>  			fwts_settings->action,
> @@ -108,7 +109,6 @@ static void logind_on_signal(
>  	gpointer user_data)
>  {
>  	gboolean status, is_s3;
> -	char buffer[50];
>  	fwts_pm_method_vars *fwts_settings = (fwts_pm_method_vars *)user_data;
>  
>  	/* Prevent -Werror=unused-parameter from complaining */
> @@ -133,7 +133,9 @@ static void logind_on_signal(
>  			status ? "true" : "false");
>  
>  		if (status) {
> -			time(&(fwts_settings->t_start));
> +			char buffer[50];
> +
> +			(void)time(&(fwts_settings->t_start));
>  			snprintf(buffer, sizeof(buffer), "Starting fwts %s\n", is_s3 ? "suspend" : "hibernate");
>  			(void)fwts_klog_write(fwts_settings->fw, buffer);
>  			snprintf(buffer, sizeof(buffer), "%s\n", fwts_settings->action);
> 

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



More information about the fwts-devel mailing list