From 3be1423d976560b8cdd79299507c54a13abdf50f Mon Sep 17 00:00:00 2001 From: WangYuli Date: Thu, 28 Nov 2024 15:44:40 +0800 Subject: [PATCH] eth: yt6801: initialize variable 'pcie_msi_mask_bits' when pcie_cap_offset Fix follow errors with clang-19: drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-net.c:983:6: error: variable 'pcie_msi_mask_bits' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] 983 | if (pcie_cap_offset) { | ^~~~~~~~~~~~~~~ drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-net.c:994:43: note: uninitialized use occurs here 994 | pcie_msi_mask_bits = FXGMAC_SET_REG_BITS(pcie_msi_mask_bits, | ^~~~~~~~~~~~~~~~~~ drivers/net/ethernet/motorcomm/yt6801/fuxi-os.h:189:22: note: expanded from macro 'FXGMAC_SET_REG_BITS' 189 | typeof(var) _var = (var); \ | ^~~ drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-net.c:983:2: note: remove the 'if' if its condition is always true 983 | if (pcie_cap_offset) { | ^~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-net.c:979:24: note: initialize the variable 'pcie_msi_mask_bits' to silence this warning 979 | u32 pcie_msi_mask_bits; | ^ | = 0 drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-net.c:1014:6: error: variable 'pcie_msi_mask_bits' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] 1014 | if (pcie_cap_offset) { | ^~~~~~~~~~~~~~~ drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-net.c:1025:43: note: uninitialized use occurs here 1025 | pcie_msi_mask_bits = FXGMAC_SET_REG_BITS(pcie_msi_mask_bits, | ^~~~~~~~~~~~~~~~~~ drivers/net/ethernet/motorcomm/yt6801/fuxi-os.h:189:22: note: expanded from macro 'FXGMAC_SET_REG_BITS' 189 | typeof(var) _var = (var); \ | ^~~ drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-net.c:1014:2: note: remove the 'if' if its condition is always true 1014 | if (pcie_cap_offset) { | ^~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-net.c:1010:24: note: initialize the variable 'pcie_msi_mask_bits' to silence this warning 1010 | u32 pcie_msi_mask_bits; | ^ | = 0 2 errors generated. Signed-off-by: WangYuli --- drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-net.c b/drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-net.c index b8734efb36426..0ae527a068388 100644 --- a/drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-net.c +++ b/drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-net.c @@ -976,7 +976,7 @@ void fxgmac_free_rx_data(struct fxgmac_pdata *pdata) static int fxgmac_disable_pci_msi_config(struct pci_dev *pdev) { u16 pcie_cap_offset; - u32 pcie_msi_mask_bits; + u32 pcie_msi_mask_bits = 0; int ret = 0; pcie_cap_offset = pci_find_capability(pdev, PCI_CAP_ID_MSI); @@ -1007,7 +1007,7 @@ static int fxgmac_disable_pci_msi_config(struct pci_dev *pdev) static int fxgmac_disable_pci_msix_config(struct pci_dev *pdev) { u16 pcie_cap_offset; - u32 pcie_msi_mask_bits; + u32 pcie_msi_mask_bits = 0; int ret = 0; pcie_cap_offset = pci_find_capability(pdev, PCI_CAP_ID_MSIX);