[PATCH] netstat: Produce non-NULL output for netstat
Denys Vlasenko
vda.linux at googlemail.com
Tue Mar 27 21:30:47 UTC 2018
Applied, thanks!
On Mon, Mar 19, 2018 at 10:45 AM, <mark.marshall at omicronenergy.com> wrote:
> From: Mark Marshall <mark.marshall at omicronenergy.com>
>
> If we don't ask for numerical output, and the symbolic look-up failed
> we used to get "(null)", but the numeric output would be better.
>
> Signed-off-by: Mark Marshall <mark.marshall at omicronenergy.com>
> ---
> networking/netstat.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/networking/netstat.c b/networking/netstat.c
> index 33281e3..f6bcd44 100644
> --- a/networking/netstat.c
> +++ b/networking/netstat.c
> @@ -397,8 +397,11 @@ static char *ip_port_str(struct sockaddr *addr, int port, const char *proto, int
> /* Code which used "*" for INADDR_ANY is removed: it's ambiguous
> * in IPv6, while "0.0.0.0" is not. */
>
> - host = numeric ? xmalloc_sockaddr2dotted_noport(addr)
> - : xmalloc_sockaddr2host_noport(addr);
> + host = NULL;
> + if (!numeric)
> + host = xmalloc_sockaddr2host_noport(addr);
> + if (!host)
> + host = xmalloc_sockaddr2dotted_noport(addr);
>
> host_port = xasprintf("%s:%s", host, get_sname(htons(port), proto, numeric));
> free(host);
> --
> 2.7.4
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list