diff options
author | Denys Vlasenko | 2015-10-14 13:21:01 +0200 |
---|---|---|
committer | Denys Vlasenko | 2015-10-14 13:21:01 +0200 |
commit | 0f296a3a56b52842057e5a2bc653621a3a6c7bec (patch) | |
tree | c504475cbf18d845698097e6b3b9656e0040d373 /networking/libiproute | |
parent | 69934701fd1b18327b3a779cb292a728834b2d0d (diff) | |
download | busybox-0f296a3a56b52842057e5a2bc653621a3a6c7bec.zip busybox-0f296a3a56b52842057e5a2bc653621a3a6c7bec.tar.gz |
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>
Diffstat (limited to 'networking/libiproute')
-rw-r--r-- | networking/libiproute/ip_parse_common_args.c | 2 | ||||
-rw-r--r-- | networking/libiproute/ipaddress.c | 6 | ||||
-rw-r--r-- | networking/libiproute/iplink.c | 27 | ||||
-rw-r--r-- | networking/libiproute/ipneigh.c | 10 | ||||
-rw-r--r-- | networking/libiproute/iproute.c | 12 | ||||
-rw-r--r-- | networking/libiproute/iprule.c | 12 | ||||
-rw-r--r-- | networking/libiproute/iptunnel.c | 6 | ||||
-rw-r--r-- | networking/libiproute/utils.c | 12 | ||||
-rw-r--r-- | networking/libiproute/utils.h | 2 |
9 files changed, 44 insertions, 45 deletions
diff --git a/networking/libiproute/ip_parse_common_args.c b/networking/libiproute/ip_parse_common_args.c index 59c759b..1a298f7 100644 --- a/networking/libiproute/ip_parse_common_args.c +++ b/networking/libiproute/ip_parse_common_args.c @@ -67,7 +67,7 @@ char** FAST_FUNC ip_parse_common_args(char **argv) bb_show_usage(); arg = index_in_strings(families, *argv); if (arg < 0) - invarg(*argv, "protocol family"); + invarg_1_to_2(*argv, "family"); /* now arg == 0, 1 or 2 */ } else { arg -= ARG_IPv4; diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 8845cab..c0f27c7 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c @@ -455,7 +455,7 @@ int FAST_FUNC ipaddr_list_or_flush(char **argv, int flush) G_filter.scopemask = -1; if (rtnl_rtscope_a2n(&scope, *argv)) { if (strcmp(*argv, "all") != 0) { - invarg(*argv, "scope"); + invarg_1_to_2(*argv, "scope"); } scope = RT_SCOPE_NOWHERE; G_filter.scopemask = 0; @@ -669,7 +669,7 @@ static int ipaddr_modify(int cmd, int flags, char **argv) } else if (arg == 5) { /* scope */ uint32_t scope = 0; if (rtnl_rtscope_a2n(&scope, *argv)) { - invarg(*argv, "scope"); + invarg_1_to_2(*argv, "scope"); } req.ifa.ifa_scope = scope; scoped = 1; @@ -751,7 +751,7 @@ int FAST_FUNC do_ipaddr(char **argv) if (*argv) { cmd = index_in_substrings(commands, *argv); if (cmd < 0) - invarg(*argv, applet_name); + invarg_1_to_2(*argv, applet_name); argv++; if (cmd <= 4) { return ipaddr_modify( diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c index 5c27c2d..ae3ef0c 100644 --- a/networking/libiproute/iplink.c +++ b/networking/libiproute/iplink.c @@ -349,7 +349,7 @@ static void vlan_parse_opt(char **argv, struct nlmsghdr *n, unsigned int size) while (*argv) { arg = index_in_substrings(keywords, *argv); if (arg < 0) - invarg(*argv, "type vlan"); + invarg_1_to_2(*argv, "type vlan"); NEXT_ARG(); if (arg == ARG_id) { @@ -512,7 +512,7 @@ static int do_add_or_delete(char **argv, const unsigned rtm) if (name_str) { const size_t name_len = strlen(name_str) + 1; 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); } 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) duparg("txqueuelen", *argv); 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); } else if (strcmp(*argv, "mtu") == 0) { NEXT_ARG(); if (mtu != -1) duparg("mtu", *argv); 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); } else if (strcmp(*argv, "netns") == 0) { 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) addattr_l(&req->n, sizeof(*req), IFLA_NET_NS_PID, &netns, 4); else - invarg("Invalid \"netns\" value\n", *argv); + invarg_1_to_2(*argv, "netns"); } else if (strcmp(*argv, "multicast") == 0) { NEXT_ARG(); req->i.ifi_change |= IFF_MULTICAST; @@ -604,7 +604,7 @@ static int do_add_or_delete(char **argv, const unsigned rtm) struct rtattr *vflist; NEXT_ARG(); 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), IFLA_VFINFO_LIST); @@ -617,7 +617,7 @@ static int do_add_or_delete(char **argv, const unsigned rtm) NEXT_ARG(); ifindex = ll_name_to_index(*argv); if (!ifindex) - invarg("Device does not exist\n", *argv); + invarg_1_to_2(*argv, "master"); addattr_l(&req->n, sizeof(*req), IFLA_MASTER, &ifindex, 4); } else if (matches(*argv, "nomaster") == 0) { @@ -644,28 +644,27 @@ static int do_add_or_delete(char **argv, const unsigned rtm) if (*group != -1) duparg("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) { int mode; NEXT_ARG(); mode = get_link_mode(*argv); if (mode < 0) - invarg("Invalid link mode\n", *argv); + invarg_1_to_2(*argv, "mode"); addattr8(&req->n, sizeof(*req), IFLA_LINKMODE, mode); } else if (strcmp(*argv, "state") == 0) { int state; NEXT_ARG(); state = get_operstate(*argv); if (state < 0) - invarg("Invalid operstate\n", *argv); - + invarg_1_to_2(*argv, "state"); addattr8(&req->n, sizeof(*req), IFLA_OPERSTATE, state); } else if (matches(*argv, "numtxqueues") == 0) { NEXT_ARG(); if (numtxqueues != -1) duparg("numtxqueues", *argv); 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, &numtxqueues, 4); } else if (matches(*argv, "numrxqueues") == 0) { @@ -673,7 +672,7 @@ static int do_add_or_delete(char **argv, const unsigned rtm) if (numrxqueues != -1) duparg("numrxqueues", *argv); 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, &numrxqueues, 4); } @@ -687,7 +686,7 @@ int FAST_FUNC do_iplink(char **argv) if (*argv) { int key = index_in_substrings(keywords, *argv); if (key < 0) /* invalid argument */ - invarg(*argv, applet_name); + invarg_1_to_2(*argv, applet_name); argv++; if (key <= 1) /* add/delete */ return do_add_or_delete(argv, key ? RTM_DELLINK : RTM_NEWLINK); diff --git a/networking/libiproute/ipneigh.c b/networking/libiproute/ipneigh.c index 03a15d8..6588c12 100644 --- a/networking/libiproute/ipneigh.c +++ b/networking/libiproute/ipneigh.c @@ -75,7 +75,7 @@ static unsigned nud_state_a2n(char *arg) id = index_in_substrings(keywords, arg); 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]; } @@ -281,9 +281,9 @@ static int FAST_FUNC ipneigh_list_or_flush(char **argv, int flush) ll_init_map(&rth); if (filter_dev) { - if ((G_filter.index = xll_name_to_index(filter_dev)) == 0) { - bb_error_msg_and_die(bb_msg_invalid_arg, - filter_dev, "Cannot find device"); + G_filter.index = xll_name_to_index(filter_dev); + if (G_filter.index == 0) { + 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 */ return ipneigh_list_or_flush(argv + 1, 1); } - invarg(*argv, applet_name); + invarg_1_to_2(*argv, applet_name); return 1; } diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index f7209b1..0d29144 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c @@ -403,7 +403,7 @@ IF_FEATURE_IP_RULE(ARG_table,) uint32_t prot; NEXT_ARG(); if (rtnl_rtprot_a2n(&prot, *argv)) - invarg(*argv, "protocol"); + invarg_1_to_2(*argv, "protocol"); req.r.rtm_protocol = prot; ok |= proto_ok; #if ENABLE_FEATURE_IP_RULE @@ -411,7 +411,7 @@ IF_FEATURE_IP_RULE(ARG_table,) uint32_t tid; NEXT_ARG(); if (rtnl_rttable_a2n(&tid, *argv)) - invarg(*argv, "table"); + invarg_1_to_2(*argv, "table"); req.r.rtm_table = tid; #endif } 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; if (rtnl_rtprot_a2n(&prot, *argv)) { if (index_in_strings(keywords, *argv) != KW_all) - invarg(*argv, "protocol"); + invarg_1_to_2(*argv, "protocol"); prot = 0; //G_filter.protocolmask = 0; } @@ -622,10 +622,10 @@ static int iproute_list_or_flush(char **argv, int flush) #if ENABLE_FEATURE_IP_RULE uint32_t tid; if (rtnl_rttable_a2n(&tid, *argv)) - invarg(*argv, "table"); + invarg_1_to_2(*argv, "table"); G_filter.tb = tid; #else - invarg(*argv, "table"); + invarg_1_to_2(*argv, "table"); #endif } } else if (arg == KW_cache) { @@ -932,7 +932,7 @@ int FAST_FUNC do_iproute(char **argv) case 11: /* flush */ return iproute_list_or_flush(argv+1, 1); default: - invarg(*argv, applet_name); + invarg_1_to_2(*argv, applet_name); } return iproute_modify(cmd, flags, argv+1); diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c index 774a3e2..c3b2109 100644 --- a/networking/libiproute/iprule.c +++ b/networking/libiproute/iprule.c @@ -214,7 +214,7 @@ static int iprule_modify(int cmd, char **argv) while (*argv) { key = index_in_substrings(keywords, *argv) + 1; 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) { inet_prefix dst; NEXT_ARG(); @@ -239,7 +239,7 @@ static int iprule_modify(int cmd, char **argv) uint32_t tos; NEXT_ARG(); if (rtnl_dsfield_a2n(&tos, *argv)) - invarg(*argv, "TOS"); + invarg_1_to_2(*argv, "TOS"); req.r.rtm_tos = tos; } else if (key == ARG_fwmark) { uint32_t fwmark; @@ -250,7 +250,7 @@ static int iprule_modify(int cmd, char **argv) uint32_t realm; NEXT_ARG(); if (get_rt_realms(&realm, *argv)) - invarg(*argv, "realms"); + invarg_1_to_2(*argv, "realms"); addattr32(&req.n, sizeof(req), RTA_FLOW, realm); } else if (key == ARG_table || key == ARG_lookup @@ -258,7 +258,7 @@ static int iprule_modify(int cmd, char **argv) uint32_t tid; NEXT_ARG(); if (rtnl_rttable_a2n(&tid, *argv)) - invarg(*argv, "table ID"); + invarg_1_to_2(*argv, "table ID"); req.r.rtm_table = tid; table_ok = 1; } else if (key == ARG_dev || @@ -281,7 +281,7 @@ static int iprule_modify(int cmd, char **argv) if (key == ARG_help) bb_show_usage(); if (rtnl_rtntype_a2n(&type, *argv)) - invarg(*argv, "type"); + invarg_1_to_2(*argv, "type"); req.r.rtm_type = type; } argv++; @@ -309,7 +309,7 @@ int FAST_FUNC do_iprule(char **argv) if (*argv) { int cmd = index_in_substrings(ip_rule_commands, *argv); if (cmd < 0) - invarg(*argv, applet_name); + invarg_1_to_2(*argv, applet_name); argv++; if (cmd < 2) return iprule_modify((cmd == 0) ? RTM_NEWRULE : RTM_DELRULE, argv); diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c index a65d5e5..b88c3a4 100644 --- a/networking/libiproute/iptunnel.c +++ b/networking/libiproute/iptunnel.c @@ -294,7 +294,7 @@ static void parse_args(char **argv, int cmd, struct ip_tunnel_parm *p) if (key != ARG_inherit) { uval = get_unsigned(*argv, "TTL"); if (uval > 255) - invarg(*argv, "TTL must be <=255"); + invarg_1_to_2(*argv, "TTL"); p->iph.ttl = uval; } } 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); if (key != ARG_inherit) { if (rtnl_dsfield_a2n(&uval, *argv)) - invarg(*argv, "TOS"); + invarg_1_to_2(*argv, "TOS"); p->iph.tos = uval; } else p->iph.tos = 1; @@ -562,7 +562,7 @@ int FAST_FUNC do_iptunnel(char **argv) if (*argv) { int key = index_in_substrings(keywords, *argv); if (key < 0) - invarg(*argv, applet_name); + invarg_1_to_2(*argv, applet_name); argv++; if (key == ARG_add) return do_add(SIOCADDTUNNEL, argv); diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c index 37b5311..7f7cb42 100644 --- a/networking/libiproute/utils.c +++ b/networking/libiproute/utils.c @@ -47,7 +47,7 @@ unsigned get_unsigned(char *arg, const char *errmsg) 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) @@ -62,7 +62,7 @@ uint32_t get_u32(char *arg, const char *errmsg) 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) @@ -77,7 +77,7 @@ uint16_t get_u16(char *arg, const char *errmsg) 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) @@ -230,12 +230,12 @@ uint32_t get_addr32(char *name) 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) diff --git a/networking/libiproute/utils.h b/networking/libiproute/utils.h index cd15b70..9bbed64 100644 --- a/networking/libiproute/utils.h +++ b/networking/libiproute/utils.h @@ -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) #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 duparg2(const char *, const char *) NORETURN; int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits); |