inet_ntop() has a signature as follows:
const char* inet_ntop(int af, const void* src, char* dst, socklen_t size);
Description:
This function converts the network address structure src in the
af address family into a character string. The resulting string
is copied to the buffer pointed to by dst, which must be a non-
null pointer. The caller specifies the number of bytes available
in this buffer in the argument size.
On success, inet_ntop() returns a non-null pointer to dst, or NULL
if there was an error.
The pattern for socket operations (e.g., getsockopt(), socket(), bind(), listen(), connect(), etc.) is typically to return an int, indicating (0) success, or (-1) error.
It seems redundant for inet_ntop() to return a pointer to the very data structure that the caller passed into it -- dst. Obviously, that datum was already known by the caller, since it was required to be passed into the function. There has to be some compelling reason for this to step away from the convention; returning redundant information surely cannot be such.
I'm feeling pretty stupid for just not seeing the reason for this. Any insight?