[git commit master] mdev: tiny shrinkage by index_in_strings

Denys Vlasenko vda.linux at googlemail.com
Tue Oct 27 16:12:26 UTC 2009


commit: http://git.busybox.net/busybox/commit/?id=6531f0923bc3c288291aa979a0e06daab964f008
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

text	   data	    bss	    dec	    hex	filename
      2633	      0	      0	   2633	    a49	util-linux/mdev.o.old
      2624	      0	      0	   2624	    a40	util-linux/mdev.o

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 util-linux/mdev.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 2ac15e7..d0aafac 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -526,6 +526,9 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
 		char *seq;
 		char *action;
 		char *env_path;
+		static const char keywords[] ALIGN1 = "remove\0add\0";
+		enum { OP_remove = 0, OP_add };
+		smalluint op;
 
 		/* Hotplug:
 		 * env ACTION=... DEVPATH=... SUBSYSTEM=... [SEQNUM=...] mdev
@@ -538,7 +541,7 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
 		if (!action || !env_path /*|| !subsystem*/)
 			bb_show_usage();
 		fw = getenv("FIRMWARE");
-
+		op = index_in_strings(keywords, action);
 		/* If it exists, does /dev/mdev.seq match $SEQNUM?
 		 * If it does not match, earlier mdev is running
 		 * in parallel, and we need to wait */
@@ -565,14 +568,14 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
 		}
 
 		snprintf(temp, PATH_MAX, "/sys%s", env_path);
-		if (strcmp(action, "remove") == 0) {
+		if (op == OP_remove) {
 			/* Ignoring "remove firmware". It was reported
 			 * to happen and to cause erroneous deletion
 			 * of device nodes. */
 			if (!fw)
 				make_device(temp, 1);
 		}
-		else if (strcmp(action, "add") == 0) {
+		else if (op == OP_add) {
 			make_device(temp, 0);
 			if (ENABLE_FEATURE_MDEV_LOAD_FIRMWARE) {
 				if (fw)
-- 
1.6.3.3



More information about the busybox-cvs mailing list