Message ID | 15030a07-3615-fca0-1891-a234dc054b00@xs4all.nl |
---|---|
State | New |
Headers | show |
Series | media: tc358746: init m/p_best to 0 | expand |
Hi Hans, thanks for the patch. On 23-01-30, Hans Verkuil wrote: > This fixes compiler warnings: > > In file included from include/linux/printk.h:566, > from include/linux/kernel.h:29, > from include/linux/clk.h:13, > from drivers/media/i2c/tc358746.c:12: > drivers/media/i2c/tc358746.c: In function 'tc358746_find_pll_settings': > include/linux/dynamic_debug.h:272:33: warning: 'p_best' may be used uninitialized in this function [-Wmaybe-uninitialized] > 272 | _dynamic_func_call(fmt, __dynamic_dev_dbg, \ > | ^~~~~~~~~~~~~~~~~ > drivers/media/i2c/tc358746.c:817:13: note: 'p_best' was declared here > 817 | u16 p_best, p; > | ^~~~~~ > In file included from include/linux/printk.h:566, > from include/linux/kernel.h:29, > from include/linux/clk.h:13, > from drivers/media/i2c/tc358746.c:12: > include/linux/dynamic_debug.h:272:33: warning: 'm_best' may be used uninitialized in this function [-Wmaybe-uninitialized] > 272 | _dynamic_func_call(fmt, __dynamic_dev_dbg, \ > | ^~~~~~~~~~~~~~~~~ > drivers/media/i2c/tc358746.c:816:13: note: 'm_best' was declared here > 816 | u16 m_best, mul; > | ^~~~~~ I'm not sure why this is printed. The m/p_best variables are only used if best_freq != 0 else it is not used. If best_freq != 0 m/p_best is set to the found mul/p. So IMHO this is a false positiv from the compiler. > Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> to make the compiler happy: Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Regards, Marco > --- > drivers/media/i2c/tc358746.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/i2c/tc358746.c b/drivers/media/i2c/tc358746.c > index d1f552bd81d4..b86baa5c2d82 100644 > --- a/drivers/media/i2c/tc358746.c > +++ b/drivers/media/i2c/tc358746.c > @@ -813,8 +813,8 @@ static unsigned long tc358746_find_pll_settings(struct tc358746 *tc358746, > u32 min_delta = 0xffffffff; > u16 prediv_max = 17; > u16 prediv_min = 1; > - u16 m_best, mul; > - u16 p_best, p; > + u16 m_best = 0, mul; > + u16 p_best = 0, p; > u8 postdiv; > > if (fout > 1000 * HZ_PER_MHZ) { > -- > 2.39.0 > > >
On 23-01-30, Hans Verkuil wrote: > Hi Marco, > > I rejected my own patch :-) > > It turned out that I was testing with gcc-11 instead of 12. The latest gcc > version doesn't report this warning. Good to know that gcc-12 fixed this :) Regards, Marco
diff --git a/drivers/media/i2c/tc358746.c b/drivers/media/i2c/tc358746.c index d1f552bd81d4..b86baa5c2d82 100644 --- a/drivers/media/i2c/tc358746.c +++ b/drivers/media/i2c/tc358746.c @@ -813,8 +813,8 @@ static unsigned long tc358746_find_pll_settings(struct tc358746 *tc358746, u32 min_delta = 0xffffffff; u16 prediv_max = 17; u16 prediv_min = 1; - u16 m_best, mul; - u16 p_best, p; + u16 m_best = 0, mul; + u16 p_best = 0, p; u8 postdiv; if (fout > 1000 * HZ_PER_MHZ) {
This fixes compiler warnings: In file included from include/linux/printk.h:566, from include/linux/kernel.h:29, from include/linux/clk.h:13, from drivers/media/i2c/tc358746.c:12: drivers/media/i2c/tc358746.c: In function 'tc358746_find_pll_settings': include/linux/dynamic_debug.h:272:33: warning: 'p_best' may be used uninitialized in this function [-Wmaybe-uninitialized] 272 | _dynamic_func_call(fmt, __dynamic_dev_dbg, \ | ^~~~~~~~~~~~~~~~~ drivers/media/i2c/tc358746.c:817:13: note: 'p_best' was declared here 817 | u16 p_best, p; | ^~~~~~ In file included from include/linux/printk.h:566, from include/linux/kernel.h:29, from include/linux/clk.h:13, from drivers/media/i2c/tc358746.c:12: include/linux/dynamic_debug.h:272:33: warning: 'm_best' may be used uninitialized in this function [-Wmaybe-uninitialized] 272 | _dynamic_func_call(fmt, __dynamic_dev_dbg, \ | ^~~~~~~~~~~~~~~~~ drivers/media/i2c/tc358746.c:816:13: note: 'm_best' was declared here 816 | u16 m_best, mul; | ^~~~~~ Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> --- drivers/media/i2c/tc358746.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)