Skip to contentSkip to conversation

media: tc358746: Address compiler warnings

PATCH Superseded Sakari Ailus 2 participants 5 messages May 30, 2023 – Jun 1, 2023 Media (V4L/DVB)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: tc358746: Address compiler warnings

Address these compiler warnings by initialising the m_best and p_best values to 0 and 1 respectively (as latter is used as a divisor):

drivers/media/i2c/tc358746.c: In function 'tc358746_find_pll_settings':

Quoted 1 line
Quoted 1 line

drivers/media/i2c/tc358746.c:817:13: warning: 'p_best' is used uninitialized

[-Wuninitialized]

     817 |         u16 p_best, p;
         |             ^~~~~~
Quoted 1 line
Quoted 1 line

drivers/media/i2c/tc358746.c:816:13: warning: 'm_best' is used uninitialized

[-Wuninitialized]

     816 |         u16 m_best, mul;
         |             ^~~~~~
---
 drivers/media/i2c/tc358746.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/i2c/tc358746.c +2 -2
index ec1a193ba161a..25fbce5cabdaa 100644
@@ -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 = 1, p;
 	u8 postdiv;
 
 	if (fout > 1000 * HZ_PER_MHZ) {
Signature · 1 line
2.30.2
#1 lore raw

Hi Sakari,

Hans already sent a patch a few months ago:
- https://lore.kernel.org/linux-media/[email protected]/

It turned out that the compiler had a bug albeit the compiler listed in 'Closes:' is already a gcc-12 and now the warning used is slightly different.

I'm not again the patch but we should point out that this patch is only required to make the compiler happy.

Regards,
Marco

Quoted 39 lines · Sakari Ailus

Address these compiler warnings by initialising the m_best and p_best values to 0 and 1 respectively (as latter is used as a divisor):

   drivers/media/i2c/tc358746.c: In function 'tc358746_find_pll_settings':
Quoted 1 line
Quoted 1 line

drivers/media/i2c/tc358746.c:817:13: warning: 'p_best' is used uninitialized

[-Wuninitialized]

     817 |         u16 p_best, p;
         |             ^~~~~~
Quoted 1 line
Quoted 1 line

drivers/media/i2c/tc358746.c:816:13: warning: 'm_best' is used uninitialized

[-Wuninitialized]

     816 |         u16 m_best, mul;
         |             ^~~~~~
---
 drivers/media/i2c/tc358746.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/i2c/tc358746.c +2 -2
index ec1a193ba161a..25fbce5cabdaa 100644
@@ -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 = 1, p;
 	u8 postdiv;
 
 	if (fout > 1000 * HZ_PER_MHZ) {
Signature · 1 line
2.30.2
#2 lore raw

Hi Marco,

Quoted 11 lines · Marco Felsch

Hi Sakari,

Hans already sent a patch a few months ago:
- https://lore.kernel.org/linux-media/[email protected]/

It turned out that the compiler had a bug albeit the compiler listed in 'Closes:' is already a gcc-12 and now the warning used is slightly different.

I'm not again the patch but we should point out that this patch is only required to make the compiler happy.

Ack, thanks. I'll drop this then. The condition isn't trivial for a compiler to figure out though, even I'm not quite sure this is the case for all parameter values.

Signature · 3 lines
Kind regards,

Sakari Ailus
#3 lore raw
Quoted 12 lines · Sakari Ailus

Hi Marco,

Quoted 9 lines · Marco Felsch

Hi Sakari,

Hans already sent a patch a few months ago:
- https://lore.kernel.org/linux-media/[email protected]/

It turned out that the compiler had a bug albeit the compiler listed in 'Closes:' is already a gcc-12 and now the warning used is slightly different.

Quoted 6 lines
Quoted 2 lines

I'm not again the patch but we should point out that this patch is only required to make the compiler happy.

Ack, thanks. I'll drop this then. The condition isn't trivial for a compiler to figure out though, even I'm not quite sure this is the case for all parameter values.

Hans's patch actually assigns p_best to 0 which isn't a best default value for a divisor.

Signature · 1 line
Sakari Ailus
#4 lore raw

Hi Sakari,

Quoted 13 lines · Sakari Ailus
Quoted 12 lines · Sakari Ailus

Hi Marco,

Quoted 9 lines · Marco Felsch

Hi Sakari,

Hans already sent a patch a few months ago:
- https://lore.kernel.org/linux-media/[email protected]/

It turned out that the compiler had a bug albeit the compiler listed in 'Closes:' is already a gcc-12 and now the warning used is slightly different.

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

I'm not again the patch but we should point out that this patch is only required to make the compiler happy.

Ack, thanks. I'll drop this then. The condition isn't trivial for a compiler to figure out though, even I'm not quite sure this is the case for all parameter values.

I don't want to complain here O:) and as I said we can pick the patch but we should mention that this is a patch for the compiler.

Quoted 2 lines

Hans's patch actually assigns p_best to 0 which isn't a best default value for a divisor.

You're right.

Regards,
Marco