diff options
author | Bernhard Reutner-Fischer | 2010-05-25 17:42:01 +0200 |
---|---|---|
committer | Bernhard Reutner-Fischer | 2010-05-25 18:48:33 +0200 |
commit | cc4493a95c877354ee267e29629b72cd9d010262 (patch) | |
tree | 955d7669b5e9128c768a27ec8f4d29695f4528de /networking/libiproute | |
parent | 1b3549875cf8beb236a17a456fc0cab66bfd1d72 (diff) | |
download | busybox-cc4493a95c877354ee267e29629b72cd9d010262.zip busybox-cc4493a95c877354ee267e29629b72cd9d010262.tar.gz |
ip addr: unify parsing args
function old new delta
do_ipaddr 87 84 -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3) Total: -3 bytes
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'networking/libiproute')
-rw-r--r-- | networking/libiproute/ipaddress.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 3f360f4..8a5edb9 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c @@ -773,21 +773,15 @@ int do_ipaddr(char **argv) { static const char commands[] ALIGN1 = "add\0""delete\0""list\0""show\0""lst\0""flush\0"; - - int command_num = 2; /* default command is list */ - + smalluint cmd = 2; if (*argv) { - command_num = index_in_substrings(commands, *argv); - if (command_num < 0 || command_num > 5) - bb_error_msg_and_die("unknown command %s", *argv); + cmd = index_in_substrings(commands, *argv); + if (cmd > 5) + bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name); argv++; + if (cmd <= 1) + return ipaddr_modify((cmd == 0) ? RTM_NEWADDR : RTM_DELADDR, argv); } - if (command_num == 0) /* add */ - return ipaddr_modify(RTM_NEWADDR, argv); - if (command_num == 1) /* delete */ - return ipaddr_modify(RTM_DELADDR, argv); - if (command_num == 5) /* flush */ - return ipaddr_list_or_flush(argv, 1); /* 2 == list, 3 == show, 4 == lst */ - return ipaddr_list_or_flush(argv, 0); + return ipaddr_list_or_flush(argv, cmd == 5); } |