All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: sfc: avoid -Wtype-limits warning
@ 2016-06-15 20:31 Arnd Bergmann
  2016-06-16 10:31 ` Bert Kenward
  2016-06-16 21:24 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2016-06-15 20:31 UTC (permalink / raw)
  To: Solarflare linux maintainers, Edward Cree, Bert Kenward
  Cc: Arnd Bergmann, David S. Miller, Martin Habets, netdev, linux-kernel

When building with -Wextra, we get a harmless warning from the
EFX_EXTRACT_OWORD32 macro:

ethernet/sfc/farch.c: In function 'efx_farch_test_registers':
ethernet/sfc/farch.c:119:30: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
ethernet/sfc/farch.c:124:144: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
ethernet/sfc/farch.c:124:392: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
ethernet/sfc/farch.c:124:731: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]

The macro and the caller are both correct, but we can avoid the
warning by changing the index variable to a signed type.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/sfc/farch.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/sfc/farch.c b/drivers/net/ethernet/sfc/farch.c
index 133e9e35be9e..4c83739d158f 100644
--- a/drivers/net/ethernet/sfc/farch.c
+++ b/drivers/net/ethernet/sfc/farch.c
@@ -104,7 +104,8 @@ int efx_farch_test_registers(struct efx_nic *efx,
 			     const struct efx_farch_register_test *regs,
 			     size_t n_regs)
 {
-	unsigned address = 0, i, j;
+	unsigned address = 0;
+	int i, j;
 	efx_oword_t mask, imask, original, reg, buf;
 
 	for (i = 0; i < n_regs; ++i) {
-- 
2.9.0

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

* Re: [PATCH] net: sfc: avoid -Wtype-limits warning
  2016-06-15 20:31 [PATCH] net: sfc: avoid -Wtype-limits warning Arnd Bergmann
@ 2016-06-16 10:31 ` Bert Kenward
  2016-06-16 21:24 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Bert Kenward @ 2016-06-16 10:31 UTC (permalink / raw)
  To: Arnd Bergmann, Solarflare linux maintainers, Edward Cree
  Cc: David S. Miller, Martin Habets, netdev, linux-kernel

On 15/06/16 21:31, Arnd Bergmann wrote:
> When building with -Wextra, we get a harmless warning from the
> EFX_EXTRACT_OWORD32 macro:
> 
> ethernet/sfc/farch.c: In function 'efx_farch_test_registers':
> ethernet/sfc/farch.c:119:30: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
> ethernet/sfc/farch.c:124:144: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
> ethernet/sfc/farch.c:124:392: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
> ethernet/sfc/farch.c:124:731: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
> 
> The macro and the caller are both correct, but we can avoid the
> warning by changing the index variable to a signed type.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Bert Kenward <bkenward@solarflare.com>

> ---
>  drivers/net/ethernet/sfc/farch.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/sfc/farch.c b/drivers/net/ethernet/sfc/farch.c
> index 133e9e35be9e..4c83739d158f 100644
> --- a/drivers/net/ethernet/sfc/farch.c
> +++ b/drivers/net/ethernet/sfc/farch.c
> @@ -104,7 +104,8 @@ int efx_farch_test_registers(struct efx_nic *efx,
>  			     const struct efx_farch_register_test *regs,
>  			     size_t n_regs)
>  {
> -	unsigned address = 0, i, j;
> +	unsigned address = 0;
> +	int i, j;
>  	efx_oword_t mask, imask, original, reg, buf;
>  
>  	for (i = 0; i < n_regs; ++i) {
> 

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

* Re: [PATCH] net: sfc: avoid -Wtype-limits warning
  2016-06-15 20:31 [PATCH] net: sfc: avoid -Wtype-limits warning Arnd Bergmann
  2016-06-16 10:31 ` Bert Kenward
@ 2016-06-16 21:24 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-06-16 21:24 UTC (permalink / raw)
  To: arnd; +Cc: linux-net-drivers, ecree, bkenward, mhabets, netdev, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Wed, 15 Jun 2016 22:31:10 +0200

> When building with -Wextra, we get a harmless warning from the
> EFX_EXTRACT_OWORD32 macro:
> 
> ethernet/sfc/farch.c: In function 'efx_farch_test_registers':
> ethernet/sfc/farch.c:119:30: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
> ethernet/sfc/farch.c:124:144: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
> ethernet/sfc/farch.c:124:392: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
> ethernet/sfc/farch.c:124:731: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
> 
> The macro and the caller are both correct, but we can avoid the
> warning by changing the index variable to a signed type.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied, thanks.

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

end of thread, other threads:[~2016-06-16 21:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-15 20:31 [PATCH] net: sfc: avoid -Wtype-limits warning Arnd Bergmann
2016-06-16 10:31 ` Bert Kenward
2016-06-16 21:24 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.