net: sparx5: Do not use mac_addr uninitialized in mchp_sparx5_probe()

Clang warns:

drivers/net/ethernet/microchip/sparx5/sparx5_main.c:760:29: warning:
variable 'mac_addr' is uninitialized when used here [-Wuninitialized]
        if (of_get_mac_address(np, mac_addr)) {
                                   ^~~~~~~~
drivers/net/ethernet/microchip/sparx5/sparx5_main.c:669:14: note:
initialize the variable 'mac_addr' to silence this warning
        u8 *mac_addr;
                    ^
                     = NULL
1 warning generated.

mac_addr is only used to store the value retrieved from
of_get_mac_address(), which is then copied into the base_mac member of
the sparx5 struct using ether_addr_copy(). It is easier to just use the
base_mac address directly, which avoids the warning and the extra copy.

Fixes: 3cfa11bac9 ("net: sparx5: add the basic sparx5 driver")
Link: https://github.com/ClangBuiltLinux/linux/issues/1413
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Nathan Chancellor 2021-06-27 11:45:43 -07:00 committed by David S. Miller
parent 74e7feff0e
commit b74ef9f9cb
1 changed files with 1 additions and 4 deletions

View File

@ -670,7 +670,6 @@ static int mchp_sparx5_probe(struct platform_device *pdev)
struct reset_control *reset;
struct sparx5 *sparx5;
int idx = 0, err = 0;
u8 *mac_addr;
if (!np && !pdev->dev.platform_data)
return -ENODEV;
@ -761,12 +760,10 @@ static int mchp_sparx5_probe(struct platform_device *pdev)
if (err)
goto cleanup_config;
if (of_get_mac_address(np, mac_addr)) {
if (!of_get_mac_address(np, sparx5->base_mac)) {
dev_info(sparx5->dev, "MAC addr was not set, use random MAC\n");
eth_random_addr(sparx5->base_mac);
sparx5->base_mac[5] = 0;
} else {
ether_addr_copy(sparx5->base_mac, mac_addr);
}
sparx5->xtr_irq = platform_get_irq_byname(sparx5->pdev, "xtr");