From alane@geeksrus.net  Mon Feb 18 01:22:57 2002
Return-Path: <alane@geeksrus.net>
Received: from wwweasel.geeksrus.net (wwweasel.geeksrus.net [64.8.210.226])
	by hub.freebsd.org (Postfix) with ESMTP id CD09A37B402
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 18 Feb 2002 01:22:56 -0800 (PST)
Received: (from alane@localhost)
	by wwweasel.geeksrus.net (8.11.6/8.11.6) id g1I9LQV02856;
	Mon, 18 Feb 2002 04:21:26 -0500 (EST)
	(envelope-from alane)
Message-Id: <200202180921.g1I9LQV02856@wwweasel.geeksrus.net>
Date: Mon, 18 Feb 2002 04:21:26 -0500 (EST)
From: Alan Eldridge <ports@geeksrus.net>
Reply-To: Alan Eldridge <ports@geeksrus.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: include/arpa/inet.h broken: must include <netinet/in.h>
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         35071
>Category:       bin
>Synopsis:       include/arpa/inet.h broken: must include <netinet/in.h>
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Feb 18 01:30:01 PST 2002
>Closed-Date:    Sat Mar 9 23:49:32 PST 2002
>Last-Modified:  Sun Mar 10 01:00:03 PST 2002
>Originator:     Alan Eldridge
>Release:        FreeBSD 4.5-STABLE i386
>Organization:
Geeksrus.NET
>Environment:
System: FreeBSD wwweasel.geeksrus.net 4.5-STABLE FreeBSD 4.5-STABLE #0: Fri Feb 8 21:25:34 EST 2002 root@wwweasel.geeksrus.net:/usr/obj/usr/src/sys/WWWEASEL i386

>Description:

According to Single Unix Spec Version 2:

<quote>
DESCRIPTION

The <arpa/inet.h> header makes available the type in_port_t and the type in_addr_t as defined in the description of <netinet/in.h>. 

The <arpa/inet.h> header makes available the in_addr structure, as defined in the description of <netinet/in.h>. 

	:
	:
	:

 Inclusion of the <arpa/inet.h> header may also make visible all symbols from <netinet/in.h> and <inttypes.h>. 
</quote>

We fail on the second sentence. The third sentence allows us to simply
include <netinet/in.h> rather than requiring that we play type-defining-macro
games.

Note that software that compiles on other Unices fails on FreeBSD for this
reason. The wget package is about to become the newest casualty; it's CVS
version will not compile without patching on FBSD, so their next release of
1.8.2 won't either.

>How-To-Repeat:

[alane ~]$ cat t.c
#include <arpa/inet.h>
[alane ~]$ cc -c t.c
In file included from t.c:1:
/usr/include/arpa/inet.h:89: warning: parameter has incomplete type
/usr/include/arpa/inet.h:92: warning: parameter has incomplete type
/usr/include/arpa/inet.h:96: warning: parameter has incomplete type
[alane ~]$

>Fix:

---8<-snip---8<-snip---8<-snip---8<-snip---8<-snip---8<-snip---8<---
--- include/arpa/inet.h.orig	Sat Apr 21 10:53:03 2001
+++ include/arpa/inet.h	Mon Feb 18 04:10:23 2002
@@ -62,8 +62,7 @@
 
 #include <sys/types.h>
 #include <sys/cdefs.h>
-
-struct in_addr;
+#include <netinet/in.h>
 
 /* XXX all new diversions!! argh!! */
 #define	inet_addr	__inet_addr
---8<-snip---8<-snip---8<-snip---8<-snip---8<-snip---8<-snip---8<---



>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: mike 
State-Changed-When: Sat Mar 9 23:49:32 PST 2002 
State-Changed-Why:  

<arpa/inet.h> and <netinet/in.h> will never conform to SUSv2 in the 
4.x branch, but 5.0-RELEASE will resolve this issue.  The patch 
submitted in this PR takes advantage of which I consider to be 
mistakes in SUSv2 and other standards, which allow for sloppy 
implementations.  Needless to say, this is not the approach taken in 
5.0. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=35071 

From: Alan Eldridge <alane@geeksrus.net>
To: mike@FreeBSD.org
Cc: freebsd-bugs@FreeBSD.org,
	FreeBSD Bugs <freebsd-gnats-submit@FreeBSD.org>
Subject: Re: bin/35071: include/arpa/inet.h broken: must include <netinet/in.h>
Date: Sun, 10 Mar 2002 03:58:34 -0500

 On Sat, Mar 09, 2002 at 11:57:17PM -0800, mike@FreeBSD.org wrote:
 >Synopsis: include/arpa/inet.h broken: must include <netinet/in.h>
 
 ><arpa/inet.h> and <netinet/in.h> will never conform to SUSv2 in the
 >4.x branch, but 5.0-RELEASE will resolve this issue.  The patch
 >submitted in this PR takes advantage of which I consider to be
 >mistakes in SUSv2 and other standards, which allow for sloppy
 >implementations.  Needless to say, this is not the approach taken in
 >5.0.
 
 Perhaps I should have been more explicit: there is a missing
 structure definition that provokes "incomplete type" warnings (at best)
 and compilation errors (in cases where the code include the header
 actually uses 'struct in_addr').
 
 The fact that including a system header will unconditionally provoke
 compiler warnings is sufficient for me to label that header "broken".
 (In the 20+ years that I have been doing "C" development, I have
 seen very few occasions where a compilation warning was truly innocuous;
 at best, they indicate sloppy coding practice.)
 
 AFAIK, other Unixes manage to get this right. There is code out there,
 in real applications, that assumes (IMO, correctly) that it will get
 'struct in_addr' with "include <arpa/inet.h>". I had to recently make
 patches to wget's CVS tree because of this issue, for example.
 
 Including <netinet/in.h> was the easies, and least intrusive method
 to fix this; it is by no means the most elegant, nor was it advertised
 as such. 
 
 I don't disagree that a different solution would be preferable to the
 one proposed; I do strongly disagree that no solution should be
 forthcoming until 5.0-RELEASE. A temporary fix to 4.x, pending the
 "real" one in 5.0, is better than none at all.
 
 -- 
 Alan Eldridge
 "Dave's not here, man."
>Unformatted:
