lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20081112124512.6EEF63E6610@basil.firstfloor.org>
Date:	Wed, 12 Nov 2008 13:45:12 +0100 (CET)
From:	Andi Kleen <andi@...stfloor.org>
To:	mingo@...e.hu, linux-kernel@...r.kernel.org, peterz@...radead.org
Subject: [PATCH] [4/4] SCHED: Use a lookup array in sd_level_to_string


Generates better/shorter code. Doesn't matter much because it's only
a SCHED_DEBUG function. 

Signed-off-by: Andi Kleen <ak@...ux.intel.com>

---
 kernel/sched.c |   29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)

Index: linux-2.6.28-rc4-test/kernel/sched.c
===================================================================
--- linux-2.6.28-rc4-test.orig/kernel/sched.c	2008-11-12 12:36:23.000000000 +0100
+++ linux-2.6.28-rc4-test/kernel/sched.c	2008-11-12 12:43:58.000000000 +0100
@@ -6629,24 +6629,17 @@
 
 static inline const char *sd_level_to_string(enum sched_domain_level lvl)
 {
-	switch (lvl) {
-	case SD_LV_NONE:
-			return "NONE";
-	case SD_LV_SIBLING:
-			return "SIBLING";
-	case SD_LV_MC:
-			return "MC";
-	case SD_LV_CPU:
-			return "CPU";
-	case SD_LV_NODE:
-			return "NODE";
-	case SD_LV_ALLNODES:
-			return "ALLNODES";
-	case SD_LV_MAX:
-			return "MAX";
-
-	}
-	return "MAX";
+	static const char *lva[] = {
+#define T(x) [SD_LV_ ## x ] = #T
+		T(NONE),
+		T(SIBLING),
+		T(MC),
+		T(CPU),
+		T(NODE),
+		T(ALLNODES),
+#undef T
+	};
+	return (unsigned)lvl < ARRAY_SIZE(lva) ? lva[lvl] : "MAX";
 }
 
 static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ