- reuse strings and messages. Saves about 600B
diff --git a/networking/libiproute/ip_parse_common_args.c b/networking/libiproute/ip_parse_common_args.c
index 52e549e..6d49157 100644
--- a/networking/libiproute/ip_parse_common_args.c
+++ b/networking/libiproute/ip_parse_common_args.c
@@ -56,7 +56,7 @@
else if (strcmp(argv[1], "link") == 0)
preferred_family = AF_PACKET;
else
- invarg(argv[1], "invalid protocol family");
+ invarg(argv[1], "protocol family");
} else if (strcmp(opt, "-4") == 0) {
preferred_family = AF_INET;
} else if (strcmp(opt, "-6") == 0) {
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index a048cff..ee9825b 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -430,11 +430,11 @@
if (flush) {
if (argc <= 0) {
- fprintf(stderr, "Flush requires arguments.\n");
+ bb_error_msg(bb_msg_requires_arg, "flush");
return -1;
}
if (filter.family == AF_PACKET) {
- fprintf(stderr, "Cannot flush link addresses.\n");
+ bb_error_msg("Cannot flush link addresses.");
return -1;
}
}
@@ -456,7 +456,7 @@
filter.scopemask = -1;
if (rtnl_rtscope_a2n(&scope, *argv)) {
if (strcmp(*argv, "all") != 0) {
- invarg("invalid \"scope\"\n", *argv);
+ invarg(*argv, "scope");
}
scope = RT_SCOPE_NOWHERE;
filter.scopemask = 0;
@@ -711,7 +711,7 @@
uint32_t scope = 0;
NEXT_ARG();
if (rtnl_rtscope_a2n(&scope, *argv)) {
- invarg(*argv, "invalid scope value");
+ invarg(*argv, "scope");
}
req.ifa.ifa_scope = scope;
scoped = 1;
@@ -744,7 +744,7 @@
}
if (d == NULL) {
- bb_error_msg("Not enough information: \"dev\" argument is required");
+ bb_error_msg(bb_msg_requires_arg,"\"dev\"");
return -1;
}
if (l && matches(d, l) != 0) {
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c
index 2797f02..9e30122 100644
--- a/networking/libiproute/iplink.c
+++ b/networking/libiproute/iplink.c
@@ -252,7 +252,7 @@
if (mtu != -1)
duparg("mtu", *argv);
if (get_integer(&mtu, *argv, 0))
- invarg("Invalid \"mtu\" value\n", *argv);
+ invarg(*argv, "mtu");
} else if (strcmp(*argv, "multicast") == 0) {
NEXT_ARG();
mask |= IFF_MULTICAST;
@@ -286,7 +286,7 @@
}
if (!dev) {
- bb_error_msg("Not enough of information: \"dev\" argument is required.");
+ bb_error_msg(bb_msg_requires_arg, "\"dev\"");
exit(-1);
}
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
index 6052a30..511e891 100644
--- a/networking/libiproute/iproute.c
+++ b/networking/libiproute/iproute.c
@@ -343,14 +343,14 @@
NEXT_ARG();
}
if (get_unsigned(&mtu, *argv, 0)) {
- invarg("\"mtu\" value is invalid\n", *argv);
+ invarg(*argv, "mtu");
}
rta_addattr32(mxrta, sizeof(mxbuf), RTAX_MTU, mtu);
} else if (matches(*argv, "protocol") == 0) {
uint32_t prot;
NEXT_ARG();
if (rtnl_rtprot_a2n(&prot, *argv))
- invarg("\"protocol\" value is invalid\n", *argv);
+ invarg(*argv, "protocol");
req.r.rtm_protocol = prot;
proto_ok =1;
} else if (strcmp(*argv, "dev") == 0 ||
@@ -487,7 +487,7 @@
filter.tb = RT_TABLE_MAIN;
if (flush && argc <= 0) {
- fprintf(stderr, "\"ip route flush\" requires arguments.\n");
+ bb_error_msg(bb_msg_requires_arg, "\"ip route flush\"");
return -1;
}
@@ -498,7 +498,7 @@
filter.protocolmask = -1;
if (rtnl_rtprot_a2n(&prot, *argv)) {
if (strcmp(*argv, "all") != 0) {
- invarg("invalid \"protocol\"\n", *argv);
+ invarg(*argv, "protocol");
}
prot = 0;
filter.protocolmask = 0;
@@ -541,7 +541,7 @@
if (matches(*argv, "cache") == 0) {
filter.tb = -1;
} else if (matches(*argv, "main") != 0) {
- invarg("invalid \"table\"", *argv);
+ invarg(*argv, "table");
}
} else if (matches(*argv, "cache") == 0) {
filter.tb = -1;
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c
index 1b1458e..9b96920 100644
--- a/networking/libiproute/iptunnel.c
+++ b/networking/libiproute/iptunnel.c
@@ -259,9 +259,9 @@
NEXT_ARG();
if (strcmp(*argv, "inherit") != 0) {
if (get_unsigned(&uval, *argv, 0))
- invarg("invalid TTL\n", *argv);
+ invarg(*argv, "TTL");
if (uval > 255)
- invarg("TTL must be <=255\n", *argv);
+ invarg(*argv, "TTL must be <=255");
p->iph.ttl = uval;
}
} else if (strcmp(*argv, "tos") == 0 ||
@@ -270,7 +270,7 @@
NEXT_ARG();
if (strcmp(*argv, "inherit") != 0) {
if (rtnl_dsfield_a2n(&uval, *argv))
- invarg("bad TOS value", *argv);
+ invarg(*argv, "TOS");
p->iph.tos = uval;
} else
p->iph.tos = 1;
diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c
index 3a161ea..2e2aa90 100644
--- a/networking/libiproute/utils.c
+++ b/networking/libiproute/utils.c
@@ -240,9 +240,9 @@
exit(-1);
}
-void invarg(char *msg, char *arg)
+void invarg(const char const *arg, const char const *opt)
{
- bb_error_msg("argument \"%s\" is wrong: %s", arg, msg);
+ bb_error_msg(bb_msg_invalid_arg, arg, opt);
exit(-1);
}
diff --git a/networking/libiproute/utils.h b/networking/libiproute/utils.h
index 0a3a06c..af286c8 100644
--- a/networking/libiproute/utils.h
+++ b/networking/libiproute/utils.h
@@ -1,13 +1,13 @@
#ifndef __UTILS_H__
#define __UTILS_H__ 1
+#include "libbb.h"
#include <asm/types.h>
#include <resolv.h>
#include "libnetlink.h"
#include "ll_map.h"
#include "rtm_map.h"
-#include "libbb.h"
extern int preferred_family;
extern int show_stats;
@@ -77,7 +77,7 @@
extern const char *format_host(int af, int len, void *addr, char *buf, int buflen);
extern const char *rt_addr_n2a(int af, int len, void *addr, char *buf, int buflen);
-void invarg(char *, char *) ATTRIBUTE_NORETURN;
+void invarg(const char const*, const char const*) ATTRIBUTE_NORETURN;
void duparg(char *, char *) ATTRIBUTE_NORETURN;
void duparg2(char *, char *) ATTRIBUTE_NORETURN;
int matches(char *arg, char *pattern);