All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] bonding: More ether_addr_copy and neatenings.
@ 2014-02-18 17:42 Joe Perches
  2014-02-18 17:42 ` [PATCH net-next 1/3] bonding: More use of ether_addr_copy Joe Perches
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Joe Perches @ 2014-02-18 17:42 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel

Joe Perches (3):
  bonding: More use of ether_addr_copy
  bonding: Remove unnecessary else
  bonding: Invert test

 drivers/net/bonding/bond_3ad.c  | 21 ++++++++++-----------
 drivers/net/bonding/bond_alb.c  | 17 ++++++++---------
 drivers/net/bonding/bond_main.c |  6 +++---
 3 files changed, 21 insertions(+), 23 deletions(-)

-- 
1.8.1.2.459.gbcd45b4.dirty


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

* [PATCH net-next 1/3] bonding: More use of ether_addr_copy
  2014-02-18 17:42 [PATCH net-next 0/3] bonding: More ether_addr_copy and neatenings Joe Perches
@ 2014-02-18 17:42 ` Joe Perches
  2014-02-18 17:42 ` [PATCH net-next 2/3] bonding: Remove unnecessary else Joe Perches
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2014-02-18 17:42 UTC (permalink / raw)
  To: netdev; +Cc: Jay Vosburgh, Veaceslav Falico, Andy Gospodarek, linux-kernel

It's smaller and faster for some architectures.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/bonding/bond_3ad.c  | 4 ++--
 drivers/net/bonding/bond_alb.c  | 5 ++---
 drivers/net/bonding/bond_main.c | 6 +++---
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index e9edd84..7cb51f9 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -2386,8 +2386,8 @@ int __bond_3ad_get_active_agg_info(struct bonding *bond,
 		ad_info->ports = aggregator->num_of_ports;
 		ad_info->actor_key = aggregator->actor_oper_aggregator_key;
 		ad_info->partner_key = aggregator->partner_oper_aggregator_key;
-		memcpy(ad_info->partner_system,
-		       aggregator->partner_system.mac_addr_value, ETH_ALEN);
+		ether_addr_copy(ad_info->partner_system,
+				aggregator->partner_system.mac_addr_value);
 		return 0;
 	}
 
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 538913e..97a43a20 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -1449,9 +1449,8 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
 
 	if (tx_slave && SLAVE_IS_OK(tx_slave)) {
 		if (tx_slave != rcu_dereference(bond->curr_active_slave)) {
-			memcpy(eth_data->h_source,
-			       tx_slave->dev->dev_addr,
-			       ETH_ALEN);
+			ether_addr_copy(eth_data->h_source,
+					tx_slave->dev->dev_addr);
 		}
 
 		bond_dev_queue_xmit(bond, skb, tx_slave->dev);
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 3bce855..4690b11 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -674,8 +674,8 @@ static void bond_do_fail_over_mac(struct bonding *bond,
 
 		if (old_active) {
 			ether_addr_copy(tmp_mac, new_active->dev->dev_addr);
-			memcpy(saddr.sa_data, old_active->dev->dev_addr,
-			       ETH_ALEN);
+			ether_addr_copy(saddr.sa_data,
+					old_active->dev->dev_addr);
 			saddr.sa_family = new_active->dev->type;
 		} else {
 			ether_addr_copy(saddr.sa_data, bond->dev->dev_addr);
@@ -1142,7 +1142,7 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
 			kfree_skb(skb);
 			return RX_HANDLER_CONSUMED;
 		}
-		memcpy(eth_hdr(skb)->h_dest, bond->dev->dev_addr, ETH_ALEN);
+		ether_addr_copy(eth_hdr(skb)->h_dest, bond->dev->dev_addr);
 	}
 
 	return ret;
-- 
1.8.1.2.459.gbcd45b4.dirty


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

* [PATCH net-next 2/3] bonding: Remove unnecessary else
  2014-02-18 17:42 [PATCH net-next 0/3] bonding: More ether_addr_copy and neatenings Joe Perches
  2014-02-18 17:42 ` [PATCH net-next 1/3] bonding: More use of ether_addr_copy Joe Perches
@ 2014-02-18 17:42 ` Joe Perches
  2014-02-18 17:42 ` [PATCH net-next 3/3] bonding: Invert test Joe Perches
  2014-02-19  1:44 ` [PATCH net-next 0/3] bonding: More ether_addr_copy and neatenings Ding Tianhong
  3 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2014-02-18 17:42 UTC (permalink / raw)
  To: netdev; +Cc: Jay Vosburgh, Veaceslav Falico, Andy Gospodarek, linux-kernel

It's unnecessary and less readable after a clause ending in a goto.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/bonding/bond_alb.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 97a43a20..aaeeacf 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -1455,12 +1455,12 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
 
 		bond_dev_queue_xmit(bond, skb, tx_slave->dev);
 		goto out;
-	} else {
-		if (tx_slave) {
-			_lock_tx_hashtbl(bond);
-			__tlb_clear_slave(bond, tx_slave, 0);
-			_unlock_tx_hashtbl(bond);
-		}
+	}
+
+	if (tx_slave) {
+		_lock_tx_hashtbl(bond);
+		__tlb_clear_slave(bond, tx_slave, 0);
+		_unlock_tx_hashtbl(bond);
 	}
 
 	/* no suitable interface, frame not sent */
-- 
1.8.1.2.459.gbcd45b4.dirty


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

* [PATCH net-next 3/3] bonding: Invert test
  2014-02-18 17:42 [PATCH net-next 0/3] bonding: More ether_addr_copy and neatenings Joe Perches
  2014-02-18 17:42 ` [PATCH net-next 1/3] bonding: More use of ether_addr_copy Joe Perches
  2014-02-18 17:42 ` [PATCH net-next 2/3] bonding: Remove unnecessary else Joe Perches
@ 2014-02-18 17:42 ` Joe Perches
  2014-02-19  1:44 ` [PATCH net-next 0/3] bonding: More ether_addr_copy and neatenings Ding Tianhong
  3 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2014-02-18 17:42 UTC (permalink / raw)
  To: netdev; +Cc: Jay Vosburgh, Veaceslav Falico, Andy Gospodarek, linux-kernel

Make the error case return early.
Make the normal return at the bottom of the function.
Reduces indent for readability.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/bonding/bond_3ad.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 7cb51f9..a0e12369 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -2381,17 +2381,16 @@ int __bond_3ad_get_active_agg_info(struct bonding *bond,
 		}
 	}
 
-	if (aggregator) {
-		ad_info->aggregator_id = aggregator->aggregator_identifier;
-		ad_info->ports = aggregator->num_of_ports;
-		ad_info->actor_key = aggregator->actor_oper_aggregator_key;
-		ad_info->partner_key = aggregator->partner_oper_aggregator_key;
-		ether_addr_copy(ad_info->partner_system,
-				aggregator->partner_system.mac_addr_value);
-		return 0;
-	}
-
-	return -1;
+	if (!aggregator)
+		return -1;
+
+	ad_info->aggregator_id = aggregator->aggregator_identifier;
+	ad_info->ports = aggregator->num_of_ports;
+	ad_info->actor_key = aggregator->actor_oper_aggregator_key;
+	ad_info->partner_key = aggregator->partner_oper_aggregator_key;
+	ether_addr_copy(ad_info->partner_system,
+			aggregator->partner_system.mac_addr_value);
+	return 0;
 }
 
 /* Wrapper used to hold bond->lock so no slave manipulation can occur */
-- 
1.8.1.2.459.gbcd45b4.dirty


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

* Re: [PATCH net-next 0/3] bonding: More ether_addr_copy and neatenings.
  2014-02-18 17:42 [PATCH net-next 0/3] bonding: More ether_addr_copy and neatenings Joe Perches
                   ` (2 preceding siblings ...)
  2014-02-18 17:42 ` [PATCH net-next 3/3] bonding: Invert test Joe Perches
@ 2014-02-19  1:44 ` Ding Tianhong
  2014-02-19 20:38   ` David Miller
  3 siblings, 1 reply; 6+ messages in thread
From: Ding Tianhong @ 2014-02-19  1:44 UTC (permalink / raw)
  To: Joe Perches, netdev; +Cc: linux-kernel

On 2014/2/19 1:42, Joe Perches wrote:
> Joe Perches (3):
>   bonding: More use of ether_addr_copy
>   bonding: Remove unnecessary else
>   bonding: Invert test
> 
>  drivers/net/bonding/bond_3ad.c  | 21 ++++++++++-----------
>  drivers/net/bonding/bond_alb.c  | 17 ++++++++---------
>  drivers/net/bonding/bond_main.c |  6 +++---
>  3 files changed, 21 insertions(+), 23 deletions(-)
> 

Reviewed-by: Ding Tianhong <dingtianhong@huawei.com>


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

* Re: [PATCH net-next 0/3] bonding: More ether_addr_copy and neatenings.
  2014-02-19  1:44 ` [PATCH net-next 0/3] bonding: More ether_addr_copy and neatenings Ding Tianhong
@ 2014-02-19 20:38   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2014-02-19 20:38 UTC (permalink / raw)
  To: dingtianhong; +Cc: joe, netdev, linux-kernel

From: Ding Tianhong <dingtianhong@huawei.com>
Date: Wed, 19 Feb 2014 09:44:54 +0800

> On 2014/2/19 1:42, Joe Perches wrote:
>> Joe Perches (3):
>>   bonding: More use of ether_addr_copy
>>   bonding: Remove unnecessary else
>>   bonding: Invert test
>> 
>>  drivers/net/bonding/bond_3ad.c  | 21 ++++++++++-----------
>>  drivers/net/bonding/bond_alb.c  | 17 ++++++++---------
>>  drivers/net/bonding/bond_main.c |  6 +++---
>>  3 files changed, 21 insertions(+), 23 deletions(-)
>> 
> 
> Reviewed-by: Ding Tianhong <dingtianhong@huawei.com>

Series applied, thanks Joe.

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

end of thread, other threads:[~2014-02-19 20:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-18 17:42 [PATCH net-next 0/3] bonding: More ether_addr_copy and neatenings Joe Perches
2014-02-18 17:42 ` [PATCH net-next 1/3] bonding: More use of ether_addr_copy Joe Perches
2014-02-18 17:42 ` [PATCH net-next 2/3] bonding: Remove unnecessary else Joe Perches
2014-02-18 17:42 ` [PATCH net-next 3/3] bonding: Invert test Joe Perches
2014-02-19  1:44 ` [PATCH net-next 0/3] bonding: More ether_addr_copy and neatenings Ding Tianhong
2014-02-19 20:38   ` 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.