[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <50AEDF00.7060709@marvell.com>
Date: Fri, 23 Nov 2012 10:27:12 +0800
From: Qing Xu <qingx@...vell.com>
To: Mark Brown <broonie@...nsource.wolfsonmicro.com>
Cc: "lrg@...com" <lrg@...com>,
"haojian.zhuang@...il.com" <haojian.zhuang@...il.com>,
Chao Xie <cxie4@...vell.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] regulator: max8925: fix compiler warnings
On 11/23/2012 09:41 AM, Mark Brown wrote:
> On Thu, Nov 22, 2012 at 10:11:06AM +0800, Qing Xu wrote:
>
>> - int i, regulator_idx;
>> + int i;
>> + int regulator_idx = 0;
> This sort of fix is rarely good without some analysis as to why this is
> a sensible initialisation to do, just unconditionally initialising may
> be masking a real issue in the control flow which the compiler has
> identified.
In my build environment, there is no such compiler warning. :(
Adding this patch is just want to avoid kbuild test robot's warning.
But, in fact, it is not necessary to initialize regulator_idx.
for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
ri = &max8925_regulator_info[i];
if (ri->vol_reg == res->start) {
****** if regulator_idx can not get a match "i" here, it will return
-EINVAL in below code
regulator_idx = i;
break;
}
}
if (i == ARRAY_SIZE(max8925_regulator_info)) {
dev_err(&pdev->dev, "Failed to find regulator %llu\n",
(unsigned long long)res->start);
return -EINVAL;
}
How to solve such compiler warning?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists