$Id: update-patches 24 2008-08-31 14:56:13Z wbx $
--- ndisc6-0.9.8.orig/src/traceroute.c	2008-05-01 14:52:28.000000000 +0200
+++ ndisc6-0.9.8/src/traceroute.c	2009-05-10 19:31:06.000000000 +0200
@@ -149,6 +149,7 @@ static ssize_t
 recv_payload (int fd, void *buf, size_t len,
               struct sockaddr_in6 *addr, int *hlim)
 {
+	struct cmsghdr *cmsg;
 	char cbuf[CMSG_SPACE (sizeof (int))];
 	struct iovec iov =
 	{
@@ -170,7 +171,7 @@ recv_payload (int fd, void *buf, size_t 
 		return val;
 
 	/* ensures the hop limit is 255 */
-	for (struct cmsghdr *cmsg = CMSG_FIRSTHDR (&hdr);
+	for (cmsg = CMSG_FIRSTHDR (&hdr);
 	     cmsg != NULL;
 	     cmsg = CMSG_NXTHDR (&hdr, cmsg))
 		if ((cmsg->cmsg_level == IPPROTO_IPV6)
@@ -625,14 +626,16 @@ static void
 display (const tracetest_t *tab, unsigned min_ttl, unsigned max_ttl,
          unsigned retries)
 {
-	for (unsigned ttl = min_ttl; ttl <= max_ttl; ttl++)
+	unsigned int ttl, col;
+
+	for (ttl = min_ttl; ttl <= max_ttl; ttl++)
 	{
 		struct sockaddr_in6 hop = { .sin6_family = AF_UNSPEC };
 		const tracetest_t *line = tab + retries * (ttl - min_ttl);
 
 		printf ("%2d ", ttl);
 
-		for (unsigned col = 0; col < retries; col++)
+		for (col = 0; col < retries; col++)
 		{
 			const tracetest_t *test = line + col;
 			if (test->result == TRACE_TIMEOUT)
@@ -821,6 +824,7 @@ static void setup_socket (int fd)
 
 static int setsock_rth (int fd, int type, const char **segv, int segc)
 {
+	int i;
 	uint8_t hdr[inet6_rth_space (type, segc)];
 	inet6_rth_init (hdr, sizeof (hdr), type, segc);
 
@@ -829,7 +833,7 @@ static int setsock_rth (int fd, int type
 	hints.ai_family = AF_INET6;
 	hints.ai_flags = AI_IDN;
 
-	for (int i = 0; i < segc; i++)
+	for (i = 0; i < segc; i++)
 	{
 		struct addrinfo *res;
 
@@ -868,7 +872,8 @@ static struct
 
 static int prepare_sockets (void)
 {
-	for (unsigned i = 0; i < sizeof (protofd) / sizeof (protofd[0]); i++)
+	unsigned int i;
+	for (i = 0; i < sizeof (protofd) / sizeof (protofd[0]); i++)
 	{
 		protofd[i].fd = socket (AF_INET6, SOCK_RAW, protofd[i].protocol);
 		if (protofd[i].fd == -1)
@@ -883,8 +888,9 @@ static int prepare_sockets (void)
 
 static int get_socket (int protocol)
 {
+	unsigned int i;
 	errno = EPROTONOSUPPORT;
-	for (unsigned i = 0; i < sizeof (protofd) / sizeof (protofd[0]); i++)
+	for (i = 0; i < sizeof (protofd) / sizeof (protofd[0]); i++)
 		if (protofd[i].protocol == protocol)
 		{
 			int fd = protofd[i].fd;
@@ -902,7 +908,8 @@ static int get_socket (int protocol)
 
 static void drop_sockets (void)
 {
-	for (unsigned i = 0; i < sizeof (protofd) / sizeof (protofd[0]); i++)
+	unsigned int i;
+	for (i = 0; i < sizeof (protofd) / sizeof (protofd[0]); i++)
 		if (protofd[i].fd != -1)
 			close (protofd[i].fd);
 }
@@ -914,6 +921,8 @@ traceroute (const char *dsthost, const c
             unsigned timeout, unsigned delay, unsigned retries,
             size_t packet_len, int min_ttl, int max_ttl)
 {
+	unsigned int i, j, step, progress;
+
 	/* Creates ICMPv6 socket to collect error packets */
 	int icmpfd = get_socket (IPPROTO_ICMPV6);
 	if (icmpfd == -1)
@@ -1020,7 +1029,7 @@ traceroute (const char *dsthost, const c
 			.filter = f,
 		};
 
-		for (unsigned i = 0; i < 4; i++)
+		for (i = 0; i < 4; i++)
 		{
 			/* A = icmp->ip6_dst.s6_addr32[i]; */
 			pc->code = BPF_LD + BPF_W + BPF_ABS;
@@ -1076,7 +1085,7 @@ traceroute (const char *dsthost, const c
 		tracetest_t tab[(1 + max_ttl - min_ttl) * retries];
 		memset (tab, 0, sizeof (tab));
 
-		for (unsigned step = 1, progress = 0;
+		for (step = 1, progress = 0;
 		     step < (1 + max_ttl - min_ttl) + retries;
 		     step++)
 		{
@@ -1093,10 +1102,10 @@ traceroute (const char *dsthost, const c
 				mono_nanosleep (&delay_ts);
 
 			/* Sends requests */
-			for (unsigned i = 0; i < retries; i++)
+			for (j = 0; j < retries; j++)
 			{
-				int attempt = (retries - 1) - i;
-				int hlim = min_ttl + step + i - retries;
+				int attempt = (retries - 1) - j;
+				int hlim = min_ttl + step + j - retries;
 
 				if ((hlim > max_ttl) || (hlim < min_ttl))
 					continue;
