summaryrefslogtreecommitdiff
path: root/networking/libiproute/iprule.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/libiproute/iprule.c')
-rw-r--r--networking/libiproute/iprule.c24
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);
}