diff options
author | Denis Vlasenko | 2007-11-18 22:56:25 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-11-18 22:56:25 +0000 |
commit | ed6a49c657ae204f6ba8ad84315fa04c09297a7c (patch) | |
tree | 5f47e19e16582dfcdefb99bc1edea693e86c258d /networking/libiproute/iprule.c | |
parent | 2a587df80a148e497d10344c79f2b94d3bce6aaf (diff) | |
download | busybox-ed6a49c657ae204f6ba8ad84315fa04c09297a7c.zip busybox-ed6a49c657ae204f6ba8ad84315fa04c09297a7c.tar.gz |
ip: stop propagating argc; optimize ip_parse_common_args
function old new delta
find_pair 167 187 +20
static.families - 17 +17
die_must_be_on_off - 11 +11
...
on_off 33 22 -11
do_ipaddr 103 90 -13
do_iptunnel 1001 986 -15
iproute_list_or_flush 1237 1217 -20
static.ip_common_commands 43 22 -21
do_iproute 2217 2193 -24
parse_args 1444 1414 -30
ip_do 47 16 -31
do_iprule 994 963 -31
ip_main 153 113 -40
ipaddr_modify 1357 1305 -52
ipaddr_list_or_flush 2543 2490 -53
ip_parse_common_args 294 159 -135
------------------------------------------------------------------------------
(add/remove: 4/1 grow/shrink: 4/24 up/down: 85/-563) Total: -478 bytes
text data bss dec hex filename
775561 966 9236 785763 bfd63 busybox_old
775073 962 9236 785271 bfb77 busybox_unstripped
Diffstat (limited to 'networking/libiproute/iprule.c')
-rw-r--r-- | networking/libiproute/iprule.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c index 3c276e6..6442992 100644 --- a/networking/libiproute/iprule.c +++ b/networking/libiproute/iprule.c @@ -161,7 +161,7 @@ static int print_rule(struct sockaddr_nl *who ATTRIBUTE_UNUSED, } /* Return value becomes exitcode. It's okay to not return at all */ -static int iprule_list(int argc, char **argv) +static int iprule_list(char **argv) { struct rtnl_handle rth; int af = preferred_family; @@ -169,9 +169,9 @@ static int iprule_list(int argc, char **argv) if (af == AF_UNSPEC) af = AF_INET; - if (argc > 0) { + if (*argv) { //bb_error_msg("\"rule show\" needs no arguments"); - bb_warn_ignoring_args(argc); + bb_warn_ignoring_args(1); return -1; } @@ -184,7 +184,7 @@ static int iprule_list(int argc, char **argv) } /* Return value becomes exitcode. It's okay to not return at all */ -static int iprule_modify(int cmd, int argc, char **argv) +static int iprule_modify(int cmd, char **argv) { static const char keywords[] ALIGN1 = "from\0""to\0""preference\0""order\0""priority\0" @@ -220,7 +220,7 @@ static int iprule_modify(int cmd, int argc, char **argv) req.r.rtm_type = RTN_UNICAST; } - while (argc > 0) { + while (*argv) { key = index_in_substrings(keywords, *argv) + 1; if (key == 0) /* no match found in keywords array, bail out. */ bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name); @@ -291,7 +291,6 @@ static int iprule_modify(int cmd, int argc, char **argv) invarg(*argv, "type"); req.r.rtm_type = type; } - argc--; argv++; } @@ -310,17 +309,16 @@ static int iprule_modify(int cmd, int argc, char **argv) } /* Return value becomes exitcode. It's okay to not return at all */ -int do_iprule(int argc, char **argv) +int do_iprule(char **argv) { static const char ip_rule_commands[] ALIGN1 = "add\0""delete\0""list\0""show\0"; int cmd = 2; /* list */ - if (argc < 1) - return iprule_list(0, NULL); - if (*argv) - cmd = index_in_substrings(ip_rule_commands, *argv); + if (!*argv) + return iprule_list(argv); + cmd = index_in_substrings(ip_rule_commands, *argv); switch (cmd) { case 0: /* add */ cmd = RTM_NEWRULE; @@ -330,10 +328,10 @@ int do_iprule(int argc, char **argv) break; case 2: /* list */ case 3: /* show */ - return iprule_list(argc-1, argv+1); + return iprule_list(argv+1); break; default: bb_error_msg_and_die("unknown command %s", *argv); } - return iprule_modify(cmd, argc-1, argv+1); + return iprule_modify(cmd, argv+1); } |