Skip to contentSkip to conversation

gpio: gpio-ml-ioh: fix off-by-one for displaying variable i in dev_err

PATCH Applied Axel Lin 2 participants 2 messages Jun 14, 2011 – Jun 16, 2011

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 gpio: gpio-ml-ioh: fix off-by-one for displaying variable i in dev_err

with the "for (; i != 0; i--)" sytax, i-- will be executed after the iteration. thus dev_err shows wrong i value.
Switch to "while(--i >= 0)" which is better in readability.

---
 drivers/gpio/gpio-ml-ioh.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/gpio/gpio-ml-ioh.c +1 -1
index 1bc621a..a9016f5 100644
@@ -233,7 +233,7 @@ static int __devinit ioh_gpio_probe(struct pci_dev *pdev,
 	return 0;
 
 err_gpiochip_add:
-	for (; i != 0; i--) {
+	while (--i >= 0) {
 		chip--;
 		ret = gpiochip_remove(&chip->gpio);
 		if (ret)
Signature · 1 line
1.7.4.1
Applied
#1 lore raw
Quoted 5 lines · Axel Lin

with the "for (; i != 0; i--)" sytax, i-- will be executed after the iteration. thus dev_err shows wrong i value.
Switch to "while(--i >= 0)" which is better in readability.

Merged, thanks.

g.

Quoted 22 lines
---
 drivers/gpio/gpio-ml-ioh.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/gpio/gpio-ml-ioh.c +1 -1
index 1bc621a..a9016f5 100644
@@ -233,7 +233,7 @@ static int __devinit ioh_gpio_probe(struct pci_dev *pdev,
 	return 0;
 
 err_gpiochip_add:
-	for (; i != 0; i--) {
+	while (--i >= 0) {
 		chip--;
 		ret = gpiochip_remove(&chip->gpio);
 		if (ret)
Signature · 1 line
1.7.4.1