* [PATCH] regulator: 88pm8607: Fix off-by-one value range checking in the case of no id is matched
@ 2011-08-04 8:18 Axel Lin
2011-08-04 8:22 ` Mark Brown
2011-08-08 16:39 ` Liam Girdwood
0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2011-08-04 8:18 UTC (permalink / raw)
To: linux-kernel; +Cc: Haojian Zhuang, Liam Girdwood, Mark Brown
In the case of no id is matched, the variable i is equal to
ARRAY_SIZE(pm8607_regulator_info).
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
I think compare variable i with ARRAY_SIZE(pm8607_regulator_info) here is slightly
better in readability than compare with PM8607_ID_RG_MAX.
Axel
drivers/regulator/88pm8607.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 5dcdb0f..ca0d608 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -413,7 +413,7 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
if (info->desc.id == res->start)
break;
}
- if ((i < 0) || (i > PM8607_ID_RG_MAX)) {
+ if (i == ARRAY_SIZE(pm8607_regulator_info)) {
dev_err(&pdev->dev, "Failed to find regulator %llu\n",
(unsigned long long)res->start);
return -EINVAL;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: 88pm8607: Fix off-by-one value range checking in the case of no id is matched
2011-08-04 8:18 [PATCH] regulator: 88pm8607: Fix off-by-one value range checking in the case of no id is matched Axel Lin
@ 2011-08-04 8:22 ` Mark Brown
2011-08-08 16:39 ` Liam Girdwood
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2011-08-04 8:22 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Haojian Zhuang, Liam Girdwood
On Thu, Aug 04, 2011 at 04:18:11PM +0800, Axel Lin wrote:
> In the case of no id is matched, the variable i is equal to
> ARRAY_SIZE(pm8607_regulator_info).
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> I think compare variable i with ARRAY_SIZE(pm8607_regulator_info) here is slightly
> better in readability than compare with PM8607_ID_RG_MAX.
It should be more robust I guess.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: 88pm8607: Fix off-by-one value range checking in the case of no id is matched
2011-08-04 8:18 [PATCH] regulator: 88pm8607: Fix off-by-one value range checking in the case of no id is matched Axel Lin
2011-08-04 8:22 ` Mark Brown
@ 2011-08-08 16:39 ` Liam Girdwood
1 sibling, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2011-08-08 16:39 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Haojian Zhuang, Liam Girdwood, Mark Brown
On Thu, 2011-08-04 at 16:18 +0800, Axel Lin wrote:
> In the case of no id is matched, the variable i is equal to
> ARRAY_SIZE(pm8607_regulator_info).
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
> I think compare variable i with ARRAY_SIZE(pm8607_regulator_info) here is slightly
> better in readability than compare with PM8607_ID_RG_MAX.
> Axel
>
Applied.
Thanks
Liam
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-08-08 16:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-04 8:18 [PATCH] regulator: 88pm8607: Fix off-by-one value range checking in the case of no id is matched Axel Lin
2011-08-04 8:22 ` Mark Brown
2011-08-08 16:39 ` Liam Girdwood
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.