net.c: Combine host_and_port() and __get_sock_name().
authorAndre Noll <maan@systemlinux.org>
Fri, 22 Apr 2011 02:21:48 +0000 (04:21 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 22 May 2011 13:24:17 +0000 (15:24 +0200)
commitf974934221902c3b440a21e845d6200f89ae8f12
tree536d2faca242867612a74cf3e7014b95bc234ffd
parent13f672993a23637fe8ad76d9ebc64fe774528f5d
net.c: Combine host_and_port() and __get_sock_name().

host_and_port() is only called by __get_sock_name().
Both functions are short enough, and merging these
two functions has the additional benefit that we can
always return the same static buffer.

Compiling with -Wwrite-strings previously caused a
warning due to returning either a string literal, or
the static buffer. We now always print into that buffer
and return it.

This also improves the error message which is returned
in the static buffer in case of failures: Previously we
returned "(don't know)" if getname() failed and "(unknown)"
if getnameinfo() failed. This turns it into "(unknown)" in
the former case and "(lookup error)" otherwise.
net.c