diff mbox

[12/46] acpi: s3: reduce scope of variables

Message ID 1421175905-17035-13-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King Jan. 13, 2015, 7:04 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

cppcheck is picking up some minor style issues which can
be easily fixed:

[src/acpi/s3/s3.c:156]:
	(style) The scope of the variable 'buffer' can be reduced.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/s3/s3.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Ivan Hu Jan. 15, 2015, 7:30 a.m. UTC | #1
On 01/14/2015 03:04 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> cppcheck is picking up some minor style issues which can
> be easily fixed:
>
> [src/acpi/s3/s3.c:156]:
> 	(style) The scope of the variable 'buffer' can be reduced.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/s3/s3.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/acpi/s3/s3.c b/src/acpi/s3/s3.c
> index 7aa420d..8cf76f0 100644
> --- a/src/acpi/s3/s3.c
> +++ b/src/acpi/s3/s3.c
> @@ -153,8 +153,6 @@ static int s3_do_suspend_resume(fwts_framework *fw,
>   	_cleanup_free_ char *command = NULL;
>   	_cleanup_free_ char *quirks = NULL;
>   	_cleanup_free_pm_vars_ fwts_pm_method_vars * fwts_settings = NULL;
> -	char buffer[80];
> -
>
>   	int (*do_suspend)(fwts_pm_method_vars *, const int, int*, const char*);
>
> @@ -231,7 +229,9 @@ static int s3_do_suspend_resume(fwts_framework *fw,
>   	if (s3_device_check) {
>   		int i;
>
> -		for (i=0;i<s3_device_check_delay;i++) {
> +		for (i = 0;i < s3_device_check_delay; i++) {
> +			char buffer[80];
> +
>   			snprintf(buffer, sizeof(buffer), "(Waiting %d/%d seconds)", i+1,s3_device_check_delay);
>   			fwts_progress_message(fw, percent, buffer);
>   			sleep(1);
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
Keng-Yu Lin Jan. 20, 2015, 6:50 a.m. UTC | #2
On Wed, Jan 14, 2015 at 3:04 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> cppcheck is picking up some minor style issues which can
> be easily fixed:
>
> [src/acpi/s3/s3.c:156]:
>         (style) The scope of the variable 'buffer' can be reduced.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/s3/s3.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/acpi/s3/s3.c b/src/acpi/s3/s3.c
> index 7aa420d..8cf76f0 100644
> --- a/src/acpi/s3/s3.c
> +++ b/src/acpi/s3/s3.c
> @@ -153,8 +153,6 @@ static int s3_do_suspend_resume(fwts_framework *fw,
>         _cleanup_free_ char *command = NULL;
>         _cleanup_free_ char *quirks = NULL;
>         _cleanup_free_pm_vars_ fwts_pm_method_vars * fwts_settings = NULL;
> -       char buffer[80];
> -
>
>         int (*do_suspend)(fwts_pm_method_vars *, const int, int*, const char*);
>
> @@ -231,7 +229,9 @@ static int s3_do_suspend_resume(fwts_framework *fw,
>         if (s3_device_check) {
>                 int i;
>
> -               for (i=0;i<s3_device_check_delay;i++) {
> +               for (i = 0;i < s3_device_check_delay; i++) {
> +                       char buffer[80];
> +
>                         snprintf(buffer, sizeof(buffer), "(Waiting %d/%d seconds)", i+1,s3_device_check_delay);
>                         fwts_progress_message(fw, percent, buffer);
>                         sleep(1);
> --
> 2.1.4
>
>

Acked-by: Keng-Yu Lin <kengyu@canonical.com>
diff mbox

Patch

diff --git a/src/acpi/s3/s3.c b/src/acpi/s3/s3.c
index 7aa420d..8cf76f0 100644
--- a/src/acpi/s3/s3.c
+++ b/src/acpi/s3/s3.c
@@ -153,8 +153,6 @@  static int s3_do_suspend_resume(fwts_framework *fw,
 	_cleanup_free_ char *command = NULL;
 	_cleanup_free_ char *quirks = NULL;
 	_cleanup_free_pm_vars_ fwts_pm_method_vars * fwts_settings = NULL;
-	char buffer[80];
-
 
 	int (*do_suspend)(fwts_pm_method_vars *, const int, int*, const char*);
 
@@ -231,7 +229,9 @@  static int s3_do_suspend_resume(fwts_framework *fw,
 	if (s3_device_check) {
 		int i;
 
-		for (i=0;i<s3_device_check_delay;i++) {
+		for (i = 0;i < s3_device_check_delay; i++) {
+			char buffer[80];
+
 			snprintf(buffer, sizeof(buffer), "(Waiting %d/%d seconds)", i+1,s3_device_check_delay);
 			fwts_progress_message(fw, percent, buffer);
 			sleep(1);