A blank string might be very confusing, depending on where this will be
used. Let's give something more visible back in the cases where we
cannot get the proper name for the peer.
if (getpeername(getFd(), &sa.u.sa, &sa_size) != 0) {
vlog.error("unable to get peer name for socket");
- return "";
+ return "(N/A)";
}
if (sa.u.sa.sa_family == AF_INET6) {
NI_NUMERICHOST);
if (ret != 0) {
vlog.error("unable to convert peer name to a string");
- return "";
+ return "(N/A)";
}
strcat(buffer, "]");
name = inet_ntoa(sa.u.sin.sin_addr);
if (name == NULL) {
vlog.error("unable to convert peer name to a string");
- return "";
+ return "(N/A)";
}
return name;