libiproute: rename invarg(a,b) to invarg_1_to_2(a,b)
invarg(a,b) - "invalid argument", but how a and b enter the message? invarg_1_to_2(a,b) is somewhat easier to read: "invalid argument 'a' to 'b'" Audit of usage revealed a number of bad uses, with too long messages. text data bss dec hex filename 938848 932 17448 957228 e9b2c busybox_old 938788 932 17448 957168 e9af0 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
69934701fd
commit
0f296a3a56
@ -326,7 +326,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
*arg = '\0';
|
*arg = '\0';
|
||||||
n = index_in_strings(conv_words, val);
|
n = index_in_strings(conv_words, val);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
bb_error_msg_and_die(bb_msg_invalid_arg, val, "conv");
|
bb_error_msg_and_die(bb_msg_invalid_arg_to, val, "conv");
|
||||||
G.flags |= (1 << n);
|
G.flags |= (1 << n);
|
||||||
if (!arg) /* no ',' left, so this was the last specifier */
|
if (!arg) /* no ',' left, so this was the last specifier */
|
||||||
break;
|
break;
|
||||||
@ -368,7 +368,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
int n;
|
int n;
|
||||||
n = index_in_strings(status_words, val);
|
n = index_in_strings(status_words, val);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
bb_error_msg_and_die(bb_msg_invalid_arg, val, "status");
|
bb_error_msg_and_die(bb_msg_invalid_arg_to, val, "status");
|
||||||
G.flags |= FLAG_STATUS << n;
|
G.flags |= FLAG_STATUS << n;
|
||||||
/*continue;*/
|
/*continue;*/
|
||||||
}
|
}
|
||||||
|
@ -882,7 +882,7 @@ static int find_type(const char *type)
|
|||||||
mask = S_IFSOCK;
|
mask = S_IFSOCK;
|
||||||
|
|
||||||
if (mask == 0 || type[1] != '\0')
|
if (mask == 0 || type[1] != '\0')
|
||||||
bb_error_msg_and_die(bb_msg_invalid_arg, type, "-type");
|
bb_error_msg_and_die(bb_msg_invalid_arg_to, type, "-type");
|
||||||
|
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
@ -1786,7 +1786,7 @@ extern const char bb_msg_can_not_create_raw_socket[] ALIGN1;
|
|||||||
extern const char bb_msg_perm_denied_are_you_root[] ALIGN1;
|
extern const char bb_msg_perm_denied_are_you_root[] ALIGN1;
|
||||||
extern const char bb_msg_you_must_be_root[] ALIGN1;
|
extern const char bb_msg_you_must_be_root[] ALIGN1;
|
||||||
extern const char bb_msg_requires_arg[] ALIGN1;
|
extern const char bb_msg_requires_arg[] ALIGN1;
|
||||||
extern const char bb_msg_invalid_arg[] ALIGN1;
|
extern const char bb_msg_invalid_arg_to[] ALIGN1;
|
||||||
extern const char bb_msg_standard_input[] ALIGN1;
|
extern const char bb_msg_standard_input[] ALIGN1;
|
||||||
extern const char bb_msg_standard_output[] ALIGN1;
|
extern const char bb_msg_standard_output[] ALIGN1;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ const char bb_msg_can_not_create_raw_socket[] ALIGN1 = "can't create raw socket"
|
|||||||
const char bb_msg_perm_denied_are_you_root[] ALIGN1 = "permission denied (are you root?)";
|
const char bb_msg_perm_denied_are_you_root[] ALIGN1 = "permission denied (are you root?)";
|
||||||
const char bb_msg_you_must_be_root[] ALIGN1 = "you must be root";
|
const char bb_msg_you_must_be_root[] ALIGN1 = "you must be root";
|
||||||
const char bb_msg_requires_arg[] ALIGN1 = "%s requires an argument";
|
const char bb_msg_requires_arg[] ALIGN1 = "%s requires an argument";
|
||||||
const char bb_msg_invalid_arg[] ALIGN1 = "invalid argument '%s' to '%s'";
|
const char bb_msg_invalid_arg_to[] ALIGN1 = "invalid argument '%s' to '%s'";
|
||||||
const char bb_msg_standard_input[] ALIGN1 = "standard input";
|
const char bb_msg_standard_input[] ALIGN1 = "standard input";
|
||||||
const char bb_msg_standard_output[] ALIGN1 = "standard output";
|
const char bb_msg_standard_output[] ALIGN1 = "standard output";
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ static ALWAYS_INLINE void bb_strtotimeval(struct timeval *tv,
|
|||||||
# else
|
# else
|
||||||
if (sscanf(time_str, "%lf", &secs) != 1)
|
if (sscanf(time_str, "%lf", &secs) != 1)
|
||||||
# endif
|
# endif
|
||||||
bb_error_msg_and_die(bb_msg_invalid_arg, time_str, "timespec");
|
bb_error_msg_and_die(bb_msg_invalid_arg_to, time_str, "timespec");
|
||||||
tv->tv_sec = secs;
|
tv->tv_sec = secs;
|
||||||
tv->tv_usec = 1000000 * (secs - tv->tv_sec);
|
tv->tv_usec = 1000000 * (secs - tv->tv_sec);
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ int brctl_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
key = index_in_strings(keywords, *argv);
|
key = index_in_strings(keywords, *argv);
|
||||||
if (key == -1) /* no match found in keywords array, bail out. */
|
if (key == -1) /* no match found in keywords array, bail out. */
|
||||||
bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
|
bb_error_msg_and_die(bb_msg_invalid_arg_to, *argv, applet_name);
|
||||||
argv++;
|
argv++;
|
||||||
fd = xsocket(AF_INET, SOCK_STREAM, 0);
|
fd = xsocket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ int brctl_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
"1\0" "on\0" "y\0" "yes\0"; /* 4 .. 7 */
|
"1\0" "on\0" "y\0" "yes\0"; /* 4 .. 7 */
|
||||||
int onoff = index_in_strings(no_yes, *argv);
|
int onoff = index_in_strings(no_yes, *argv);
|
||||||
if (onoff < 0)
|
if (onoff < 0)
|
||||||
bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
|
bb_error_msg_and_die(bb_msg_invalid_arg_to, *argv, applet_name);
|
||||||
onoff = (unsigned)onoff / 4;
|
onoff = (unsigned)onoff / 4;
|
||||||
arm_ioctl(args, BRCTL_SET_BRIDGE_STP_STATE, onoff, 0);
|
arm_ioctl(args, BRCTL_SET_BRIDGE_STP_STATE, onoff, 0);
|
||||||
goto fire;
|
goto fire;
|
||||||
@ -332,7 +332,7 @@ int brctl_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
port = if_nametoindex(*argv++);
|
port = if_nametoindex(*argv++);
|
||||||
if (!port)
|
if (!port)
|
||||||
bb_error_msg_and_die(bb_msg_invalid_arg, *argv, "port");
|
bb_error_msg_and_die(bb_msg_invalid_arg_to, *argv, "port");
|
||||||
memset(ifidx, 0, sizeof ifidx);
|
memset(ifidx, 0, sizeof ifidx);
|
||||||
arm_ioctl(args, BRCTL_GET_PORT_LIST, (unsigned long)ifidx,
|
arm_ioctl(args, BRCTL_GET_PORT_LIST, (unsigned long)ifidx,
|
||||||
MAX_PORTS);
|
MAX_PORTS);
|
||||||
|
@ -67,7 +67,7 @@ char** FAST_FUNC ip_parse_common_args(char **argv)
|
|||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
arg = index_in_strings(families, *argv);
|
arg = index_in_strings(families, *argv);
|
||||||
if (arg < 0)
|
if (arg < 0)
|
||||||
invarg(*argv, "protocol family");
|
invarg_1_to_2(*argv, "family");
|
||||||
/* now arg == 0, 1 or 2 */
|
/* now arg == 0, 1 or 2 */
|
||||||
} else {
|
} else {
|
||||||
arg -= ARG_IPv4;
|
arg -= ARG_IPv4;
|
||||||
|
@ -455,7 +455,7 @@ int FAST_FUNC ipaddr_list_or_flush(char **argv, int flush)
|
|||||||
G_filter.scopemask = -1;
|
G_filter.scopemask = -1;
|
||||||
if (rtnl_rtscope_a2n(&scope, *argv)) {
|
if (rtnl_rtscope_a2n(&scope, *argv)) {
|
||||||
if (strcmp(*argv, "all") != 0) {
|
if (strcmp(*argv, "all") != 0) {
|
||||||
invarg(*argv, "scope");
|
invarg_1_to_2(*argv, "scope");
|
||||||
}
|
}
|
||||||
scope = RT_SCOPE_NOWHERE;
|
scope = RT_SCOPE_NOWHERE;
|
||||||
G_filter.scopemask = 0;
|
G_filter.scopemask = 0;
|
||||||
@ -669,7 +669,7 @@ static int ipaddr_modify(int cmd, int flags, char **argv)
|
|||||||
} else if (arg == 5) { /* scope */
|
} else if (arg == 5) { /* scope */
|
||||||
uint32_t scope = 0;
|
uint32_t scope = 0;
|
||||||
if (rtnl_rtscope_a2n(&scope, *argv)) {
|
if (rtnl_rtscope_a2n(&scope, *argv)) {
|
||||||
invarg(*argv, "scope");
|
invarg_1_to_2(*argv, "scope");
|
||||||
}
|
}
|
||||||
req.ifa.ifa_scope = scope;
|
req.ifa.ifa_scope = scope;
|
||||||
scoped = 1;
|
scoped = 1;
|
||||||
@ -751,7 +751,7 @@ int FAST_FUNC do_ipaddr(char **argv)
|
|||||||
if (*argv) {
|
if (*argv) {
|
||||||
cmd = index_in_substrings(commands, *argv);
|
cmd = index_in_substrings(commands, *argv);
|
||||||
if (cmd < 0)
|
if (cmd < 0)
|
||||||
invarg(*argv, applet_name);
|
invarg_1_to_2(*argv, applet_name);
|
||||||
argv++;
|
argv++;
|
||||||
if (cmd <= 4) {
|
if (cmd <= 4) {
|
||||||
return ipaddr_modify(
|
return ipaddr_modify(
|
||||||
|
@ -349,7 +349,7 @@ static void vlan_parse_opt(char **argv, struct nlmsghdr *n, unsigned int size)
|
|||||||
while (*argv) {
|
while (*argv) {
|
||||||
arg = index_in_substrings(keywords, *argv);
|
arg = index_in_substrings(keywords, *argv);
|
||||||
if (arg < 0)
|
if (arg < 0)
|
||||||
invarg(*argv, "type vlan");
|
invarg_1_to_2(*argv, "type vlan");
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (arg == ARG_id) {
|
if (arg == ARG_id) {
|
||||||
@ -512,7 +512,7 @@ static int do_add_or_delete(char **argv, const unsigned rtm)
|
|||||||
if (name_str) {
|
if (name_str) {
|
||||||
const size_t name_len = strlen(name_str) + 1;
|
const size_t name_len = strlen(name_str) + 1;
|
||||||
if (name_len < 2 || name_len > IFNAMSIZ)
|
if (name_len < 2 || name_len > IFNAMSIZ)
|
||||||
invarg(name_str, "name");
|
invarg_1_to_2(name_str, "name");
|
||||||
addattr_l(&req.n, sizeof(req), IFLA_IFNAME, name_str, name_len);
|
addattr_l(&req.n, sizeof(req), IFLA_IFNAME, name_str, name_len);
|
||||||
}
|
}
|
||||||
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
|
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
|
||||||
@ -536,14 +536,14 @@ static int do_add_or_delete(char **argv, const unsigned rtm)
|
|||||||
if (qlen != -1)
|
if (qlen != -1)
|
||||||
duparg("txqueuelen", *argv);
|
duparg("txqueuelen", *argv);
|
||||||
if (get_integer(&qlen, *argv, 0))
|
if (get_integer(&qlen, *argv, 0))
|
||||||
invarg("Invalid \"txqueuelen\" value\n", *argv);
|
invarg_1_to_2(*argv, "txqueuelen");
|
||||||
addattr_l(&req->n, sizeof(*req), IFLA_TXQLEN, &qlen, 4);
|
addattr_l(&req->n, sizeof(*req), IFLA_TXQLEN, &qlen, 4);
|
||||||
} else if (strcmp(*argv, "mtu") == 0) {
|
} else if (strcmp(*argv, "mtu") == 0) {
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (mtu != -1)
|
if (mtu != -1)
|
||||||
duparg("mtu", *argv);
|
duparg("mtu", *argv);
|
||||||
if (get_integer(&mtu, *argv, 0))
|
if (get_integer(&mtu, *argv, 0))
|
||||||
invarg("Invalid \"mtu\" value\n", *argv);
|
invarg_1_to_2(*argv, "mtu");
|
||||||
addattr_l(&req->n, sizeof(*req), IFLA_MTU, &mtu, 4);
|
addattr_l(&req->n, sizeof(*req), IFLA_MTU, &mtu, 4);
|
||||||
} else if (strcmp(*argv, "netns") == 0) {
|
} else if (strcmp(*argv, "netns") == 0) {
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
@ -554,7 +554,7 @@ static int do_add_or_delete(char **argv, const unsigned rtm)
|
|||||||
else if (get_integer(&netns, *argv, 0) == 0)
|
else if (get_integer(&netns, *argv, 0) == 0)
|
||||||
addattr_l(&req->n, sizeof(*req), IFLA_NET_NS_PID, &netns, 4);
|
addattr_l(&req->n, sizeof(*req), IFLA_NET_NS_PID, &netns, 4);
|
||||||
else
|
else
|
||||||
invarg("Invalid \"netns\" value\n", *argv);
|
invarg_1_to_2(*argv, "netns");
|
||||||
} else if (strcmp(*argv, "multicast") == 0) {
|
} else if (strcmp(*argv, "multicast") == 0) {
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
req->i.ifi_change |= IFF_MULTICAST;
|
req->i.ifi_change |= IFF_MULTICAST;
|
||||||
@ -604,7 +604,7 @@ static int do_add_or_delete(char **argv, const unsigned rtm)
|
|||||||
struct rtattr *vflist;
|
struct rtattr *vflist;
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_integer(&vf, *argv, 0)) {
|
if (get_integer(&vf, *argv, 0)) {
|
||||||
invarg("Invalid \"vf\" value\n", *argv);
|
invarg_1_to_2(*argv, "vf");
|
||||||
}
|
}
|
||||||
vflist = addattr_nest(&req->n, sizeof(*req),
|
vflist = addattr_nest(&req->n, sizeof(*req),
|
||||||
IFLA_VFINFO_LIST);
|
IFLA_VFINFO_LIST);
|
||||||
@ -617,7 +617,7 @@ static int do_add_or_delete(char **argv, const unsigned rtm)
|
|||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
ifindex = ll_name_to_index(*argv);
|
ifindex = ll_name_to_index(*argv);
|
||||||
if (!ifindex)
|
if (!ifindex)
|
||||||
invarg("Device does not exist\n", *argv);
|
invarg_1_to_2(*argv, "master");
|
||||||
addattr_l(&req->n, sizeof(*req), IFLA_MASTER,
|
addattr_l(&req->n, sizeof(*req), IFLA_MASTER,
|
||||||
&ifindex, 4);
|
&ifindex, 4);
|
||||||
} else if (matches(*argv, "nomaster") == 0) {
|
} else if (matches(*argv, "nomaster") == 0) {
|
||||||
@ -644,28 +644,27 @@ static int do_add_or_delete(char **argv, const unsigned rtm)
|
|||||||
if (*group != -1)
|
if (*group != -1)
|
||||||
duparg("group", *argv);
|
duparg("group", *argv);
|
||||||
if (rtnl_group_a2n(group, *argv))
|
if (rtnl_group_a2n(group, *argv))
|
||||||
invarg("Invalid \"group\" value\n", *argv);
|
invarg_1_to_2(*argv, "group");
|
||||||
} else if (strcmp(*argv, "mode") == 0) {
|
} else if (strcmp(*argv, "mode") == 0) {
|
||||||
int mode;
|
int mode;
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
mode = get_link_mode(*argv);
|
mode = get_link_mode(*argv);
|
||||||
if (mode < 0)
|
if (mode < 0)
|
||||||
invarg("Invalid link mode\n", *argv);
|
invarg_1_to_2(*argv, "mode");
|
||||||
addattr8(&req->n, sizeof(*req), IFLA_LINKMODE, mode);
|
addattr8(&req->n, sizeof(*req), IFLA_LINKMODE, mode);
|
||||||
} else if (strcmp(*argv, "state") == 0) {
|
} else if (strcmp(*argv, "state") == 0) {
|
||||||
int state;
|
int state;
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
state = get_operstate(*argv);
|
state = get_operstate(*argv);
|
||||||
if (state < 0)
|
if (state < 0)
|
||||||
invarg("Invalid operstate\n", *argv);
|
invarg_1_to_2(*argv, "state");
|
||||||
|
|
||||||
addattr8(&req->n, sizeof(*req), IFLA_OPERSTATE, state);
|
addattr8(&req->n, sizeof(*req), IFLA_OPERSTATE, state);
|
||||||
} else if (matches(*argv, "numtxqueues") == 0) {
|
} else if (matches(*argv, "numtxqueues") == 0) {
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (numtxqueues != -1)
|
if (numtxqueues != -1)
|
||||||
duparg("numtxqueues", *argv);
|
duparg("numtxqueues", *argv);
|
||||||
if (get_integer(&numtxqueues, *argv, 0))
|
if (get_integer(&numtxqueues, *argv, 0))
|
||||||
invarg("Invalid \"numtxqueues\" value\n", *argv);
|
invarg_1_to_2(*argv, "numtxqueues");
|
||||||
addattr_l(&req->n, sizeof(*req), IFLA_NUM_TX_QUEUES,
|
addattr_l(&req->n, sizeof(*req), IFLA_NUM_TX_QUEUES,
|
||||||
&numtxqueues, 4);
|
&numtxqueues, 4);
|
||||||
} else if (matches(*argv, "numrxqueues") == 0) {
|
} else if (matches(*argv, "numrxqueues") == 0) {
|
||||||
@ -673,7 +672,7 @@ static int do_add_or_delete(char **argv, const unsigned rtm)
|
|||||||
if (numrxqueues != -1)
|
if (numrxqueues != -1)
|
||||||
duparg("numrxqueues", *argv);
|
duparg("numrxqueues", *argv);
|
||||||
if (get_integer(&numrxqueues, *argv, 0))
|
if (get_integer(&numrxqueues, *argv, 0))
|
||||||
invarg("Invalid \"numrxqueues\" value\n", *argv);
|
invarg_1_to_2(*argv, "numrxqueues");
|
||||||
addattr_l(&req->n, sizeof(*req), IFLA_NUM_RX_QUEUES,
|
addattr_l(&req->n, sizeof(*req), IFLA_NUM_RX_QUEUES,
|
||||||
&numrxqueues, 4);
|
&numrxqueues, 4);
|
||||||
}
|
}
|
||||||
@ -687,7 +686,7 @@ int FAST_FUNC do_iplink(char **argv)
|
|||||||
if (*argv) {
|
if (*argv) {
|
||||||
int key = index_in_substrings(keywords, *argv);
|
int key = index_in_substrings(keywords, *argv);
|
||||||
if (key < 0) /* invalid argument */
|
if (key < 0) /* invalid argument */
|
||||||
invarg(*argv, applet_name);
|
invarg_1_to_2(*argv, applet_name);
|
||||||
argv++;
|
argv++;
|
||||||
if (key <= 1) /* add/delete */
|
if (key <= 1) /* add/delete */
|
||||||
return do_add_or_delete(argv, key ? RTM_DELLINK : RTM_NEWLINK);
|
return do_add_or_delete(argv, key ? RTM_DELLINK : RTM_NEWLINK);
|
||||||
|
@ -75,7 +75,7 @@ static unsigned nud_state_a2n(char *arg)
|
|||||||
|
|
||||||
id = index_in_substrings(keywords, arg);
|
id = index_in_substrings(keywords, arg);
|
||||||
if (id < 0)
|
if (id < 0)
|
||||||
bb_error_msg_and_die(bb_msg_invalid_arg, arg, "nud state");
|
bb_error_msg_and_die(bb_msg_invalid_arg_to, arg, "nud state");
|
||||||
return nuds[id];
|
return nuds[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,9 +281,9 @@ static int FAST_FUNC ipneigh_list_or_flush(char **argv, int flush)
|
|||||||
ll_init_map(&rth);
|
ll_init_map(&rth);
|
||||||
|
|
||||||
if (filter_dev) {
|
if (filter_dev) {
|
||||||
if ((G_filter.index = xll_name_to_index(filter_dev)) == 0) {
|
G_filter.index = xll_name_to_index(filter_dev);
|
||||||
bb_error_msg_and_die(bb_msg_invalid_arg,
|
if (G_filter.index == 0) {
|
||||||
filter_dev, "Cannot find device");
|
bb_error_msg_and_die("can't find device '%s'", filter_dev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,6 +349,6 @@ int FAST_FUNC do_ipneigh(char **argv)
|
|||||||
case 1: /* flush */
|
case 1: /* flush */
|
||||||
return ipneigh_list_or_flush(argv + 1, 1);
|
return ipneigh_list_or_flush(argv + 1, 1);
|
||||||
}
|
}
|
||||||
invarg(*argv, applet_name);
|
invarg_1_to_2(*argv, applet_name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -403,7 +403,7 @@ IF_FEATURE_IP_RULE(ARG_table,)
|
|||||||
uint32_t prot;
|
uint32_t prot;
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (rtnl_rtprot_a2n(&prot, *argv))
|
if (rtnl_rtprot_a2n(&prot, *argv))
|
||||||
invarg(*argv, "protocol");
|
invarg_1_to_2(*argv, "protocol");
|
||||||
req.r.rtm_protocol = prot;
|
req.r.rtm_protocol = prot;
|
||||||
ok |= proto_ok;
|
ok |= proto_ok;
|
||||||
#if ENABLE_FEATURE_IP_RULE
|
#if ENABLE_FEATURE_IP_RULE
|
||||||
@ -411,7 +411,7 @@ IF_FEATURE_IP_RULE(ARG_table,)
|
|||||||
uint32_t tid;
|
uint32_t tid;
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (rtnl_rttable_a2n(&tid, *argv))
|
if (rtnl_rttable_a2n(&tid, *argv))
|
||||||
invarg(*argv, "table");
|
invarg_1_to_2(*argv, "table");
|
||||||
req.r.rtm_table = tid;
|
req.r.rtm_table = tid;
|
||||||
#endif
|
#endif
|
||||||
} else if (arg == ARG_dev || arg == ARG_oif) {
|
} else if (arg == ARG_dev || arg == ARG_oif) {
|
||||||
@ -597,7 +597,7 @@ static int iproute_list_or_flush(char **argv, int flush)
|
|||||||
//G_filter.protocolmask = -1;
|
//G_filter.protocolmask = -1;
|
||||||
if (rtnl_rtprot_a2n(&prot, *argv)) {
|
if (rtnl_rtprot_a2n(&prot, *argv)) {
|
||||||
if (index_in_strings(keywords, *argv) != KW_all)
|
if (index_in_strings(keywords, *argv) != KW_all)
|
||||||
invarg(*argv, "protocol");
|
invarg_1_to_2(*argv, "protocol");
|
||||||
prot = 0;
|
prot = 0;
|
||||||
//G_filter.protocolmask = 0;
|
//G_filter.protocolmask = 0;
|
||||||
}
|
}
|
||||||
@ -622,10 +622,10 @@ static int iproute_list_or_flush(char **argv, int flush)
|
|||||||
#if ENABLE_FEATURE_IP_RULE
|
#if ENABLE_FEATURE_IP_RULE
|
||||||
uint32_t tid;
|
uint32_t tid;
|
||||||
if (rtnl_rttable_a2n(&tid, *argv))
|
if (rtnl_rttable_a2n(&tid, *argv))
|
||||||
invarg(*argv, "table");
|
invarg_1_to_2(*argv, "table");
|
||||||
G_filter.tb = tid;
|
G_filter.tb = tid;
|
||||||
#else
|
#else
|
||||||
invarg(*argv, "table");
|
invarg_1_to_2(*argv, "table");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else if (arg == KW_cache) {
|
} else if (arg == KW_cache) {
|
||||||
@ -932,7 +932,7 @@ int FAST_FUNC do_iproute(char **argv)
|
|||||||
case 11: /* flush */
|
case 11: /* flush */
|
||||||
return iproute_list_or_flush(argv+1, 1);
|
return iproute_list_or_flush(argv+1, 1);
|
||||||
default:
|
default:
|
||||||
invarg(*argv, applet_name);
|
invarg_1_to_2(*argv, applet_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return iproute_modify(cmd, flags, argv+1);
|
return iproute_modify(cmd, flags, argv+1);
|
||||||
|
@ -214,7 +214,7 @@ static int iprule_modify(int cmd, char **argv)
|
|||||||
while (*argv) {
|
while (*argv) {
|
||||||
key = index_in_substrings(keywords, *argv) + 1;
|
key = index_in_substrings(keywords, *argv) + 1;
|
||||||
if (key == 0) /* no match found in keywords array, bail out. */
|
if (key == 0) /* no match found in keywords array, bail out. */
|
||||||
invarg(*argv, applet_name);
|
invarg_1_to_2(*argv, applet_name);
|
||||||
if (key == ARG_from) {
|
if (key == ARG_from) {
|
||||||
inet_prefix dst;
|
inet_prefix dst;
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
@ -239,7 +239,7 @@ static int iprule_modify(int cmd, char **argv)
|
|||||||
uint32_t tos;
|
uint32_t tos;
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (rtnl_dsfield_a2n(&tos, *argv))
|
if (rtnl_dsfield_a2n(&tos, *argv))
|
||||||
invarg(*argv, "TOS");
|
invarg_1_to_2(*argv, "TOS");
|
||||||
req.r.rtm_tos = tos;
|
req.r.rtm_tos = tos;
|
||||||
} else if (key == ARG_fwmark) {
|
} else if (key == ARG_fwmark) {
|
||||||
uint32_t fwmark;
|
uint32_t fwmark;
|
||||||
@ -250,7 +250,7 @@ static int iprule_modify(int cmd, char **argv)
|
|||||||
uint32_t realm;
|
uint32_t realm;
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_rt_realms(&realm, *argv))
|
if (get_rt_realms(&realm, *argv))
|
||||||
invarg(*argv, "realms");
|
invarg_1_to_2(*argv, "realms");
|
||||||
addattr32(&req.n, sizeof(req), RTA_FLOW, realm);
|
addattr32(&req.n, sizeof(req), RTA_FLOW, realm);
|
||||||
} else if (key == ARG_table ||
|
} else if (key == ARG_table ||
|
||||||
key == ARG_lookup
|
key == ARG_lookup
|
||||||
@ -258,7 +258,7 @@ static int iprule_modify(int cmd, char **argv)
|
|||||||
uint32_t tid;
|
uint32_t tid;
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (rtnl_rttable_a2n(&tid, *argv))
|
if (rtnl_rttable_a2n(&tid, *argv))
|
||||||
invarg(*argv, "table ID");
|
invarg_1_to_2(*argv, "table ID");
|
||||||
req.r.rtm_table = tid;
|
req.r.rtm_table = tid;
|
||||||
table_ok = 1;
|
table_ok = 1;
|
||||||
} else if (key == ARG_dev ||
|
} else if (key == ARG_dev ||
|
||||||
@ -281,7 +281,7 @@ static int iprule_modify(int cmd, char **argv)
|
|||||||
if (key == ARG_help)
|
if (key == ARG_help)
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
if (rtnl_rtntype_a2n(&type, *argv))
|
if (rtnl_rtntype_a2n(&type, *argv))
|
||||||
invarg(*argv, "type");
|
invarg_1_to_2(*argv, "type");
|
||||||
req.r.rtm_type = type;
|
req.r.rtm_type = type;
|
||||||
}
|
}
|
||||||
argv++;
|
argv++;
|
||||||
@ -309,7 +309,7 @@ int FAST_FUNC do_iprule(char **argv)
|
|||||||
if (*argv) {
|
if (*argv) {
|
||||||
int cmd = index_in_substrings(ip_rule_commands, *argv);
|
int cmd = index_in_substrings(ip_rule_commands, *argv);
|
||||||
if (cmd < 0)
|
if (cmd < 0)
|
||||||
invarg(*argv, applet_name);
|
invarg_1_to_2(*argv, applet_name);
|
||||||
argv++;
|
argv++;
|
||||||
if (cmd < 2)
|
if (cmd < 2)
|
||||||
return iprule_modify((cmd == 0) ? RTM_NEWRULE : RTM_DELRULE, argv);
|
return iprule_modify((cmd == 0) ? RTM_NEWRULE : RTM_DELRULE, argv);
|
||||||
|
@ -294,7 +294,7 @@ static void parse_args(char **argv, int cmd, struct ip_tunnel_parm *p)
|
|||||||
if (key != ARG_inherit) {
|
if (key != ARG_inherit) {
|
||||||
uval = get_unsigned(*argv, "TTL");
|
uval = get_unsigned(*argv, "TTL");
|
||||||
if (uval > 255)
|
if (uval > 255)
|
||||||
invarg(*argv, "TTL must be <=255");
|
invarg_1_to_2(*argv, "TTL");
|
||||||
p->iph.ttl = uval;
|
p->iph.ttl = uval;
|
||||||
}
|
}
|
||||||
} else if (key == ARG_tos ||
|
} else if (key == ARG_tos ||
|
||||||
@ -305,7 +305,7 @@ static void parse_args(char **argv, int cmd, struct ip_tunnel_parm *p)
|
|||||||
key = index_in_strings(keywords, *argv);
|
key = index_in_strings(keywords, *argv);
|
||||||
if (key != ARG_inherit) {
|
if (key != ARG_inherit) {
|
||||||
if (rtnl_dsfield_a2n(&uval, *argv))
|
if (rtnl_dsfield_a2n(&uval, *argv))
|
||||||
invarg(*argv, "TOS");
|
invarg_1_to_2(*argv, "TOS");
|
||||||
p->iph.tos = uval;
|
p->iph.tos = uval;
|
||||||
} else
|
} else
|
||||||
p->iph.tos = 1;
|
p->iph.tos = 1;
|
||||||
@ -562,7 +562,7 @@ int FAST_FUNC do_iptunnel(char **argv)
|
|||||||
if (*argv) {
|
if (*argv) {
|
||||||
int key = index_in_substrings(keywords, *argv);
|
int key = index_in_substrings(keywords, *argv);
|
||||||
if (key < 0)
|
if (key < 0)
|
||||||
invarg(*argv, applet_name);
|
invarg_1_to_2(*argv, applet_name);
|
||||||
argv++;
|
argv++;
|
||||||
if (key == ARG_add)
|
if (key == ARG_add)
|
||||||
return do_add(SIOCADDTUNNEL, argv);
|
return do_add(SIOCADDTUNNEL, argv);
|
||||||
|
@ -47,7 +47,7 @@ unsigned get_unsigned(char *arg, const char *errmsg)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
invarg(arg, errmsg); /* does not return */
|
invarg_1_to_2(arg, errmsg); /* does not return */
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t get_u32(char *arg, const char *errmsg)
|
uint32_t get_u32(char *arg, const char *errmsg)
|
||||||
@ -62,7 +62,7 @@ uint32_t get_u32(char *arg, const char *errmsg)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
invarg(arg, errmsg); /* does not return */
|
invarg_1_to_2(arg, errmsg); /* does not return */
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t get_u16(char *arg, const char *errmsg)
|
uint16_t get_u16(char *arg, const char *errmsg)
|
||||||
@ -77,7 +77,7 @@ uint16_t get_u16(char *arg, const char *errmsg)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
invarg(arg, errmsg); /* does not return */
|
invarg_1_to_2(arg, errmsg); /* does not return */
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_addr_1(inet_prefix *addr, char *name, int family)
|
int get_addr_1(inet_prefix *addr, char *name, int family)
|
||||||
@ -230,12 +230,12 @@ uint32_t get_addr32(char *name)
|
|||||||
|
|
||||||
void incomplete_command(void)
|
void incomplete_command(void)
|
||||||
{
|
{
|
||||||
bb_error_msg_and_die("command line is not complete, try option \"help\"");
|
bb_error_msg_and_die("command line is not complete, try \"help\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
void invarg(const char *arg, const char *opt)
|
void invarg_1_to_2(const char *arg, const char *opt)
|
||||||
{
|
{
|
||||||
bb_error_msg_and_die(bb_msg_invalid_arg, arg, opt);
|
bb_error_msg_and_die(bb_msg_invalid_arg_to, arg, opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void duparg(const char *key, const char *arg)
|
void duparg(const char *key, const char *arg)
|
||||||
|
@ -74,7 +74,7 @@ extern const char *format_host(int af, int len, void *addr, char *buf, int bufle
|
|||||||
rt_addr_n2a(af, addr, buf, buflen)
|
rt_addr_n2a(af, addr, buf, buflen)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void invarg(const char *, const char *) NORETURN;
|
void invarg_1_to_2(const char *, const char *) NORETURN;
|
||||||
void duparg(const char *, const char *) NORETURN;
|
void duparg(const char *, const char *) NORETURN;
|
||||||
void duparg2(const char *, const char *) NORETURN;
|
void duparg2(const char *, const char *) NORETURN;
|
||||||
int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits);
|
int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits);
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
//usage: "\n -F Disable RTS/CTS flow control"
|
//usage: "\n -F Disable RTS/CTS flow control"
|
||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
#include "libiproute/utils.h" /* invarg() */
|
#include "libiproute/utils.h" /* invarg_1_to_2() */
|
||||||
|
|
||||||
struct globals {
|
struct globals {
|
||||||
int handle;
|
int handle;
|
||||||
@ -175,7 +175,7 @@ int slattach_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
encap = index_in_strings(proto_names, proto);
|
encap = index_in_strings(proto_names, proto);
|
||||||
|
|
||||||
if (encap < 0)
|
if (encap < 0)
|
||||||
invarg(proto, "protocol");
|
invarg_1_to_2(proto, "protocol");
|
||||||
if (encap > 3)
|
if (encap > 3)
|
||||||
encap = 8;
|
encap = 8;
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ int slattach_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (opt & OPT_s_baud) {
|
if (opt & OPT_s_baud) {
|
||||||
baud_code = tty_value_to_baud(xatoi(baud_str));
|
baud_code = tty_value_to_baud(xatoi(baud_str));
|
||||||
if (baud_code < 0)
|
if (baud_code < 0)
|
||||||
invarg(baud_str, "baud rate");
|
invarg_1_to_2(baud_str, "baud rate");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Trap signals in order to restore tty states upon exit */
|
/* Trap signals in order to restore tty states upon exit */
|
||||||
|
@ -459,14 +459,14 @@ int tc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
obj = index_in_substrings(objects, *argv++);
|
obj = index_in_substrings(objects, *argv++);
|
||||||
|
|
||||||
if (obj < OBJ_qdisc)
|
if (obj < 0)
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
if (!*argv)
|
if (!*argv)
|
||||||
cmd = CMD_show; /* list is the default */
|
cmd = CMD_show; /* list is the default */
|
||||||
else {
|
else {
|
||||||
cmd = index_in_substrings(commands, *argv);
|
cmd = index_in_substrings(commands, *argv);
|
||||||
if (cmd < 0)
|
if (cmd < 0)
|
||||||
bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
|
invarg_1_to_2(*argv, argv[-1]);
|
||||||
argv++;
|
argv++;
|
||||||
}
|
}
|
||||||
memset(&msg, 0, sizeof(msg));
|
memset(&msg, 0, sizeof(msg));
|
||||||
@ -489,7 +489,7 @@ int tc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
/* We don't care about duparg2("qdisc handle",*argv) for now */
|
/* We don't care about duparg2("qdisc handle",*argv) for now */
|
||||||
if (get_qdisc_handle(&filter_qdisc, *argv))
|
if (get_qdisc_handle(&filter_qdisc, *argv))
|
||||||
invarg(*argv, "qdisc");
|
invarg_1_to_2(*argv, "qdisc");
|
||||||
} else
|
} else
|
||||||
if (obj != OBJ_qdisc
|
if (obj != OBJ_qdisc
|
||||||
&& (arg == ARG_root
|
&& (arg == ARG_root
|
||||||
@ -499,7 +499,7 @@ int tc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
) {
|
) {
|
||||||
/* nothing */
|
/* nothing */
|
||||||
} else {
|
} else {
|
||||||
invarg(*argv, "command");
|
invarg_1_to_2(*argv, "command");
|
||||||
}
|
}
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (arg == ARG_root) {
|
if (arg == ARG_root) {
|
||||||
@ -513,7 +513,7 @@ int tc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (msg.tcm_parent)
|
if (msg.tcm_parent)
|
||||||
duparg(*argv, "parent");
|
duparg(*argv, "parent");
|
||||||
if (get_tc_classid(&handle, *argv))
|
if (get_tc_classid(&handle, *argv))
|
||||||
invarg(*argv, "parent");
|
invarg_1_to_2(*argv, "parent");
|
||||||
msg.tcm_parent = handle;
|
msg.tcm_parent = handle;
|
||||||
if (obj == OBJ_filter)
|
if (obj == OBJ_filter)
|
||||||
filter_parent = handle;
|
filter_parent = handle;
|
||||||
@ -538,7 +538,7 @@ int tc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (filter_proto)
|
if (filter_proto)
|
||||||
duparg(*argv, "protocol");
|
duparg(*argv, "protocol");
|
||||||
if (ll_proto_a2n(&tmp, *argv))
|
if (ll_proto_a2n(&tmp, *argv))
|
||||||
invarg(*argv, "protocol");
|
invarg_1_to_2(*argv, "protocol");
|
||||||
filter_proto = tmp;
|
filter_proto = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user