Subject: pkg/36520: parallel/pvm3 build fails
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <jbernard@mines.edu>
List: pkgsrc-bugs
Date: 06/20/2007 13:50:00
>Number:         36520
>Category:       pkg
>Synopsis:       parallel/pvm3 build fails
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 20 13:50:00 +0000 2007
>Originator:     Jim Bernard
>Release:        NetBSD 4.99.20
>Organization:
>Environment:
System: NetBSD 4.99.20 #0: Fri Jun 8 15:06:22 MDT 2007 i386
Architecture: i386
Machine: i386
>Description:
	Compilation of the file src/host.c fails:

	  ===> Building for pvm-3.4.5nb3
	  ./lib/aimk -here -f ./conf/`./lib/pvmtmparch`.def -f ./Makefile.aimk all
	  making in . for NETBSDI386
	  make[1]: Entering directory `/usr/pkgsrc/parallel/pvm3/work/pvm3'
	  building in src
	  cd src; ../lib/aimk CC="cc" F77="f77" CFLOPTS="-O2 -I/usr/pkg/include" FFLOPTS="-O" install
	  making in NETBSDI386/ for NETBSDI386
	  make[2]: Entering directory `/usr/pkgsrc/parallel/pvm3/work/pvm3/src/NETBSDI386'
	  libtool  --mode=compile cc -O2 -I/usr/pkg/include -DCLUMP_ALLOC -DSTATISTICS -DTIMESTAMPLOG -DSANITY -I../../include -DARCHCLASS=\"NETBSDI386\" -DIMA_NETBSDI386 -DHASSTDLIB -DCTIMEISTIMET -DSOCKADHASLEN -DRSHCOMMAND=\"/usr/bin/ssh\" -DHASERRORVARS -DNOREXEC -DNEEDMENDIAN -DSYSERRISCONST -DHASSTDLIB -c ../../src/host.c
	   cc -O2 -I/usr/pkgsrc/parallel/pvm3/work/.buildlink/include -DCLUMP_ALLOC -DSTATISTICS -DTIMESTAMPLOG -DSANITY -I../../include -DARCHCLASS=\"NETBSDI386\" -DIMA_NETBSDI386 -DHASSTDLIB -DCTIMEISTIMET -DSOCKADHASLEN -DRSHCOMMAND=\"/usr/bin/ssh\" -DHASERRORVARS -DNOREXEC -DNEEDMENDIAN -DSYSERRISCONST -c ../../src/host.c  -fPIC -DPIC -o .libs/host.o
	   ../../src/host.c: In function 'iflist':
	   ../../src/host.c:995: error: invalid operands to binary -
	   make[2]: *** [host.o] Error 1
	   make[2]: Leaving directory `/usr/pkgsrc/parallel/pvm3/work/pvm3/src/NETBSDI386'
	   make[1]: *** [s] Error 2
	   make[1]: Leaving directory `/usr/pkgsrc/parallel/pvm3/work/pvm3'
	   gmake: *** [all] Error 2
	   *** Error code 2

	   Stop.

	The offending line in iflist() is:

	  cp - sif.ifc_ifcu.ifcu_buf < sif.ifc_len;

	which is in the context of a for statement:

	  for (cp = sif.ifc_ifcu.ifcu_buf;
		cp - sif.ifc_ifcu.ifcu_buf < sif.ifc_len;
		...

	Now, cp is declared by:

	  char *cp;

	and sif is:

	  struct ifconf sif;

	ifconf is declared in /usr/include/net/if.h, where ifc_ifcu.ifcu_buf
	is declared

	  void *  ifcu_buf;

	That declaration was changed from caddr_t (aka char *) in revision
	1.123 of if.h on March 4, 2007.  Evidently the compiler is perfectly
	happy to convert from void* to char* for the purposes of assignment
	in the previous line, but not for the purposes of subtraction in the
	offending statement.  An explicit cast makes the compiler happy:

		cp - (char *)sif.ifc_ifcu.ifcu_buf < sif.ifc_len;

>How-To-Repeat:
	cd .../pkgsrc/parallel/pvm3 && make

>Fix:
	Add the explicit cast.  Here's a replacement for patches/patch-bo
	that includes that change, together with the original patches
	from patch-bo:

$NetBSD$

--- src/host.c.orig	2004-01-14 11:50:55.000000000 -0700
+++ src/host.c
@@ -978,7 +978,7 @@ iflist(alp, np)
 #ifdef OSIOCGIFCONF
 #if defined(IMA_RS6K) || defined(IMA_RS6KMP) || defined(IMA_SP2MPI) \
 			|| defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2) \
-			|| defined(IMA_FREEBSD)
+			|| defined(IMA_FREEBSD) || defined(IMA_DRAGONFLY)
 		SIOCGIFCONF
 #else
 		OSIOCGIFCONF
@@ -992,7 +992,7 @@ iflist(alp, np)
 	}
 
 	for (cp = sif.ifc_ifcu.ifcu_buf;
-			cp - sif.ifc_ifcu.ifcu_buf < sif.ifc_len;
+			cp - (char *)sif.ifc_ifcu.ifcu_buf < sif.ifc_len;
 			cp += sizeof(*reqp) - sizeof(struct sockaddr) + SIZ(reqp->ifr_addr))
 	{
 		reqp = (struct ifreq*)cp;
@@ -1005,7 +1005,11 @@ iflist(alp, np)
 		}
 		/* On some FreeBSD systems: */
 		/* if (IFF_UP & req.ifr_flags) { */
+#ifdef IMA_DRAGONFLY
+		if (IFF_UP & req.ifr_flags) {
+#else
 		if (IFF_UP & req.ifr_ifru.ifru_flags) {
+#endif
 			if (nip > 0 && !(nip % 10))
 				iplist = TREALLOC(iplist, (nip + 10), struct in_addr);
 			iplist[nip++] =