Possible non-conformance to POSIX

Bruce Evans brde at optusnet.com.au
Tue Nov 27 22:39:39 UTC 2012


On Tue, 27 Nov 2012, Martin Sustrik wrote:

> I've just noted the following:
>
> #include <netinet/in.h>
> INADDR_ANY;
>
> The above results in 'u_int32_t undefined' error, which it shouldn't 
> according to POSIX.

<netinet/in.h> is careful to only declare uint32_t, but then it is
broken and uses u_int32_t for INADDR_ANY and INADDR_BROADCAST.
u_int32_t is also misused extensively in the definitions of INADDR_*
and IN_* under __BSD_VISIBLE.  INADDR_ANY is broken even if __BSD_VISIBLE
is nonzero (the default), because the u_int32_t pollution is not
automatically supplied with __BSD_VISIBLE.  It takes including
<sys/types.h> (with __BSD_VISIBLE) to get it.

Nearby bugs: missing parentheses in the definitions of INADDR_ANY and
INADDR_BROADCAST.  Similarly for definitions under __BSD_VISIBLE.
Casts bind tightly (they are at the second level of precedence --
see `man operator'), so it takes very weird usage for these bugs
to matter.

Nearby style bugs: some of the not-so-extensive use of uint32_t is
probably a misspelling of in_addr_t.

Bruce


More information about the freebsd-bugs mailing list