2013-11-09 16:16 keltezéssel, Mark Brown írta:
> On Sat, Nov 09, 2013 at 09:49:11AM +0000, Caizhiyong wrote:
> 
>> @@ -2170,7 +2170,8 @@ int regmap_register_patch(struct regmap *map, const 
>> struct reg_default *regs,
>>                        int num_regs)
>>  {
>>      struct reg_default *p;
>> -    int i, ret;
>> +    int i;
>> +    int ret = 0;
>>      bool bypass;
Wouldn't the following be better?

int i, ret = 0;

I think it is more readable.

> 
> This sort of fix isn't ideal, it just silences the warning but if the
> compiler has spotted a genuine oversight in the function it won't
> address it.  It's better to include some analysis of why this is a good
> fix.
> 
The only condition when 'ret' is not set is when the num_regs parameter is zero
and krealloc doesn't fail. If the above two conditions apply, then
the code would return an uninitialized value. However, calling this function 
with
num_regs == 0, would be a waste as it essentially does nothing.

Also, I think code which throws warnings is worse than code
which doesn't.

-- 
Regards,
Levente Kurusa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to