Project

General

Profile

Actions

Bug #14104

open

getaddrinfo() man page differs from netdb.h (and POSIX)

Added by Jim Klimov 2 months ago. Updated 2 months ago.

Status:
New
Priority:
Low
Assignee:
-
Category:
manpage - manual pages
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:
man
Gerrit CR:

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.

Actions #1

Updated by Jim Klimov 2 months 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

Also available in: Atom PDF