diff mbox

[2/7] bonding: use table for mode names

Message ID 20081209201446.222212807@eitzenberger.org
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

holger@eitzenberger.org Dec. 9, 2008, 8:07 p.m. UTC
Use a small array in bond_mode_name() for the names, thus saving some
space:

before

    text     data      bss      dec    hex filename
   57736     9372      344    67452  1077c drivers/net/bonding/bonding.ko

after
    text     data      bss      dec    hex filename
   57441     9372      344    67157  10655 drivers/net/bonding/bonding.ko

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>

Comments

David Miller Dec. 10, 2008, 7:08 a.m. UTC | #1
From: holger@eitzenberger.org
Date: Tue, 09 Dec 2008 21:07:52 +0100

> Use a small array in bond_mode_name() for the names, thus saving some
> space:
> 
> before
> 
>     text     data      bss      dec    hex filename
>    57736     9372      344    67452  1077c drivers/net/bonding/bonding.ko
> 
> after
>     text     data      bss      dec    hex filename
>    57441     9372      344    67157  10655 drivers/net/bonding/bonding.ko
> 
> Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

Index: bonding-2.6/drivers/net/bonding/bond_main.c
===================================================================
--- bonding-2.6.orig/drivers/net/bonding/bond_main.c	2008-12-08 20:55:52.000000000 +0100
+++ bonding-2.6/drivers/net/bonding/bond_main.c	2008-12-08 22:16:02.000000000 +0100
@@ -219,24 +219,20 @@ 
 
 static const char *bond_mode_name(int mode)
 {
-	switch (mode) {
-	case BOND_MODE_ROUNDROBIN :
-		return "load balancing (round-robin)";
-	case BOND_MODE_ACTIVEBACKUP :
-		return "fault-tolerance (active-backup)";
-	case BOND_MODE_XOR :
-		return "load balancing (xor)";
-	case BOND_MODE_BROADCAST :
-		return "fault-tolerance (broadcast)";
-	case BOND_MODE_8023AD:
-		return "IEEE 802.3ad Dynamic link aggregation";
-	case BOND_MODE_TLB:
-		return "transmit load balancing";
-	case BOND_MODE_ALB:
-		return "adaptive load balancing";
-	default:
+	static const char *names[] = {
+		[BOND_MODE_ROUNDROBIN] = "load balancing (round-robin)",
+		[BOND_MODE_ACTIVEBACKUP] = "fault-tolerance (active-backup)",
+		[BOND_MODE_XOR] = "load balancing (xor)",
+		[BOND_MODE_BROADCAST] = "fault-tolerance (broadcast)",
+		[BOND_MODE_8023AD]= "IEEE 802.3ad Dynamic link aggregation",
+		[BOND_MODE_TLB] = "transmit load balancing",
+		[BOND_MODE_ALB] = "adaptive load balancing",
+	};
+
+	if (mode < 0 || mode > BOND_MODE_ALB)
 		return "unknown";
-	}
+
+	return names[mode];
 }
 
 /*---------------------------------- VLAN -----------------------------------*/