Skip to contentSkip to conversation

sfc: avoid an unused-variable warning

PATCH In review Arnd Bergmann 3 participants 3 messages May 27, 2020 – May 29, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sfc: avoid an unused-variable warning

'nic_data' is no longer used outside of the #ifdef block in efx_ef10_set_mac_address:

drivers/net/ethernet/sfc/ef10.c:3231:28: error: unused variable 'nic_data' [-Werror,-Wunused-variable]

        struct efx_ef10_nic_data *nic_data = efx->nic_data;

Move the variable into a local scope.

Fixes dfcabb078847 ("sfc: move vport_id to struct efx_nic")
---
 drivers/net/ethernet/sfc/ef10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/sfc/ef10.c +1 -1
index e634e8110585..964c5e842cec 100644
@@ -3228,7 +3228,6 @@ static int efx_ef10_vport_set_mac_address(struct efx_nic *efx)
 static int efx_ef10_set_mac_address(struct efx_nic *efx)
 {
 	MCDI_DECLARE_BUF(inbuf, MC_CMD_VADAPTOR_SET_MAC_IN_LEN);
-	struct efx_ef10_nic_data *nic_data = efx->nic_data;
 	bool was_enabled = efx->port_enabled;
 	int rc;
 
@@ -3256,6 +3255,7 @@ static int efx_ef10_set_mac_address(struct efx_nic *efx)
 
 #ifdef CONFIG_SFC_SRIOV
 	if (efx->pci_dev->is_virtfn && efx->pci_dev->physfn) {
+		struct efx_ef10_nic_data *nic_data = efx->nic_data;
 		struct pci_dev *pci_dev_pf = efx->pci_dev->physfn;
 
 		if (rc == -EPERM) {
Signature · 1 line
2.26.2
#1 lore raw

From: Arnd Bergmann <[email protected]>
Date: Wed, 27 May 2020 15:41:06 +0200

Quoted 10 lines

'nic_data' is no longer used outside of the #ifdef block in efx_ef10_set_mac_address:

drivers/net/ethernet/sfc/ef10.c:3231:28: error: unused variable 'nic_data' [-Werror,-Wunused-variable]

        struct efx_ef10_nic_data *nic_data = efx->nic_data;

Move the variable into a local scope.

Fixes dfcabb078847 ("sfc: move vport_id to struct efx_nic")

Applid, thanks.

#2 lore raw
Quoted 6 lines · David Miller

From: Arnd Bergmann <[email protected]>
Date: Wed, 27 May 2020 15:41:06 +0200

Quoted 3 lines

'nic_data' is no longer used outside of the #ifdef block in efx_ef10_set_mac_address:

Quoted 8 lines
Quoted 7 lines

drivers/net/ethernet/sfc/ef10.c:3231:28: error: unused variable 'nic_data' [-Werror,-Wunused-variable]

        struct efx_ef10_nic_data *nic_data = efx->nic_data;

Move the variable into a local scope.

Fixes dfcabb078847 ("sfc: move vport_id to struct efx_nic")

Applid, thanks.

Sorry I didn't see the original patch (I think it disappeared into a mail outage).  Fix is good, but I think we can improve the code further by moving the declaration down another block, into the 'if (rc == -EPERM)', at which point it is no longer shadowed by the other nic_data declaration in the 'else if (!rc)' block.
Alternatively, we could rename the latter to 'pf_nic_data' or something.  Any opinions/preferences on which way to go?  We could even do both...
When I make up my mind I'll spin an incremental patch.

-ed