aboutsummaryrefslogtreecommitdiff
path: root/networking/libiproute/utils.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-14 13:56:42 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-14 13:56:42 +0200
commit926d801fa51717b3af3faf33f9d686e92a20ecfd (patch)
treebe5d1e982d1ec0330055ebeb0e216eca9a07892f /networking/libiproute/utils.c
parent0f296a3a56b52842057e5a2bc653621a3a6c7bec (diff)
downloadbusybox-926d801fa51717b3af3faf33f9d686e92a20ecfd.tar.gz
libiproute: make rt_addr_n2a() and format_host() return auto strings
function old new delta rt_addr_n2a 56 53 -3 print_addrinfo 1227 1178 -49 print_neigh 933 881 -52 print_rule 689 617 -72 print_tunnel 640 560 -80 print_route 1727 1588 -139 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/6 up/down: 0/-395) Total: -395 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/libiproute/utils.c')
-rw-r--r--networking/libiproute/utils.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c
index 7f7cb4203..42025bc66 100644
--- a/networking/libiproute/utils.c
+++ b/networking/libiproute/utils.c
@@ -276,20 +276,21 @@ int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits)
return 0;
}
-const char *rt_addr_n2a(int af,
- void *addr, char *buf, int buflen)
+const char *rt_addr_n2a(int af, void *addr)
{
switch (af) {
case AF_INET:
case AF_INET6:
- return inet_ntop(af, addr, buf, buflen);
+ return inet_ntop(af, addr,
+ auto_string(xzalloc(INET6_ADDRSTRLEN)), INET6_ADDRSTRLEN
+ );
default:
return "???";
}
}
#ifdef RESOLVE_HOSTNAMES
-const char *format_host(int af, int len, void *addr, char *buf, int buflen)
+const char *format_host(int af, int len, void *addr)
{
if (resolve_hosts) {
struct hostent *h_ent;
@@ -308,11 +309,10 @@ const char *format_host(int af, int len, void *addr, char *buf, int buflen)
if (len > 0) {
h_ent = gethostbyaddr(addr, len, af);
if (h_ent != NULL) {
- safe_strncpy(buf, h_ent->h_name, buflen);
- return buf;
+ return auto_string(xstrdup(h_ent->h_name));
}
}
}
- return rt_addr_n2a(af, addr, buf, buflen);
+ return rt_addr_n2a(af, addr);
}
#endif