Page MenuHomeFreeBSD

gethostbyname(3): Add missing reentrant functions
ClosedPublic

Authored by fernape on May 21 2021, 3:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 24, 7:41 AM
Unknown Object (File)
Mon, Nov 11, 11:52 AM
Unknown Object (File)
Oct 26 2024, 2:51 PM
Unknown Object (File)
Oct 26 2024, 2:50 PM
Unknown Object (File)
Oct 26 2024, 2:50 PM
Unknown Object (File)
Oct 26 2024, 2:50 PM
Unknown Object (File)
Oct 26 2024, 2:31 PM
Unknown Object (File)
Oct 26 2024, 5:56 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
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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 ↗(On Diff #89805)

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

68–73 ↗(On Diff #89805)

Same question as abofee

lib/libc/net/gethostbyname.3
43–45 ↗(On Diff #89805)

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