From f42640a36227fc8ff52affded91834647c8abddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Sat, 4 Dec 2010 14:19:35 +0000 Subject: [PATCH] traceroute6(8): make WARNS=3 clean --- usr.sbin/traceroute6/Makefile | 2 +- usr.sbin/traceroute6/traceroute6.c | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/usr.sbin/traceroute6/Makefile b/usr.sbin/traceroute6/Makefile index e0b72a13cd03..4428d5b46389 100644 --- a/usr.sbin/traceroute6/Makefile +++ b/usr.sbin/traceroute6/Makefile @@ -25,7 +25,7 @@ BINMODE= 4555 CFLAGS+= -DIPSEC -DUSE_RFC2292BIS -DHAVE_POLL CFLAGS+= -I${.CURDIR} -I${TRACEROUTE_DISTDIR} -I. -WARNS?= 1 +WARNS?= 3 DPADD= ${LIBIPSEC} LDADD= -lipsec diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c index 699af68c1ddd..1a67173dcdfa 100644 --- a/usr.sbin/traceroute6/traceroute6.c +++ b/usr.sbin/traceroute6/traceroute6.c @@ -66,7 +66,7 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1990, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ @@ -322,7 +322,7 @@ void send_probe(int, u_long); void *get_uphdr(struct ip6_hdr *, u_char *); int get_hoplim(struct msghdr *); double deltaT(struct timeval *, struct timeval *); -char *pr_type(int); +const char *pr_type(int); int packet_ok(struct msghdr *, int, int); void print(struct msghdr *, int); const char *inetname(struct sockaddr *); @@ -372,12 +372,12 @@ main(argc, argv) { int mib[4] = { CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_DEFHLIM }; char hbuf[NI_MAXHOST], src0[NI_MAXHOST], *ep; - int ch, i, on = 1, seq, rcvcmsglen, error, minlen; + int ch, i, on = 1, seq, rcvcmsglen, error; struct addrinfo hints, *res; static u_char *rcvcmsgbuf; u_long probe, hops, lport; struct hostent *hp; - size_t size; + size_t size, minlen; uid_t uid; /* @@ -671,11 +671,11 @@ main(argc, argv) datalen = minlen; else if (datalen >= MAXPACKET) { fprintf(stderr, - "traceroute6: packet size must be %d <= s < %ld.\n", - minlen, (long)MAXPACKET); + "traceroute6: packet size must be %zu <= s < %d.\n", + minlen, MAXPACKET); exit(1); } - outpacket = (struct opacket *)malloc((unsigned)datalen); + outpacket = malloc(datalen); if (!outpacket) { perror("malloc"); exit(1); @@ -913,7 +913,7 @@ main(argc, argv) for (hops = first_hop; hops <= max_hops; ++hops) { struct in6_addr lastaddr; int got_there = 0; - int unreachable = 0; + unsigned unreachable = 0; printf("%2lu ", hops); bzero(&lastaddr, sizeof(lastaddr)); @@ -1089,7 +1089,7 @@ send_probe(seq, hops) i = sendto(sndsock, (char *)outpacket, datalen, 0, (struct sockaddr *)&Dst, Dst.sin6_len); - if (i < 0 || i != datalen) { + if (i < 0 || (u_long)i != datalen) { if (i < 0) perror("sendto"); printf("traceroute6: wrote %s %lu chars, ret=%d\n", @@ -1129,12 +1129,11 @@ deltaT(t1p, t2p) /* * Convert an ICMP "type" field to a printable string. */ -char * -pr_type(t0) - int t0; +const char * +pr_type(int t0) { u_char t = t0 & 0xff; - char *cp; + const char *cp; switch (t) { case ICMP6_DST_UNREACH: @@ -1221,7 +1220,7 @@ packet_ok(mhdr, cc, seq) cc -= hlen; icp = (struct icmp6_hdr *)(buf + hlen); #else - if (cc < sizeof(struct icmp6_hdr)) { + if (cc < (int)sizeof(struct icmp6_hdr)) { if (verbose) { if (getnameinfo((struct sockaddr *)from, from->sin6_len, hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST) != 0)