mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [Patch] Signedness issue in drivers/net/3c515.c
@ 2006-08-19 17:37 Eric Sesterhenn
  2006-08-20 18:22 ` Alan Cox
  2006-08-21 21:05 ` Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: Eric Sesterhenn @ 2006-08-19 17:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: becker

hi,

while playing with gcc 4.1 -Wextra warnings, I came across this one:

drivers/net/3c515.c:1027: warning: comparison of unsigned expression >= 0 is always true

Since i is unsigned the >= 0 check in the for loop is always true,
so we might spin there forever unless the if condition triggers.
Since i is only used in this loop, this patch changes it to
an integer.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.18-rc4/drivers/net/3c515.c.orig	2006-08-19 19:35:04.000000000 +0200
+++ linux-2.6.18-rc4/drivers/net/3c515.c	2006-08-19 19:35:14.000000000 +0200
@@ -1003,7 +1003,8 @@ static int corkscrew_start_xmit(struct s
 		/* Calculate the next Tx descriptor entry. */
 		int entry = vp->cur_tx % TX_RING_SIZE;
 		struct boom_tx_desc *prev_entry;
-		unsigned long flags, i;
+		unsigned long flags;
+		int i;
 
 		if (vp->tx_full)	/* No room to transmit with */
 			return 1;



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

* Re: [Patch] Signedness issue in drivers/net/3c515.c
  2006-08-19 17:37 [Patch] Signedness issue in drivers/net/3c515.c Eric Sesterhenn
@ 2006-08-20 18:22 ` Alan Cox
  2006-08-21 21:05 ` Andrew Morton
  1 sibling, 0 replies; 4+ messages in thread
From: Alan Cox @ 2006-08-20 18:22 UTC (permalink / raw)
  To: Eric Sesterhenn; +Cc: linux-kernel, becker, jgarzik

Ar Sad, 2006-08-19 am 19:37 +0200, ysgrifennodd Eric Sesterhenn:
> hi,
> 
> while playing with gcc 4.1 -Wextra warnings, I came across this one:
> 
> drivers/net/3c515.c:1027: warning: comparison of unsigned expression >= 0 is always true
> 
> Since i is unsigned the >= 0 check in the for loop is always true,
> so we might spin there forever unless the if condition triggers.
> Since i is only used in this loop, this patch changes it to
> an integer.
> 
> Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
> 

Acked-by: Alan Cox <alan@redhat.com>

[And put JG on the Cc:]

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

* Re: [Patch] Signedness issue in drivers/net/3c515.c
  2006-08-19 17:37 [Patch] Signedness issue in drivers/net/3c515.c Eric Sesterhenn
  2006-08-20 18:22 ` Alan Cox
@ 2006-08-21 21:05 ` Andrew Morton
  2006-08-21 22:13   ` Alan Cox
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2006-08-21 21:05 UTC (permalink / raw)
  To: Eric Sesterhenn; +Cc: linux-kernel, netdev, Jeff Garzik

On Sat, 19 Aug 2006 19:37:57 +0200
Eric Sesterhenn <snakebyte@gmx.de> wrote:

> while playing with gcc 4.1 -Wextra warnings, I came across this one:
> 
> drivers/net/3c515.c:1027: warning: comparison of unsigned expression >= 0 is always true
> 
> Since i is unsigned the >= 0 check in the for loop is always true,
> so we might spin there forever unless the if condition triggers.
> Since i is only used in this loop, this patch changes it to
> an integer.
> 
> Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
> 
> --- linux-2.6.18-rc4/drivers/net/3c515.c.orig	2006-08-19 19:35:04.000000000 +0200
> +++ linux-2.6.18-rc4/drivers/net/3c515.c	2006-08-19 19:35:14.000000000 +0200
> @@ -1003,7 +1003,8 @@ static int corkscrew_start_xmit(struct s
>  		/* Calculate the next Tx descriptor entry. */
>  		int entry = vp->cur_tx % TX_RING_SIZE;
>  		struct boom_tx_desc *prev_entry;
> -		unsigned long flags, i;
> +		unsigned long flags;
> +		int i;
>  
>  		if (vp->tx_full)	/* No room to transmit with */
>  			return 1;

Which affects this loop:

	/* Wait for the stall to complete. */
	for (i = 20; i >= 0; i--)
		if ((inw(ioaddr + EL3_STATUS) & CmdInProgress) == 0) 
			break;

Your fix will convert this indefinit wait into a bounded one.  It might
cause the driver to malfunction.

Given that our pool of 3c515 testers is less than enormous, a more prudent
change might be to remove `i' and simply formalise the existing behaviour
into a while(1) loop.


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

* Re: [Patch] Signedness issue in drivers/net/3c515.c
  2006-08-21 21:05 ` Andrew Morton
@ 2006-08-21 22:13   ` Alan Cox
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Cox @ 2006-08-21 22:13 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Eric Sesterhenn, linux-kernel, netdev, Jeff Garzik

Ar Llu, 2006-08-21 am 14:05 -0700, ysgrifennodd Andrew Morton:
> 	/* Wait for the stall to complete. */
> 	for (i = 20; i >= 0; i--)
> 		if ((inw(ioaddr + EL3_STATUS) & CmdInProgress) == 0) 
> 			break;
> 
> Your fix will convert this indefinit wait into a bounded one.  It might
> cause the driver to malfunction.

The change is correct. The docs guarantee it can't take that long.


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

end of thread, other threads:[~2006-08-21 21:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-19 17:37 [Patch] Signedness issue in drivers/net/3c515.c Eric Sesterhenn
2006-08-20 18:22 ` Alan Cox
2006-08-21 21:05 ` Andrew Morton
2006-08-21 22:13   ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome