sbin/ping WARNS=6

Sepherosa Ziehau sepherosa at softhome.net
Wed Feb 9 04:33:08 PST 2005


sbin/ping WARNS=6
patch:
Index: Makefile
===================================================================
RCS file: /opt/df_cvs/src/sbin/ping/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- Makefile	17 Jun 2003 04:27:34 -0000	1.2
+++ Makefile	9 Feb 2005 10:54:48 -0000
@@ -2,10 +2,10 @@
 # $FreeBSD: src/sbin/ping/Makefile,v 1.12.2.4 2001/12/19 04:49:11 dd Exp $
 # $DragonFly: src/sbin/ping/Makefile,v 1.2 2003/06/17 04:27:34 dillon Exp  
$

+WARNS=	6
 PROG=	ping
 MAN=	ping.8
 BINMODE=4555
-CFLAGS+=-Wall -Wmissing-prototypes
 .if ${MACHINE_ARCH} == "alpha"
 CFLAGS+=-fno-builtin	# GCC's builtin memcpy doesn't do unaligned copies
 .endif
Index: ping.c
===================================================================
RCS file: /opt/df_cvs/src/sbin/ping/ping.c,v
retrieving revision 1.4
diff -u -r1.4 ping.c
--- ping.c	18 Dec 2004 21:43:39 -0000	1.4
+++ ping.c	9 Feb 2005 10:57:58 -0000
@@ -191,7 +191,7 @@
 	struct iovec iov;
 	struct msghdr msg;
 	struct sigaction si_sa;
-	struct sockaddr_in from, sin;
+	struct sockaddr_in from, src_in;
 	struct termios ts;
 	struct timeval last, intvl;
 	struct hostent *hp;
@@ -387,9 +387,9 @@
 	target = argv[optind];
 	if (source) {
-		bzero((char *)&sin, sizeof(sin));
-		sin.sin_family = AF_INET;
-		if (inet_aton(source, &sin.sin_addr) != 0) {
+		bzero((char *)&src_in, sizeof(src_in));
+		src_in.sin_family = AF_INET;
+		if (inet_aton(source, &src_in.sin_addr) != 0) {
 			shostname = source;
 		} else {
 			hp = gethostbyname2(source, AF_INET);
@@ -397,18 +397,18 @@
 				errx(EX_NOHOST, "cannot resolve %s: %s",
 				    source, hstrerror(h_errno));
-			sin.sin_len = sizeof sin;
-			if (hp->h_length > sizeof(sin.sin_addr) ||
+			src_in.sin_len = sizeof src_in;
+			if (hp->h_length > (int)sizeof(src_in.sin_addr) ||
 			    hp->h_length < 0)
 				errx(1, "gethostbyname2: illegal address");
-			memcpy(&sin.sin_addr, hp->h_addr_list[0],
-			    sizeof(sin.sin_addr));
+			memcpy(&src_in.sin_addr, hp->h_addr_list[0],
+			    sizeof(src_in.sin_addr));
 			strncpy(snamebuf, hp->h_name,
 			    sizeof(snamebuf) - 1);
 			snamebuf[sizeof(snamebuf) - 1] = '\0';
 			shostname = snamebuf;
 		}
-		if (bind(s, (struct sockaddr *)&sin, sizeof sin) == -1)
+		if (bind(s, (struct sockaddr *)&src_in, sizeof src_in) == -1)
 			err(1, "bind");
 	}
@@ -424,7 +424,7 @@
 			errx(EX_NOHOST, "cannot resolve %s: %s",
 			    target, hstrerror(h_errno));
-		if (hp->h_length > sizeof(to->sin_addr))
+		if (hp->h_length > (int)sizeof(to->sin_addr))
 			errx(1, "gethostbyname2 returned an illegal address");
 		memcpy(&to->sin_addr, hp->h_addr_list[0], sizeof to->sin_addr);
 		strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1);
@@ -656,7 +656,7 @@
 		if (n < 0)
 			continue;	/* Must be EINTR. */
 		if (n == 1) {
-			struct timeval *t = 0;
+			struct timeval *tv = 0;
 #ifdef SO_TIMESTAMP
 			struct cmsghdr *cmsg = (struct cmsghdr *)&ctrl;
@@ -672,17 +672,17 @@
 #ifdef SO_TIMESTAMP
 			if (cmsg->cmsg_level == SOL_SOCKET &&
 			    cmsg->cmsg_type == SCM_TIMESTAMP &&
-			    cmsg->cmsg_len == CMSG_LEN(sizeof *t)) {
+			    cmsg->cmsg_len == CMSG_LEN(sizeof *tv)) {
 				/* Copy to avoid alignment problems: */
 				memcpy(&now,CMSG_DATA(cmsg),sizeof(now));
-				t = &now;
+				tv = &now;
 			}
 #endif
-			if (t == 0) {
+			if (tv == 0) {
 				gettimeofday(&now, NULL);
-				t = &now;
+				tv = &now;
 			}
-			pr_pack((char *)packet, cc, &from, t);
+			pr_pack((char *)packet, cc, &from, tv);
 			if (npackets && nreceived >= npackets)
 				break;
 		}





More information about the Submit mailing list