linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [net-next] sfc: avoid an unused-variable warning
@ 2020-05-27 13:41 Arnd Bergmann
  2020-05-28 19:49 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2020-05-27 13:41 UTC (permalink / raw)
  To: Solarflare linux maintainers, Edward Cree, Martin Habets,
	David S. Miller, Jakub Kicinski
  Cc: Arnd Bergmann, Alex Maftei (amaftei), Tom Zhao, netdev, linux-kernel

'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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/sfc/ef10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index e634e8110585..964c5e842cec 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -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) {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] [net-next] sfc: avoid an unused-variable warning
  2020-05-27 13:41 [PATCH] [net-next] sfc: avoid an unused-variable warning Arnd Bergmann
@ 2020-05-28 19:49 ` David Miller
  2020-05-29  0:30   ` Edward Cree
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2020-05-28 19:49 UTC (permalink / raw)
  To: arnd
  Cc: linux-net-drivers, ecree, mhabets, kuba, amaftei, tzhao, netdev,
	linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Wed, 27 May 2020 15:41:06 +0200

> '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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applid, thanks.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [net-next] sfc: avoid an unused-variable warning
  2020-05-28 19:49 ` David Miller
@ 2020-05-29  0:30   ` Edward Cree
  0 siblings, 0 replies; 3+ messages in thread
From: Edward Cree @ 2020-05-29  0:30 UTC (permalink / raw)
  To: David Miller, arnd
  Cc: linux-net-drivers, mhabets, kuba, amaftei, tzhao, netdev, linux-kernel

On 28/05/2020 20:49, David Miller wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> Date: Wed, 27 May 2020 15:41:06 +0200
>
>> '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")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-29  0:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 13:41 [PATCH] [net-next] sfc: avoid an unused-variable warning Arnd Bergmann
2020-05-28 19:49 ` David Miller
2020-05-29  0:30   ` Edward Cree

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).