From 926d801fa51717b3af3faf33f9d686e92a20ecfd Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 14 Oct 2015 13:56:42 +0200 Subject: 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 --- networking/libiproute/utils.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'networking/libiproute/utils.c') 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 -- cgit v1.2.3