Actions
Bug #14104
opengetaddrinfo() man page differs from netdb.h (and POSIX)
Status:
New
Priority:
Low
Assignee:
-
Category:
manpage - manual pages
Start date:
Due date:
% Done:
0%
Estimated time:
Difficulty:
Bite-size
Tags:
man
Gerrit CR:
External Bug:
Description
In system headers (/usr/include/netdb.h), we have
int getnameinfo(const struct sockaddr *_RESTRICT_KYWD, socklen_t, char *_RESTRICT_KYWD, socklen_t, char *_RESTRICT_KYWD, socklen_t, int);
and in man pages,
int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
Notably, socklen_t is not size_t for the third arg so with pedantic enough builds of code written in accordance with the docs, I get
error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'socklen_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
Upon further discussion on IRC, this seems to be a manpage problem (looks a lot like one in FreeBSD) while header actually conforms to POSIX: https://pubs.opengroup.org/onlinepubs/009604599/functions/getnameinfo.html
For ecosystem context:- Solaris docs are correct: https://docs.oracle.com/cd/E88353_01/html/E37843/getnameinfo-3c.html
- (Debian) Linux manpage and header are correct: it has socklen_t in all 3 spots
- FreeBSD 12 is "consistently" different:
freebsd manpage indeed says:int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
but their netdb.h also says:int getnameinfo(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int);
Thanks to AndyF for the context research and links.
Updated by Jim Klimov about 2 years ago
UPDATE: https://man.omnios.org/man3xnet/getnameinfo has it right, but it seems the page with the error has been in illumos since the start
There is a wrongly documented getnameinfo in another section https://man.omnios.org/man3socket/getnameinfo
Actions