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>
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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);