diff mbox

acpi: battery: clean up source, no functional change

Message ID 1431686206-12752-1-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King May 15, 2015, 10:36 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

cppcheck was complaining about being able to reduce the scope
of new_variable:

[src/acpi/battery/battery.c:157]: (style) The scope of the
  variable 'new_value' can be reduced.

..so move the declaration.  Also re-format the spacing in
an ancient for loop

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

Comments

Alex Hung May 21, 2015, 11:07 p.m. UTC | #1
On 05/15/2015 03:36 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> cppcheck was complaining about being able to reduce the scope
> of new_variable:
> 
> [src/acpi/battery/battery.c:157]: (style) The scope of the
>   variable 'new_value' can be reduced.
> 
> ..so move the declaration.  Also re-format the spacing in
> an ancient for loop
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/battery/battery.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/src/acpi/battery/battery.c b/src/acpi/battery/battery.c
> index d216b32..bd4e257 100644
> --- a/src/acpi/battery/battery.c
> +++ b/src/acpi/battery/battery.c
> @@ -154,14 +154,15 @@ static void check_discharging(fwts_framework *fw, int index, char *name)
>  {
>  	int i;
>  	/* when we get here we KNOW the state is "discharging" */
> -	uint32_t initial_value, new_value;
> +	uint32_t initial_value;
>  
>  	fwts_printf(fw, "==== Waiting to see if battery '%s' discharges ====\n", name);
>  	fwts_cpu_consume_start();
>  
>  	initial_value = get_full(fw, index);
> -	for (i=0; i<=120; i++) {
> -		new_value = get_full(fw, index);
> +	for (i = 0; i <= 120; i++) {
> +		uint32_t new_value = get_full(fw, index);
> +
>  		if (new_value<initial_value) {
>  			fwts_passed(fw, "Battery %s charge is decrementing as expected.", name);
>  			fwts_cpu_consume_complete();
> 


Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu May 29, 2015, 7:01 a.m. UTC | #2
On 2015年05月15日 18:36, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> cppcheck was complaining about being able to reduce the scope
> of new_variable:
>
> [src/acpi/battery/battery.c:157]: (style) The scope of the
>    variable 'new_value' can be reduced.
>
> ..so move the declaration.  Also re-format the spacing in
> an ancient for loop
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/battery/battery.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/src/acpi/battery/battery.c b/src/acpi/battery/battery.c
> index d216b32..bd4e257 100644
> --- a/src/acpi/battery/battery.c
> +++ b/src/acpi/battery/battery.c
> @@ -154,14 +154,15 @@ static void check_discharging(fwts_framework *fw, int index, char *name)
>   {
>   	int i;
>   	/* when we get here we KNOW the state is "discharging" */
> -	uint32_t initial_value, new_value;
> +	uint32_t initial_value;
>   
>   	fwts_printf(fw, "==== Waiting to see if battery '%s' discharges ====\n", name);
>   	fwts_cpu_consume_start();
>   
>   	initial_value = get_full(fw, index);
> -	for (i=0; i<=120; i++) {
> -		new_value = get_full(fw, index);
> +	for (i = 0; i <= 120; i++) {
> +		uint32_t new_value = get_full(fw, index);
> +
>   		if (new_value<initial_value) {
>   			fwts_passed(fw, "Battery %s charge is decrementing as expected.", name);
>   			fwts_cpu_consume_complete();
Acked-by: Ivan Hu<ivan.hu@canonical.com>
diff mbox

Patch

diff --git a/src/acpi/battery/battery.c b/src/acpi/battery/battery.c
index d216b32..bd4e257 100644
--- a/src/acpi/battery/battery.c
+++ b/src/acpi/battery/battery.c
@@ -154,14 +154,15 @@  static void check_discharging(fwts_framework *fw, int index, char *name)
 {
 	int i;
 	/* when we get here we KNOW the state is "discharging" */
-	uint32_t initial_value, new_value;
+	uint32_t initial_value;
 
 	fwts_printf(fw, "==== Waiting to see if battery '%s' discharges ====\n", name);
 	fwts_cpu_consume_start();
 
 	initial_value = get_full(fw, index);
-	for (i=0; i<=120; i++) {
-		new_value = get_full(fw, index);
+	for (i = 0; i <= 120; i++) {
+		uint32_t new_value = get_full(fw, index);
+
 		if (new_value<initial_value) {
 			fwts_passed(fw, "Battery %s charge is decrementing as expected.", name);
 			fwts_cpu_consume_complete();