Skip to content

Commit 6e68dae

Browse files
nathanchancetsbogend
authored andcommitted
clk: ralink: mtmips: Fix uninitialized use of ret in mtmips_register_{fixed,factor}_clocks()
Clang warns: drivers/clk/ralink/clk-mtmips.c:309:9: error: variable 'ret' is uninitialized when used here [-Werror,-Wuninitialized] 309 | return ret; | ^~~ drivers/clk/ralink/clk-mtmips.c:285:9: note: initialize the variable 'ret' to silence this warning 285 | int ret, i; | ^ | = 0 drivers/clk/ralink/clk-mtmips.c:359:9: error: variable 'ret' is uninitialized when used here [-Werror,-Wuninitialized] 359 | return ret; | ^~~ drivers/clk/ralink/clk-mtmips.c:335:9: note: initialize the variable 'ret' to silence this warning 335 | int ret, i; | ^ | = 0 2 errors generated. Set ret to the return value of clk_hw_register_fixed_rate() using the PTR_ERR() macro, which ensures ret is not used uninitialized, clearing up the warning. Fixes: 6f3b155 ("clk: ralink: add clock and reset driver for MTMIPS SoCs") Closes: ClangBuiltLinux#1879 Signed-off-by: Nathan Chancellor <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Acked-by: Sergio Paracuellos <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent fd99ac5 commit 6e68dae

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/clk/ralink/clk-mtmips.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ static int mtmips_register_fixed_clocks(struct clk_hw_onecell_data *clk_data,
292292
sclk->parent, 0,
293293
sclk->rate);
294294
if (IS_ERR(sclk->hw)) {
295+
ret = PTR_ERR(sclk->hw);
295296
pr_err("Couldn't register fixed clock %d\n", idx);
296297
goto err_clk_unreg;
297298
}
@@ -342,6 +343,7 @@ static int mtmips_register_factor_clocks(struct clk_hw_onecell_data *clk_data,
342343
sclk->parent, sclk->flags,
343344
sclk->mult, sclk->div);
344345
if (IS_ERR(sclk->hw)) {
346+
ret = PTR_ERR(sclk->hw);
345347
pr_err("Couldn't register factor clock %d\n", idx);
346348
goto err_clk_unreg;
347349
}

0 commit comments

Comments
 (0)