Subject: pkg/34838: news/nn does not compile (NetBSD 3.0)
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <kre@munnari.OZ.AU>
List: pkgsrc-bugs
Date: 10/17/2006 09:55:01
>Number:         34838
>Category:       pkg
>Synopsis:       news/nn does not compile (NetBSD 3.0)
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 17 09:55:00 +0000 2006
>Originator:     Robert Elz
>Release:        NetBSD 3.99.15  (pkgsrc current within last hour or two)
>Organization:
	Prince of Songkla University
>Environment:
	
	
System: NetBSD jade.coe.psu.ac.th 3.99.15 NetBSD 3.99.15 (GENERIC-1.696-20060125) #8: Wed Jan 25 04:59:39 ICT 2006 kre@jade.coe.psu.ac.th:/usr/obj/current/kernels/JADE_ASUS i386
Architecture: i386
Machine: i386
>Description:
	I have no idea what systems news/nn actually compiles
	successfully on (except probably irix, where it looks to
	be handled), but as it is it uses sockaddr_in and (on most(?)
	systems) doesn't include netinet/in.h

>How-To-Repeat:
	Attempt to compile news/nn on NetBSD - most likely any NetBSD
	version would do, I'm using pkg_comp with NetBSD 3.0 release
	sets installed (so a pretty pure NetBSD 3.0 environment).

	Expect to see ...

cc -Iconf -O2  -c nntp.c
nntp.c: In function `get_socket':
nntp.c:295: error: storage size of `sin' isn't known
*** Error code 1

	That's from this line of code ...

	    struct sockaddr_in sin; 

	which suggests that sockaddr_in isn't defined.
	And sure, enough, around lines 60-65 of nntp.c
	there appears ...

/* This is necessary due to the definitions in m-XXX.h */
/* IRIX needs it for struct sockaddr_in */

#if !defined(NETWORK_DATABASE) || defined(NETWORK_BYTE_ORDER) || defined(__sgi)
#include <netinet/in.h>
#endif

	which doesn't manage to include netinet/in.h on NetBSD systems.

>Fix:

	Patching nntp.c to add
		|| defined(__NetBSD__)
	to the #if allowed it to compile for me.

	A better fix would be to get rid of the use of sockaddr_in and
	get getaddrinfo() instead of gethostbyname(0 and getservbynam()
	(wich might possibly also be extended to allow IPv6 to work, but
	I certainly haven't tested that)

	Howwever, this (adjusting the #if) might not be the right solution.
	What systems (if any) don't require (or at least, allow) netinet/in.h
	to be included to define sockaaddr_in ?   That's where the
	struct definition has been since it was invented.  If there are
	no such systems, then simply remove the #if/#endif completely,
	and leave the #include always being included would seem like
	a better idea.