Skip to contentSkip to conversation

e1000 C style badness

PATCH Patrizio Bassi 3 participants 4 messages Jan 18, 2006 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Jens Axboe ha scritto:

Quoted 26 lines

Hi,

Recent e1000 updates introduced variable declarations after code. Fix those up again.

drivers/net/e1000/e1000_main.c +3 -1
index d0a5d16..ca68a04 100644
@@ -2142,9 +2142,11 @@ e1000_leave_82542_rst(struct e1000_adapt
 		e1000_pci_set_mwi(&adapter->hw);
 
 	if(netif_running(netdev)) {
+		struct e1000_rx_ring *ring;
+
 		e1000_configure_rx(adapter);
 		/* No need to loop, because 82542 supports only 1 queue */
-		struct e1000_rx_ring *ring = &adapter->rx_ring[0];
+		ring = &adapter->rx_ring[0];
 		adapter->alloc_rx_buf(adapter, ring, E1000_DESC_UNUSED(ring));
 	}
 }

drivers/net/e1000/e1000_main.c e1000_clean_rx_irq(struct e1000_adapter · line 3592

Quoted 9 lines
drivers/net/e1000/e1000_main.c +1 -1
@@ -3583,8 +3585,8 @@ e1000_clean_rx_irq(struct e1000_adapter 
 	rx_desc = E1000_RX_DESC(*rx_ring, i);
 
 	while(rx_desc->status & E1000_RXD_STAT_DD) {
-		buffer_info = &rx_ring->buffer_info[i];
 		u8 status;
+		buffer_info = &rx_ring->buffer_info[i];
 #ifdef CONFIG_E1000_NAPI
 		if(*work_done >= work_to_do)
 			break;

Shouldn't variables declaration be on top of function and not on top of a block (like if, while, for...)?

--
Patrizio Bassi
www.patriziobassi.it

#2 lore raw
Quoted 28 lines · Patrizio Bassi

Jens Axboe ha scritto:

Quoted 27 lines

Hi,

Recent e1000 updates introduced variable declarations after code. Fix those up again.

drivers/net/e1000/e1000_main.c +3 -1
index d0a5d16..ca68a04 100644
@@ -2142,9 +2142,11 @@ e1000_leave_82542_rst(struct e1000_adapt
 		e1000_pci_set_mwi(&adapter->hw);
 
 	if(netif_running(netdev)) {
+		struct e1000_rx_ring *ring;
+
 		e1000_configure_rx(adapter);
 		/* No need to loop, because 82542 supports only 1 queue */
-		struct e1000_rx_ring *ring = &adapter->rx_ring[0];
+		ring = &adapter->rx_ring[0];
 		adapter->alloc_rx_buf(adapter, ring, E1000_DESC_UNUSED(ring));
 	}
 }
@@ -3583,8 +3585,8 @@ e1000_clean_rx_irq(struct e1000_adapter 
 	rx_desc = E1000_RX_DESC(*rx_ring, i);
 
Quoted 11 lines

drivers/net/e1000/e1000_main.c e1000_clean_rx_irq(struct e1000_adapter · line 3592

Quoted 8 lines
drivers/net/e1000/e1000_main.c +1 -1
 	while(rx_desc->status & E1000_RXD_STAT_DD) {
-		buffer_info = &rx_ring->buffer_info[i];
 		u8 status;
+		buffer_info = &rx_ring->buffer_info[i];
 #ifdef CONFIG_E1000_NAPI
 		if(*work_done >= work_to_do)
 			break;

Shouldn't variables declaration be on top of function and not on top of a block (like if, while, for...)?

No, that's not necessary. But they should be before actual code inside that block.

Signature · 1 line
Jens Axboe
#3 lore raw
In reply to Patrizio Bassi
Quoted 29 lines · Patrizio Bassi

Jens Axboe ha scritto:

Quoted 27 lines

Hi,

Recent e1000 updates introduced variable declarations after code. Fix those up again.

drivers/net/e1000/e1000_main.c +3 -1
index d0a5d16..ca68a04 100644
@@ -2142,9 +2142,11 @@ e1000_leave_82542_rst(struct e1000_adapt
 		e1000_pci_set_mwi(&adapter->hw);
 
 	if(netif_running(netdev)) {
+		struct e1000_rx_ring *ring;
+
 		e1000_configure_rx(adapter);
 		/* No need to loop, because 82542 supports only 1 queue */
-		struct e1000_rx_ring *ring = &adapter->rx_ring[0];
+		ring = &adapter->rx_ring[0];
 		adapter->alloc_rx_buf(adapter, ring, E1000_DESC_UNUSED(ring));
 	}
 }
@@ -3583,8 +3585,8 @@ e1000_clean_rx_irq(struct e1000_adapter 
 	rx_desc = E1000_RX_DESC(*rx_ring, i);
 
Quoted 13 lines

drivers/net/e1000/e1000_main.c e1000_clean_rx_irq(struct e1000_adapter · line 3592

Quoted 8 lines
drivers/net/e1000/e1000_main.c +1 -1
 	while(rx_desc->status & E1000_RXD_STAT_DD) {
-		buffer_info = &rx_ring->buffer_info[i];
 		u8 status;
+		buffer_info = &rx_ring->buffer_info[i];
 #ifdef CONFIG_E1000_NAPI
 		if(*work_done >= work_to_do)
 			break;

Shouldn't variables declaration be on top of function and not on top of a block (like if, while, for...)?

Any block is OK, and they all have the same nice symmetry - variables come into scope at the top and go out of scope at the bottom.

Signature · 2 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 
#4 lore raw

Nick Piggin ha scritto:

Quoted 45 lines
Quoted 30 lines · Patrizio Bassi

Jens Axboe ha scritto:

Quoted 28 lines

Hi,

Recent e1000 updates introduced variable declarations after code. Fix those up again.

drivers/net/e1000/e1000_main.c +3 -1
index d0a5d16..ca68a04 100644
@@ -2142,9 +2142,11 @@ e1000_leave_82542_rst(struct e1000_adapt
        e1000_pci_set_mwi(&adapter->hw);
 
    if(netif_running(netdev)) {
+        struct e1000_rx_ring *ring;
+
        e1000_configure_rx(adapter);
        /* No need to loop, because 82542 supports only 1 queue */
-        struct e1000_rx_ring *ring = &adapter->rx_ring[0];
+        ring = &adapter->rx_ring[0];
        adapter->alloc_rx_buf(adapter, ring, E1000_DESC_UNUSED(ring));
    }
 }
@@ -3583,8 +3585,8 @@ e1000_clean_rx_irq(struct e1000_adapter
    rx_desc = E1000_RX_DESC(*rx_ring, i);
 
Quoted 13 lines

drivers/net/e1000/e1000_main.c e1000_clean_rx_irq(struct e1000_adapter · line 3592

Quoted 8 lines
drivers/net/e1000/e1000_main.c +1 -1
    while(rx_desc->status & E1000_RXD_STAT_DD) {
-        buffer_info = &rx_ring->buffer_info[i];
        u8 status;
+        buffer_info = &rx_ring->buffer_info[i];
 #ifdef CONFIG_E1000_NAPI
        if(*work_done >= work_to_do)
            break;

Shouldn't variables declaration be on top of function and not on top of a block (like if, while, for...)?

Quoted 3 lines

Any block is OK, and they all have the same nice symmetry - variables come into scope at the top and go out of scope at the bottom.

ok, i'm still linked to the 70' C style (not confortable) :) old compilers failed with such syntax.