Skip to contentSkip to conversation

clk: mediatek: fix cppcheck error for uninitialized variable

PATCH In review 2 participants 2 messages Dec 25, 2023 – Jan 2, 2024

Subsystems (2)
lore
Share & tools
lore

#0 lore raw

PATCH 1/1 clk: mediatek: fix cppcheck error for uninitialized variable

From: Kishan Dudhatra <[email protected]>

cppcheck reports below warning

clk/mediatek/clk-fhctl.c:206:27:
error: Uninitialized variable: pll_postdiv [uninitvar] if (postdiv && postdiv < pll_postdiv)

This is due to uninitialization of variable pll_postdiv, which is now initialized as part of this patch.

drivers/clk/mediatek/clk-fhctl.c +1 -1
index 33b6ad8fdc2e..b0e71e4fd938 100644
@@ -186,7 +186,7 @@ static int fhctl_hopping(struct mtk_fh *fh, unsigned int new_dds,
 	struct fh_pll_regs *regs = &fh->regs;
 	struct mtk_clk_pll *pll = &fh->clk_pll;
 	spinlock_t *lock = fh->lock;
-	unsigned int pll_postdiv;
+	unsigned int pll_postdiv = 0;
 	unsigned long flags = 0;
 	int ret;
 
Signature · 1 line
2.25.1
#1 lore raw

Il 25/12/23 16:28, ha scritto:

Quoted 4 lines

From: Kishan Dudhatra <[email protected]>

cppcheck reports below warning

Quoted 8 lines

clk/mediatek/clk-fhctl.c:206:27:
error: Uninitialized variable: pll_postdiv [uninitvar] if (postdiv && postdiv < pll_postdiv)

This is due to uninitialization of variable pll_postdiv, which is now initialized as part of this patch.

This is a false positive... the pll_postdiv variable is *always* used and *only if* postdiv > 0.

P.S.: There was some problem with your email, as the From entry is empty.

Regards,
Angelo

Quoted 14 lines
drivers/clk/mediatek/clk-fhctl.c +1 -1
index 33b6ad8fdc2e..b0e71e4fd938 100644
@@ -186,7 +186,7 @@ static int fhctl_hopping(struct mtk_fh *fh, unsigned int new_dds,
  	struct fh_pll_regs *regs = &fh->regs;
  	struct mtk_clk_pll *pll = &fh->clk_pll;
  	spinlock_t *lock = fh->lock;
-	unsigned int pll_postdiv;
+	unsigned int pll_postdiv = 0;
  	unsigned long flags = 0;
  	int ret;