From cd0e80ce902f6e79b31888af4ff4545846ce1c0e Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Wed, 20 Jun 2007 14:53:49 +0000 Subject: - move iprule and ipaddress from matches() to index_in_str_array text data bss dec hex filename 2544 0 0 2544 9f0 networking/libiproute/iprule.o.oorig 2356 0 0 2356 934 networking/libiproute/iprule.o 6481 0 0 6481 1951 networking/libiproute/ipaddress.o.oorig 6464 0 0 6464 1940 networking/libiproute/ipaddress.o --- networking/libiproute/ipaddress.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'networking/libiproute/ipaddress.c') diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index e504862a9..a4add6a47 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c @@ -604,7 +604,6 @@ static int ipaddr_modify(int cmd, int argc, char **argv) "peer", "remote", "broadcast", "brd", "anycast", "scope", "dev", "label", "local", 0 }; - struct rtnl_handle rth; struct { struct nlmsghdr n; @@ -619,7 +618,7 @@ static int ipaddr_modify(int cmd, int argc, char **argv) int peer_len = 0; int brd_len = 0; int any_len = 0; - int scoped = 0; + bool scoped = 0; memset(&req, 0, sizeof(req)); @@ -724,7 +723,7 @@ static int ipaddr_modify(int cmd, int argc, char **argv) bb_error_msg(bb_msg_requires_arg,"\"dev\""); return -1; } - if (l && matches(d, l) != 0) { + if (l && strncmp(d, l, strlen(d)) != 0) { bb_error_msg_and_die("\"dev\" (%s) must match \"label\" (%s)", d, l); } @@ -775,22 +774,21 @@ int do_ipaddr(int argc, char **argv) "add", "delete", "list", "show", "lst", "flush", 0 }; - int command_num = 2; + int command_num = 2; /* default command is list */ if (*argv) { command_num = index_in_substr_array(commands, *argv); } - switch (command_num) { - case 0: /* add */ - return ipaddr_modify(RTM_NEWADDR, argc-1, argv+1); - case 1: /* delete */ - return ipaddr_modify(RTM_DELADDR, argc-1, argv+1); - case 2: /* list */ - case 3: /* show */ - case 4: /* lst */ - return ipaddr_list_or_flush(argc-1, argv+1, 0); - case 5: /* flush */ - return ipaddr_list_or_flush(argc-1, argv+1, 1); - } - bb_error_msg_and_die("unknown command %s", *argv); + if (command_num < 0 || command_num > 5) + bb_error_msg_and_die("unknown command %s", *argv); + --argc; + ++argv; + if (command_num == 0) /* add */ + return ipaddr_modify(RTM_NEWADDR, argc, argv); + else if (command_num == 1) /* delete */ + return ipaddr_modify(RTM_DELADDR, argc, argv); + else if (command_num == 5) /* flush */ + return ipaddr_list_or_flush(argc, argv, 1); + else /* 2 == list, 3 == show, 4 == lst */ + return ipaddr_list_or_flush(argc, argv, 0); } -- cgit v1.2.3