看板 DFBSD_submit 關於我們 聯絡資訊
This is a multi-part message in MIME format. --------------010802010600040503000402 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit hi, this is patch against sbin/ping6. included: WARNS=6, remove register, add __DragonFly__ to #ifdef check, minor rewrite. Tested with gcc2 and gcc34. -- --------------010802010600040503000402 Content-Type: text/plain; name="ping6.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ping6.patch" * add __DragonFly__ defined * remove register * WARNS=6 * tested with CCVER=gcc2 and CCVER=gcc34 Index: sbin/ping6/ping6.c =================================================================== RCS file: /home/dcvs/src/sbin/ping6/ping6.c,v retrieving revision 1.7 diff -u -r1.7 ping6.c --- sbin/ping6/ping6.c 18 Dec 2004 21:43:39 -0000 1.7 +++ sbin/ping6/ping6.c 3 Mar 2005 03:13:39 -0000 @@ -114,7 +114,7 @@ #include <err.h> #include <errno.h> #include <fcntl.h> -#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) +#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) #include <math.h> #endif #include <signal.h> @@ -128,7 +128,7 @@ #include <netinet6/ipsec.h> #endif -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) #include <md5.h> #else #include "md5.h" @@ -224,7 +224,7 @@ double tmin = 999999999.0; /* minimum round trip time */ double tmax = 0.0; /* maximum round trip time */ double tsum = 0.0; /* sum of all times, for doing average */ -#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) +#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) double tsumsq = 0.0; /* sum of all times squared, for std. dev. */ #endif @@ -284,7 +284,7 @@ struct addrinfo hints; fd_set *fdmaskp; int fdmasks; - register int cc, i; + int cc, i; int ch, fromlen, hold, packlen, preload, optval, ret_ga; u_char *datap, *packet; char *e, *target, *ifname = NULL; @@ -619,7 +619,7 @@ errx(1, "-f and -i incompatible options"); if ((options & F_NOUSERDATA) == 0) { - if (datalen >= sizeof(struct timeval)) { + if (datalen >= (int)sizeof(struct timeval)) { /* we can time transfer */ timing = 1; } else @@ -647,7 +647,7 @@ gettimeofday(&timeout, NULL); srand((unsigned int)(timeout.tv_sec ^ timeout.tv_usec ^ (long)ident)); memset(nonce, 0, sizeof(nonce)); - for (i = 0; i < sizeof(nonce); i += sizeof(int)) + for (i = 0; i < (int)sizeof(nonce); i += sizeof(int)) *((int *)&nonce[i]) = rand(); #else memset(nonce, 0, sizeof(nonce)); @@ -1296,7 +1296,7 @@ dnsdecode(const u_char **sp, const u_char *ep, const u_char *base, u_char *buf, size_t bufsiz) { - int i; + int i = 0; const u_char *cp; char cresult[MAXDNAME + 1]; const u_char *comp; @@ -1335,7 +1335,7 @@ while (i-- > 0 && cp < ep) { l = snprintf(cresult, sizeof(cresult), isprint(*cp) ? "%c" : "\\%03o", *cp & 0xff); - if (l >= sizeof(cresult)) + if (l >= (int)sizeof(cresult)) return NULL; if (strlcat(buf, cresult, bufsiz) >= bufsiz) return NULL; /*result overrun*/ @@ -1389,7 +1389,7 @@ } from = (struct sockaddr *)mhdr->msg_name; fromlen = mhdr->msg_namelen; - if (cc < sizeof(struct icmp6_hdr)) { + if (cc < (int)sizeof(struct icmp6_hdr)) { if (options & F_VERBOSE) warnx("packet too short (%d bytes) from %s\n", cc, pr_addr(from, fromlen)); @@ -1417,7 +1417,7 @@ triptime = ((double)tv.tv_sec) * 1000.0 + ((double)tv.tv_usec) / 1000.0; tsum += triptime; -#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) +#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) tsumsq += triptime * triptime; #endif if (triptime < tmin) @@ -1717,7 +1717,7 @@ #else /* !USE_RFC2292BIS */ /* ARGSUSED */ void -pr_ip6opt(void *extbuf) +pr_ip6opt(void __unused *extbuf) { putchar('\n'); return; @@ -1761,7 +1761,7 @@ #else /* !USE_RFC2292BIS */ /* ARGSUSED */ void -pr_rthdr(void *extbuf) +pr_rthdr(void __unused *extbuf) { putchar('\n'); return; @@ -1769,7 +1769,7 @@ #endif /* USE_RFC2292BIS */ int -pr_bitrange(u_int32_t v, int s, int ii) +pr_bitrange(u_int32_t v, int ss, int ii) { int off; int i; @@ -1807,7 +1807,7 @@ break; } if (!ii) - printf(" %u", s + off); + printf(" %u", ss + off); ii += i; v >>= i; off += i; } @@ -1984,10 +1984,10 @@ return(NULL); } +#ifdef IPV6_RECVPATHMTU int get_pathmtu(struct msghdr *mhdr) { -#ifdef IPV6_RECVPATHMTU struct cmsghdr *cm; struct ip6_mtuinfo *mtuctl = NULL; @@ -2035,14 +2035,20 @@ return((int)mtuctl->ip6m_mtu); } } -#endif return(0); } +#else +int +get_pathmtu(struct msghdr __unused *mhdr) +{ + return(0); +} +#endif +#ifdef IPV6_USE_MTU void set_pathmtu(int mtu) { -#ifdef IPV6_USE_MTU static int firsttime = 1; struct cmsghdr *cm; @@ -2089,8 +2095,13 @@ errx(1, "set_pathmtu: internal error: no space for path MTU"); *(int *)CMSG_DATA(cm) = mtu; -#endif } +#else +void +set_pathmtu(int __unused mtu) +{ +} +#endif /* * tvsub -- @@ -2098,7 +2109,7 @@ * be >= in. */ void -tvsub(register struct timeval *out, register struct timeval *in) +tvsub(struct timeval *out, struct timeval *in) { if ((out->tv_usec -= in->tv_usec) < 0) { --out->tv_sec; @@ -2113,7 +2124,7 @@ */ /* ARGSUSED */ void -onint(int notused) +onint(int __unused notused) { signal(SIGINT, SIG_IGN); signal(SIGALRM, SIG_IGN); @@ -2149,7 +2160,7 @@ /* Only display average to microseconds */ double num = nreceived + nrepeats; double avg = tsum / num; -#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) +#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || (__DragonFly__) double dev = sqrt(tsumsq / num - avg * avg); printf( "round-trip min/avg/max/std-dev = %.3f/%.3f/%.3f/%.3f ms\n", @@ -2165,14 +2176,14 @@ } /*subject type*/ -static char *niqcode[] = { +static const char *niqcode[] = { "IPv6 address", "DNS label", /*or empty*/ "IPv4 address", }; /*result code*/ -static char *nircode[] = { +static const char *nircode[] = { "Success", "Refused", "Unknown", }; @@ -2467,7 +2478,7 @@ u_char *cp = (u_char *)ip6, nh; int hlen; - if (end - (u_char *)ip6 < sizeof(*ip6)) { + if (end - (u_char *)ip6 < (int)sizeof(*ip6)) { printf("IP6"); goto trunc; } @@ -2544,7 +2555,7 @@ void fill(char *bp, char *patp) { - register int ii, jj, kk; + int ii, jj, kk; int pat[16]; char *cp; @@ -2560,7 +2571,7 @@ /* xxx */ if (ii > 0) for (kk = 0; - kk <= MAXDATALEN - (8 + sizeof(struct timeval) + ii); + kk <= MAXDATALEN - (8 + (int)sizeof(struct timeval) + ii); kk += ii) for (jj = 0; jj < ii; ++jj) bp[jj + kk] = pat[jj]; @@ -2575,7 +2586,7 @@ #ifdef IPSEC #ifdef IPSEC_POLICY_IPSEC int -setpolicy(int so, char *policy) +setpolicy(int __unused so, char *policy) { char *buf; --------------010802010600040503000402--