Skip to contentSkip to conversation

acpi: get_throttling_state() cannot be larger than state_count

PATCH Applied [email protected] 3 participants 4 messages Mar 4, 2009 – Mar 17, 2009 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 4/8 acpi: get_throttling_state() cannot be larger than state_count

From: Roel Kluin <[email protected]>

With for(i = 0; i < n; i++) { ... } i reaches n.

---

 drivers/acpi/processor_throttling.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/processor_throttling.c renamed from drivers/acpi/processor_throttling.c~acpi-get_throttling_state-cannot-be-larger-state_count +1 -1
diff -puN drivers/acpi/processor_throttling.c~acpi-get_throttling_state-cannot-be-larger-state_count drivers/acpi/processor_throttling.c
@@ -785,7 +785,7 @@ static int acpi_get_throttling_state(str
 		if (tx->control == value)
 			break;
 	}
-	if (i > pr->throttling.state_count)
+	if (i >= pr->throttling.state_count)
 		i = -1;
 	return i;
 }

_

reviewer
#1 lore raw

--
Len Brown, Intel Open Source Technology Center

Quoted 25 lines · On Wed, 4 Mar 2009, [email protected] wrote:

From: Roel Kluin <[email protected]>

With for(i = 0; i < n; i++) { ... } i reaches n.

---

 drivers/acpi/processor_throttling.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN drivers/acpi/processor_throttling.c~acpi-get_throttling_state-cannot-be-larger-state_count drivers/acpi/processor_throttling.c

drivers/acpi/processor_throttling.c renamed from drivers/acpi/processor_throttling.c~acpi-get_throttling_state-cannot-be-larger-state_count +1 -1
@@ -785,7 +785,7 @@ static int acpi_get_throttling_state(str
 		if (tx->control == value)
 			break;
 	}
-	if (i > pr->throttling.state_count)
+	if (i >= pr->throttling.state_count)
 		i = -1;
 	return i;
 }
Quoted 2 lines

_

how about simply...

drivers/acpi/processor_throttling.c +2 -4
index d278381..5f09901 100644
@@ -783,11 +783,9 @@ static int acpi_get_throttling_state(struct acpi_processor *pr,
 		    (struct acpi_processor_tx_tss *)&(pr->throttling.
 						      states_tss[i]);
 		if (tx->control == value)
-			break;
+			return i;
 	}
-	if (i > pr->throttling.state_count)
-		i = -1;
-	return i;
+	return -1;
 }
 
 static int acpi_get_throttling_value(struct acpi_processor *pr,
#2 lore raw
Quoted 19 lines · Len Brown

--
Len Brown, Intel Open Source Technology Center

Quoted 13 lines · On Wed, 4 Mar 2009, [email protected] wrote:

From: Roel Kluin <[email protected]>

With for(i = 0; i < n; i++) { ... } i reaches n.

---

 drivers/acpi/processor_throttling.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
Quoted 12 lines

diff -puN drivers/acpi/processor_throttling.c~acpi-get_throttling_state-cannot-be-larger-state_count drivers/acpi/processor_throttling.c

drivers/acpi/processor_throttling.c renamed from drivers/acpi/processor_throttling.c~acpi-get_throttling_state-cannot-be-larger-state_count +1 -1
@@ -785,7 +785,7 @@ static int acpi_get_throttling_state(str
 		if (tx->control == value)
 			break;
 	}
-	if (i > pr->throttling.state_count)
+	if (i >= pr->throttling.state_count)
 		i = -1;
 	return i;
 }
Quoted 2 lines

_

how about simply...

It is OK to me.

Quoted 19 lines
drivers/acpi/processor_throttling.c +2 -4
index d278381..5f09901 100644
@@ -783,11 +783,9 @@ static int acpi_get_throttling_state(struct acpi_processor *pr,
 		    (struct acpi_processor_tx_tss *)&(pr->throttling.
 						      states_tss[i]);
 		if (tx->control == value)
-			break;
+			return i;
 	}
-	if (i > pr->throttling.state_count)
-		i = -1;
-	return i;
+	return -1;
 }
 
 static int acpi_get_throttling_value(struct acpi_processor *pr,
reviewer
#3 lore raw
In reply to [email protected]

Andrew,
you'll want to drop this one from your series
b/c I checked in the simpler version.

thanks,
Len Brown, Intel Open Source Technology Center

Quoted 27 lines · On Wed, 4 Mar 2009, [email protected] wrote:

From: Roel Kluin <[email protected]>

With for(i = 0; i < n; i++) { ... } i reaches n.

---

 drivers/acpi/processor_throttling.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN drivers/acpi/processor_throttling.c~acpi-get_throttling_state-cannot-be-larger-state_count drivers/acpi/processor_throttling.c

drivers/acpi/processor_throttling.c renamed from drivers/acpi/processor_throttling.c~acpi-get_throttling_state-cannot-be-larger-state_count +1 -1
@@ -785,7 +785,7 @@ static int acpi_get_throttling_state(str
 		if (tx->control == value)
 			break;
 	}
-	if (i > pr->throttling.state_count)
+	if (i >= pr->throttling.state_count)
 		i = -1;
 	return i;
 }

_