[Bug 271131] net/asterisk18: utils.c:99:12: error: static declaration of 'gethostbyname_r' follows non-static declaration

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 09 May 2023 19:15:57 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271131

--- Comment #6 from O. Hartmann <ohartmann@walstatt.org> ---
Hello,

I'm running into the very same issue here on CURRENT builder host, running
13-STABLE jail:

=>> Building net/asterisk18
build started at Mon May  8 08:36:14 UTC 2023
port directory: /usr/ports/net/asterisk18
package name: asterisk18-18.17.1_1
[...]
13.2-STABLE 1302505 amd64
[...]
/net/asterisk18/Makefile
Ports top last git commit: ec23a17e0f51
Ports top unclean checkout: no
Port dir last git commit: 6ee7f9f1ae2e
Port dir unclean checkout: no
Poudriere version: poudriere-git-3.3.99.20220831
Host OSVERSION: 1400088
Jail OSVERSION: 1302505
Job Id: 02

poudriere shows the very same error as reported before.

My understanding of the techniques of the C code is limited, but looking at 

main/utils.c

reveals that there is a static declaration of gethostbyname_r() (as reported in
the error) for which the comment says it is a replacement for BSD-versions, see
below.

Checking the manpages for gethostbyname_r(), found in libc, obviously
prototyped in /usr/include/netdb.h definitely states, that the routine is
threadsafe AND reentrant!
I have not checked with upstream so far, but I found it logic to eliminate the
extranous gehthostbyname_r() routine in main/utils.c with the (clumsy) #ifdef
clause show below - and the code is compiling. Haven't tested it.

I have no idea since when the code starts to bread to determine
__FreeBSD_version, but this might be a first approach to a workaround?

Otherwise, sorry for the noise, if the suggestion is illogical and ill-adviced.

[... main/utisl.c ...]
/*! \brief Reentrant replacement for gethostbyname for BSD-based systems.
\note This
routine is derived from code originally written and placed in the public
domain by Enzo Michelangeli <em@em.no-ip.com> */

#if !defined(__FreeBSD__)
static int gethostbyname_r (const char *name, struct hostent *ret, char *buf,
                size_t buflen, struct hostent **result,
                int *h_errnop)
[...]
}
#endif

-- 
You are receiving this mail because:
You are the assignee for the bug.