Skip to content

Commit

Permalink
eth: yt6801: initialize variable 'pcie_msi_mask_bits' when pcie_cap_o…
Browse files Browse the repository at this point in the history
…ffset

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 <[email protected]>
  • Loading branch information
Avenger-285714 committed Nov 28, 2024
1 parent 1324943 commit 3be1423
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3be1423

Please sign in to comment.