Re: [PATCH] media: tc358746: init m/p_best to 0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Regards,

	Hans

On 30/01/2023 11:59, Marco Felsch wrote:
> 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@xxxxxxxxx>
> 
> to make the compiler happy:
> 
> Reviewed-by: Marco Felsch <m.felsch@xxxxxxxxxxxxxx>
> 
> 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
>>
>>
>>




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux