Page MenuHomeFreeBSD

gethostbyname(3): Add missing reentrant functions
ClosedPublic

Authored by fernape on May 21 2021, 3:37 PM.
Tags
None
Referenced Files
F122499537: D30385.id.diff
Sat, Jul 5, 7:35 PM
Unknown Object (File)
Wed, Jul 2, 4:36 PM
Unknown Object (File)
Sat, Jun 28, 3:48 AM
Unknown Object (File)
Fri, Jun 27, 6:49 AM
Unknown Object (File)
Wed, Jun 25, 9:48 PM
Unknown Object (File)
Tue, Jun 24, 8:27 PM
Unknown Object (File)
Mon, Jun 23, 5:26 PM
Unknown Object (File)
Mon, Jun 16, 5:16 AM

Details

Summary

Add documentation for gethostbyname_r, gethostbyname2_r and gethostbyaddr_r

Create proper MLINKs for the new functions.

PR: 249154
Reported by: asomers@

Test Plan

Before the change:

$ man gethostbyname_r
No manual entry for gethostbyname_r

After the change, the new documentation is accessible.

  • mandoc -Tlint clean (useless .Tn macro and Xr named(8) reported)
  • igor clean (deferring .Dd bump)
  • aspell happy
  • man ./gethostbyname.3 renders the page properly

Tested several things with this small program:

#include <err.h>
#include <netdb.h>
#include <stdio.h>

int
main()
{
        char *name = "localhost";
        char buflen = 100;
        char buffer[buflen];
        struct hostent he;
        struct hostent *result = NULL;
        int h_errnop, ret;

        if ((ret = gethostbyname_r(name, &he, buffer, buflen, &result, &h_errnop))) {
                errx(1, "no name associated with %s. result = %p. ret = %d",
                                name, result, ret);
        }

        printf("name associated with %s is %s\n", name, result->h_name);

        return 0;
}

Note that we don't have named(8) anymore in base, but I would remove that in
a different commit.

Also note the documentation for some getnet*_r functions is missing. I would
rather do this in small pieces.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 39341
Build 36230: arc lint + arc unit

Event Timeline

Sort entries alphabetically in the Makefile

Can I have some feedback here so I can move forward with this?

seems fine. If you don't get other feedback in a reasonable amount of time, go ahead, imho.

This revision is now accepted and ready to land.Jun 13 2022, 8:27 PM
pauamma_gundo.com added inline comments.
lib/libc/net/gethostbyname.3
43–45

Keep _r functions together, or each next to the corresponding non-_r?

68–73

Same question as abofee

lib/libc/net/gethostbyname.3
43–45

I would keep them together. See cap_endgrent(3), cap_pwd(3)