Messages in this thread | | | Date | Sat, 09 Nov 2013 20:02:17 +0100 | From | Levente Kurusa <> | Subject | Re: [PATCH] regmap: Fix compile warning with value uninitialized |
| |
2013-11-09 19:57 keltezéssel, Mark Brown írta: > On Sat, Nov 09, 2013 at 04:34:07PM +0100, Levente Kurusa wrote: >> 2013-11-09 16:16 keltezéssel, Mark Brown írta: > >>>> - 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. > > No, that's not the kernel coding style. Alright. > >>> 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. > > OK, so that should be in the changelog - or there should be an error > check for num_regs == 0 which might be more helpful.
Adding an explanation into the changelog and editing the patch in a way so that it adds a check would be the best choice I think.
Cai, can you please do this as part of the patch?
-- Regards, Levente Kurusa -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |