Skip to contentSkip to conversation

Avoid switch on long long in s2io driver

PATCH In review Andreas Schwab 3 participants 3 messages May 26, 2007 – May 30, 2007

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

PATCH 1/1 Avoid switch on long long in s2io driver

A switch on long long causes gcc to generate a reference to __ucmpdi2 on ppc32. Avoid that by casting to int, since the value is only a small integer anyway.

---
 drivers/net/s2io.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/s2io.c +2 -2
Index: linux-2.6.22-rc1/drivers/net/s2io.c
===================================================================
@@ -2898,7 +2898,7 @@ static void tx_intr_handler(struct fifo_
 
 			/* update t_code statistics */
 			err >>= 48;
-			switch(err) {
+			switch((int)err) {
 				case 2:
 					nic->mac_control.stats_info->sw_stat.
 							tx_buf_abort_cnt++;
@@ -6825,7 +6825,7 @@ static int rx_osm_handler(struct ring_in
 			sp->mac_control.stats_info->sw_stat.parity_err_cnt++;
 		}
 		err >>= 48;
-		switch(err) {
+		switch((int)err) {
 			case 1:
 				sp->mac_control.stats_info->sw_stat.
 				rx_parity_err_cnt++;

Andreas.

Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#1 lore raw
Quoted 15 lines · On Saturday 26 May 2007 10:58:15 Andreas Schwab wrote:

A switch on long long causes gcc to generate a reference to __ucmpdi2 on ppc32. Avoid that by casting to int, since the value is only a small integer anyway.

---
 drivers/net/s2io.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: linux-2.6.22-rc1/drivers/net/s2io.c
===================================================================

drivers/net/s2io.c static void tx_intr_handler(struct fifo_ · line 2901

Quoted 5 lines
drivers/net/s2io.c +1 -1
@@ -2898,7 +2898,7 @@ static void tx_intr_handler(struct fifo_
 
 			/* update t_code statistics */
 			err >>= 48;
-			switch(err) {
+			switch((int)err) {

Hm, maybe add a comment, too?
This cast looks redundant at the first look and someone who doesn't understand it might submit a patch to remove it again.

Quoted 15 lines
drivers/net/s2io.c +1 -1
 				case 2:
 					nic->mac_control.stats_info->sw_stat.
 							tx_buf_abort_cnt++;
@@ -6825,7 +6825,7 @@ static int rx_osm_handler(struct ring_in
 			sp->mac_control.stats_info->sw_stat.parity_err_cnt++;
 		}
 		err >>= 48;
-		switch(err) {
+		switch((int)err) {
 			case 1:
 				sp->mac_control.stats_info->sw_stat.
 				rx_parity_err_cnt++;

Andreas.

Signature · 1 line
Greetings Michael.
#2 lore raw

Patch looks good. Yes, please add a comment as to reason for cast.

Ram

Quoted 2 lines

-----Original Message-----
From: [email protected]

[mailto:[email protected]]

Quoted 8 lines

On Behalf Of Michael Buesch
Sent: Saturday, May 26, 2007 10:04 AM
To: Andreas Schwab
Cc: [email protected]
Subject: Re: [PATCH] Avoid switch on long long in s2io driver

Quoted 1 line · On Saturday 26 May 2007 10:58:15 Andreas Schwab wrote:

A switch on long long causes gcc to generate a reference to

__ucmpdi2 on

Quoted 1 line
Quoted 1 line

ppc32. Avoid that by casting to int, since the value is only a

small

Quoted 8 lines
Quoted 8 lines

integer anyway.

---
 drivers/net/s2io.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 3 lines

Index: linux-2.6.22-rc1/drivers/net/s2io.c
===================================================================
--- linux-2.6.22-rc1.orig/drivers/net/s2io.c 2007-05-13

11:03:28.000000000 +0200

Quoted 1 line

+++ linux-2.6.22-rc1/drivers/net/s2io.c 2007-05-13

12:52:49.000000000

Quoted 14 lines

+0200

drivers/net/s2io.c static void tx_intr_handler(struct fifo_ · line 2901

Quoted 6 lines
drivers/net/s2io.c +1 -1
@@ -2898,7 +2898,7 @@ static void tx_intr_handler(struct fifo_
 
 			/* update t_code statistics */
 			err >>= 48;
-			switch(err) {
+			switch((int)err) {

Hm, maybe add a comment, too?
This cast looks redundant at the first look and someone who doesn't understand it might submit a patch to remove it again.

Quoted 2 lines
(quoted diff) +0 -0
 				case 2:
 

nic->mac_control.stats_info->sw_stat.

Quoted 1 line
Quoted 1 line

tx_buf_abort_cnt++;

Quoted 2 lines

Review static int rx_osm_handler(struct ring_in · line 6825

Quoted 2 lines
(quoted diff) +0 -0
@@ -6825,7 +6825,7 @@ static int rx_osm_handler(struct ring_in
 

sp->mac_control.stats_info->sw_stat.parity_err_cnt++;

Quoted 19 lines
Quoted 10 lines
drivers/net/s2io.c +1 -1
 		}
 		err >>= 48;
-		switch(err) {
+		switch((int)err) {
 			case 1:
 				sp->mac_control.stats_info->sw_stat.
 				rx_parity_err_cnt++;

Andreas.

--
Greetings Michael.
-
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html