linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: aquantia: return 'err' if set MPI_DEINIT state fails
@ 2018-11-24 10:16 YueHaibing
  2018-11-27 23:25 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: YueHaibing @ 2018-11-24 10:16 UTC (permalink / raw)
  To: davem, igor.russkikh, nikita.danilov, yana.esina
  Cc: linux-kernel, netdev, YueHaibing

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c:260:7:
 warning: variable 'err' set but not used [-Wunused-but-set-variable]

'err' should be returned while set MPI_DEINIT state fails
in hw_atl_utils_soft_reset.

Fixes: cce96d1883da ("net: aquantia: Regression on reset with 1.x firmware")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
index 1af6606..9b74a31 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
@@ -263,6 +263,8 @@ int hw_atl_utils_soft_reset(struct aq_hw_s *self)
 		AQ_HW_WAIT_FOR((aq_hw_read_reg(self, HW_ATL_MPI_STATE_ADR) &
 				HW_ATL_MPI_STATE_MSK) == MPI_DEINIT,
 			       10, 1000U);
+		if (err)
+			return err;
 	}
 
 	if (self->rbl_enabled)
-- 
2.7.0



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

* Re: [PATCH net-next] net: aquantia: return 'err' if set MPI_DEINIT state fails
  2018-11-24 10:16 [PATCH net-next] net: aquantia: return 'err' if set MPI_DEINIT state fails YueHaibing
@ 2018-11-27 23:25 ` David Miller
  2018-11-28  9:40   ` Igor Russkikh
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2018-11-27 23:25 UTC (permalink / raw)
  To: yuehaibing
  Cc: igor.russkikh, nikita.danilov, yana.esina, linux-kernel, netdev

From: YueHaibing <yuehaibing@huawei.com>
Date: Sat, 24 Nov 2018 18:16:41 +0800

> Fixes gcc '-Wunused-but-set-variable' warning:
> 
> drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c:260:7:
>  warning: variable 'err' set but not used [-Wunused-but-set-variable]
> 
> 'err' should be returned while set MPI_DEINIT state fails
> in hw_atl_utils_soft_reset.
> 
> Fixes: cce96d1883da ("net: aquantia: Regression on reset with 1.x firmware")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Applied.

But this AQ_HW_STATE_FOR macro _MUST_ be fixed.

No macro should have invisible references to variables like this, and
that is exactly what leads to bugs like this.  CPP macros written this
way make it impossible to properly audit code.

'err' should be an explicit argument given to this function instead of
how it works now.

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

* Re: [PATCH net-next] net: aquantia: return 'err' if set MPI_DEINIT state fails
  2018-11-27 23:25 ` David Miller
@ 2018-11-28  9:40   ` Igor Russkikh
  0 siblings, 0 replies; 3+ messages in thread
From: Igor Russkikh @ 2018-11-28  9:40 UTC (permalink / raw)
  To: David Miller, yuehaibing; +Cc: Nikita Danilov, linux-kernel, netdev


>> drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c:260:7:
>>  warning: variable 'err' set but not used [-Wunused-but-set-variable]
>>
>> 'err' should be returned while set MPI_DEINIT state fails
>> in hw_atl_utils_soft_reset.
>>
>> Fixes: cce96d1883da ("net: aquantia: Regression on reset with 1.x firmware")
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> 
> Applied.
> 
> But this AQ_HW_STATE_FOR macro _MUST_ be fixed.
> 
> No macro should have invisible references to variables like this, and
> that is exactly what leads to bugs like this.  CPP macros written this
> way make it impossible to properly audit code.
> 
> 'err' should be an explicit argument given to this function instead of
> how it works now.

Hi David,

Agreed, I'll clean this up.

Regards,
  Igor

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

end of thread, other threads:[~2018-11-28  9:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-24 10:16 [PATCH net-next] net: aquantia: return 'err' if set MPI_DEINIT state fails YueHaibing
2018-11-27 23:25 ` David Miller
2018-11-28  9:40   ` Igor Russkikh

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).