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/ip.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/ip.c')
-rw-r--r-- | networking/ip.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/networking/ip.c b/networking/ip.c index 3ea1b62..182813d 100644 --- a/networking/ip.c +++ b/networking/ip.c @@ -24,57 +24,50 @@ || ENABLE_FEATURE_IP_TUNNEL \ || ENABLE_FEATURE_IP_RULE -static int ATTRIBUTE_NORETURN ip_print_help(int ATTRIBUTE_UNUSED ac, char ATTRIBUTE_UNUSED **av) +static int ATTRIBUTE_NORETURN ip_print_help(char ATTRIBUTE_UNUSED **argv) { bb_show_usage(); } -static int (*ip_func)(int argc, char **argv) = ip_print_help; - -static int ip_do(int argc, char **argv) +static int ip_do(int (*ip_func)(char **argv), char **argv) { - ip_parse_common_args(&argc, &argv); - return ip_func(argc-1, argv+1); + argv = ip_parse_common_args(argv); + return ip_func(argv); } #if ENABLE_FEATURE_IP_ADDRESS int ipaddr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int ipaddr_main(int argc, char **argv) { - ip_func = do_ipaddr; - return ip_do(argc, argv); + return ip_do(do_ipaddr, argv); } #endif #if ENABLE_FEATURE_IP_LINK int iplink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int iplink_main(int argc, char **argv) { - ip_func = do_iplink; - return ip_do(argc, argv); + return ip_do(do_iplink, argv); } #endif #if ENABLE_FEATURE_IP_ROUTE int iproute_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int iproute_main(int argc, char **argv) { - ip_func = do_iproute; - return ip_do(argc, argv); + return ip_do(do_iproute, argv); } #endif #if ENABLE_FEATURE_IP_RULE int iprule_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int iprule_main(int argc, char **argv) { - ip_func = do_iprule; - return ip_do(argc, argv); + return ip_do(do_iprule, argv); } #endif #if ENABLE_FEATURE_IP_TUNNEL int iptunnel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int iptunnel_main(int argc, char **argv) { - ip_func = do_iptunnel; - return ip_do(argc, argv); + return ip_do(do_iptunnel, argv); } #endif @@ -97,12 +90,12 @@ int ip_main(int argc, char **argv) USE_FEATURE_IP_RULE(IP_rule,) IP_none }; + int (*ip_func)(char **argv) = ip_print_help; - ip_parse_common_args(&argc, &argv); - if (argc > 1) { - int key = index_in_substrings(keywords, argv[1]); - argc -= 2; - argv += 2; + argv = ip_parse_common_args(argv + 1); + if (*argv) { + int key = index_in_substrings(keywords, *argv); + argv++; #if ENABLE_FEATURE_IP_ADDRESS if (key == IP_addr) ip_func = do_ipaddr; @@ -124,7 +117,7 @@ int ip_main(int argc, char **argv) ip_func = do_iprule; #endif } - return ip_func(argc, argv); + return ip_func(argv); } #endif /* any of ENABLE_FEATURE_IP_xxx is 1 */ |