From f39973c65f01d768f1d24cadd124ce490b44d263 Mon Sep 17 00:00:00 2001 From: WangYuli Date: Thu, 28 Nov 2024 11:28:51 +0800 Subject: [PATCH] eth: phytmac: phytmac_plat_probe: initialize variable 'ret' when !pdata->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 --- drivers/net/ethernet/phytium/phytmac_platform.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/phytium/phytmac_platform.c b/drivers/net/ethernet/phytium/phytmac_platform.c index 305ff5866e2fe..d98128458b464 100644 --- a/drivers/net/ethernet/phytium/phytmac_platform.c +++ b/drivers/net/ethernet/phytium/phytmac_platform.c @@ -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; } }