diff mbox

[03/46] acpi: brightness: reduce scope of variables

Message ID 1421175905-17035-4-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/brightness/autobrightness.c:161]:
	(style) The scope of the variable 'j' can be reduced.

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

Comments

Ivan Hu Jan. 15, 2015, 7:28 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/brightness/autobrightness.c:161]:
> 	(style) The scope of the variable 'j' can be reduced.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/brightness/autobrightness.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/acpi/brightness/autobrightness.c b/src/acpi/brightness/autobrightness.c
> index 1d94b0e..2bd435a 100644
> --- a/src/acpi/brightness/autobrightness.c
> +++ b/src/acpi/brightness/autobrightness.c
> @@ -158,9 +158,11 @@ static int auto_brightness_test2(fwts_framework *fw)
>
>   			/* Find the ranges of the failed levels */
>   			for (i = 0; i <= max_brightness; i++) {
> -				int j, end = i;
> +				int end = i;
>
>   				if (brightness_fail[i]) {
> +					int j;
> +
>   					/* Scan until we don't find a failure */
>   					for (j = i; j <= max_brightness && brightness_fail[j]; j++)
>   						end = j;
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
Keng-Yu Lin Jan. 20, 2015, 6:43 a.m. UTC | #2
On Thu, Jan 15, 2015 at 3:28 PM, IvanHu <ivan.hu@canonical.com> wrote:
> 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/brightness/autobrightness.c:161]:
>>         (style) The scope of the variable 'j' can be reduced.
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>   src/acpi/brightness/autobrightness.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/acpi/brightness/autobrightness.c
>> b/src/acpi/brightness/autobrightness.c
>> index 1d94b0e..2bd435a 100644
>> --- a/src/acpi/brightness/autobrightness.c
>> +++ b/src/acpi/brightness/autobrightness.c
>> @@ -158,9 +158,11 @@ static int auto_brightness_test2(fwts_framework *fw)
>>
>>                         /* Find the ranges of the failed levels */
>>                         for (i = 0; i <= max_brightness; i++) {
>> -                               int j, end = i;
>> +                               int end = i;
>>
>>                                 if (brightness_fail[i]) {
>> +                                       int j;
>> +
>>                                         /* Scan until we don't find a
>> failure */
>>                                         for (j = i; j <= max_brightness &&
>> brightness_fail[j]; j++)
>>                                                 end = j;
>>
>
> Acked-by: Ivan Hu <ivan.hu@canonical.com>
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
diff mbox

Patch

diff --git a/src/acpi/brightness/autobrightness.c b/src/acpi/brightness/autobrightness.c
index 1d94b0e..2bd435a 100644
--- a/src/acpi/brightness/autobrightness.c
+++ b/src/acpi/brightness/autobrightness.c
@@ -158,9 +158,11 @@  static int auto_brightness_test2(fwts_framework *fw)
 
 			/* Find the ranges of the failed levels */
 			for (i = 0; i <= max_brightness; i++) {
-				int j, end = i;
+				int end = i;
 
 				if (brightness_fail[i]) {
+					int j;
+
 					/* Scan until we don't find a failure */
 					for (j = i; j <= max_brightness && brightness_fail[j]; j++)
 						end = j;