Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Jul 2010 09:48:37 -0700 (PDT)
From:      Jeremy Chadwick <freebsd@jdc.parodius.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        R.E.Wolff@BitWizard.nl
Subject:   ports/148524: net/mtr 0.79 -- RES_INIT macro conflict and unused variables on systems w/out IPv6
Message-ID:  <20100712164837.231759B425@icarus.home.lan>
Resent-Message-ID: <201007121650.o6CGo22n091250@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         148524
>Category:       ports
>Synopsis:       net/mtr 0.79 -- RES_INIT macro conflict and unused variables on systems w/out IPv6
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 12 16:50:02 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Jeremy Chadwick
>Release:        FreeBSD 8.1-PRERELEASE amd64
>Organization:
>Environment:
System: FreeBSD icarus.home.lan 8.1-PRERELEASE FreeBSD 8.1-PRERELEASE #0: Tue Jun 8 05:01:22 PDT 2010 root@icarus.home.lan:/usr/obj/usr/src/sys/X7SBA_RELENG_8_amd64 amd64
>Description:
	The author of mtr appears to have chosen a name for a macro
	which already exists on FreeBSD:

if cc -DHAVE_CONFIG_H -I. -I. -I.	-O2 -pipe -march=nocona -fno-strict-aliasing -Wall -Wno-pointer-sign -MT dns.o -MD -MP -MF ".deps/dns.Tpo" -c -o dns.o dns.c; \
	then mv -f ".deps/dns.Tpo" ".deps/dns.Po"; else rm -f ".deps/dns.Tpo"; exit 1; fi
dns.c:313:1: warning: "RES_INIT" redefined
In file included from dns.c:38:
/usr/include/resolv.h:230:1: warning: this is the location of the previous definition

	The difference is pretty severe however, meaning this could
	bite us later:

# cd /usr/ports/net/mtr
# grep -r RES_INIT .
./work/mtr-0.79/dns.c:#define RES_INIT() res_ninit(&myres);
./work/mtr-0.79/dns.c:#define RES_INIT() res_init();
./work/mtr-0.79/dns.c:  RES_INIT();
icarus# grep RES_INIT /usr/include/resolv.h
#define RES_INIT        0x00000001      /*%< address initialized */

	One's a macro to either res_init() or res_ninit(), while the other
	is a bitfield for resolver options.  Ouch.

	Next we have an "unused variable" warning which only happens if the
	software is built without IPv6 support:

if cc -DHAVE_CONFIG_H -I. -I. -I.	-O2 -pipe -march=nocona -fno-strict-aliasing -Wall -Wno-pointer-sign -MT net.o -MD -MP -MF ".deps/net.Tpo" -c -o net.o net.c; \
	then mv -f ".deps/net.Tpo" ".deps/net.Po"; else rm -f ".deps/net.Tpo"; exit 1; fi
net.c: In function 'net_send_query':
net.c:301: warning: unused variable 'offset'

	This one is easy to fix -- there's a missing #ifdef and #endif.
>How-To-Repeat:
	Attempt to build net/mtr 0.79, particularly on a system with WITHOUT_IPV6
	defined in make.conf (or maybe WITHOUT_INET6 in src.conf).
>Fix:
	The easiest way to deal with this is to rename mtr's macro to
	something like MY_RES_INIT.  As far as the unused variables goes,
	adding the necessary #ifdef/#endif should be sufficient.

	Below are two patch that should do both things.  Drop 'em in files/.

	These issues should be reported upstream to the author to be
	fixed in the official source.  I've CC'd him here.


--- dns.c.orig	2010-06-06 23:58:23.000000000 -0700
+++ dns.c	2010-07-12 09:40:15.000000000 -0700
@@ -310,12 +310,12 @@
 int use_dns = 1;
 
 #ifdef res_ninit
-#define RES_INIT() res_ninit(&myres);
+#define MY_RES_INIT() res_ninit(&myres);
 #define RES_MKQUERY(a, b, c, d, e, f, g, h, i) \
     res_nmkquery(&myres, a, b, c, d, e, f, g, h, i)
 struct __res_state myres;
 #else
-#define RES_INIT() res_init();
+#define MY_RES_INIT() res_init();
 #define RES_MKQUERY(a, b, c, d, e, f, g, h, i) \
     res_mkquery(a, b, c, d, e, f, g, h, i)
 #define myres _res
@@ -495,7 +495,7 @@
   int option,i;
 
   if (!dns) return;
-  RES_INIT();
+  MY_RES_INIT();
   if (!myres.nscount) {
     fprintf(stderr,"No nameservers defined.\n");
     exit(-1);



--- net.c.orig	2010-06-06 23:58:25.000000000 -0700
+++ net.c	2010-07-12 09:45:08.000000000 -0700
@@ -297,8 +297,10 @@
 
   ttl = index + 1;
 
+#ifdef ENABLE_IPV6
   /* offset for ipv6 checksum calculation */
   int offset = 6;
+#endif
 
   if ( packetsize < MINPACKET ) packetsize = MINPACKET;
   if ( packetsize > MAXPACKET ) packetsize = MAXPACKET;
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100712164837.231759B425>