Skip to content

Commit

Permalink
eth: phytmac: phytmac_plat_probe: initialize variable 'ret' when !pda…
Browse files Browse the repository at this point in the history
…ta->msg_regs

Fix follow error with clang-19:

drivers/net/ethernet/phytium/phytmac_platform.c:130:8: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
  130 |                         if (!pdata->msg_regs) {
      |                             ^~~~~~~~~~~~~~~~
drivers/net/ethernet/phytium/phytmac_platform.c:202:9: note: uninitialized use occurs here
  202 |         return ret;
      |                ^~~
drivers/net/ethernet/phytium/phytmac_platform.c:130:4: note: remove the 'if' if its condition is always false
  130 |                         if (!pdata->msg_regs) {
      |                         ^~~~~~~~~~~~~~~~~~~~~~~
  131 |                                 dev_err(&pdev->dev, "msg_regs ioremap failed, i=%d\n", i);
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  132 |                                 goto err_mem;
      |                                 ~~~~~~~~~~~~~
  133 |                         }
      |                         ~
drivers/net/ethernet/phytium/phytmac_platform.c:81:9: note: initialize the variable 'ret' to silence this warning
   81 |         int ret, i;
      |                ^
      |                 = 0
1 error generated.

Signed-off-by: WangYuli <[email protected]>
  • Loading branch information
Avenger-285714 committed Nov 28, 2024
1 parent e7ea92b commit f39973c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/net/ethernet/phytium/phytmac_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ static int phytmac_plat_probe(struct platform_device *pdev)
pdata->msg_regs = ioremap_wt(regs->start, MEMORY_SIZE);
if (!pdata->msg_regs) {
dev_err(&pdev->dev, "msg_regs ioremap failed, i=%d\n", i);
ret = PTR_ERR(pdata->mac_regs);
goto err_mem;
}
}
Expand Down

0 comments on commit f39973c

Please sign in to comment.