public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: gpio-ml-ioh: fix off-by-one for displaying variable i in dev_err
@ 2011-06-14 11:12 Axel Lin
  2011-06-16 19:45 ` Grant Likely
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2011-06-14 11:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Grant Likely

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.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/gpio/gpio-ml-ioh.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c
index 1bc621a..a9016f5 100644
--- a/drivers/gpio/gpio-ml-ioh.c
+++ b/drivers/gpio/gpio-ml-ioh.c
@@ -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)
-- 
1.7.4.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpio: gpio-ml-ioh: fix off-by-one for displaying variable i in dev_err
  2011-06-14 11:12 [PATCH] gpio: gpio-ml-ioh: fix off-by-one for displaying variable i in dev_err Axel Lin
@ 2011-06-16 19:45 ` Grant Likely
  0 siblings, 0 replies; 2+ messages in thread
From: Grant Likely @ 2011-06-16 19:45 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel

On Tue, Jun 14, 2011 at 07:12:57PM +0800, Axel Lin wrote:
> 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.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Merged, thanks.

g.

> ---
>  drivers/gpio/gpio-ml-ioh.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c
> index 1bc621a..a9016f5 100644
> --- a/drivers/gpio/gpio-ml-ioh.c
> +++ b/drivers/gpio/gpio-ml-ioh.c
> @@ -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)
> -- 
> 1.7.4.1
> 
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-16 19:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-14 11:12 [PATCH] gpio: gpio-ml-ioh: fix off-by-one for displaying variable i in dev_err Axel Lin
2011-06-16 19:45 ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox