DragonFly BSD
DragonFly submit List (threaded) for 2005-04
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

[PATCH] sbin/natd WARNS=6


From: Sepherosa Ziehau <sepherosa@xxxxxxxxxxxx>
Date: Tue, 12 Apr 2005 18:17:47 +0800 (CST)

WARNS=6 cleanup
1) WARNS = 6
2) add __unused for unused function parameter
3) change local variable to avoid name shadowing

Index: Makefile
===================================================================
RCS file: /opt/df_cvs/src/sbin/natd/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- Makefile	31 Jan 2004 06:56:41 -0000	1.3
+++ Makefile	11 Apr 2005 10:25:23 -0000
@@ -3,7 +3,7 @@
 
 PROG		= natd
 SRCS		= natd.c icmp.c
-CFLAGS	       += -Wall
+WARNS	       ?= 6
 LDADD		= -lalias
 DPADD		= ${LIBALIAS}
 MAN		= natd.8
Index: natd.c
===================================================================
RCS file: /opt/df_cvs/src/sbin/natd/natd.c,v
retrieving revision 1.6
diff -u -r1.6 natd.c
--- natd.c	18 Dec 2004 21:43:39 -0000	1.6
+++ natd.c	11 Apr 2005 10:25:23 -0000
@@ -684,7 +684,7 @@
 	struct if_msghdr *ifm;
 	struct ifa_msghdr *ifam;
 	struct sockaddr_dl *sdl;
-	struct sockaddr_in *sin;
+	struct sockaddr_in *in;
 
 	mib[0] = CTL_NET;
 	mib[1] = PF_ROUTE;
@@ -734,7 +734,7 @@
 /*
  * Get interface address.
  */
-	sin = NULL;
+	in = NULL;
 	while (next < lim) {
 		ifam = (struct ifa_msghdr *)next;
 		next += ifam->ifam_msglen;
@@ -758,17 +758,17 @@
 				if (ifam->ifam_addrs & i)
 					ADVANCE(cp, (struct sockaddr *)cp);
 			if (((struct sockaddr *)cp)->sa_family == AF_INET) {
-				sin = (struct sockaddr_in *)cp;
+				in = (struct sockaddr_in *)cp;
 				break;
 			}
 		}
 	}
-	if (sin == NULL)
+	if (in == NULL)
 		errx(1, "%s: cannot get interface address", ifn);
 
-	PacketAliasSetAddress(sin->sin_addr);
+	PacketAliasSetAddress(in->sin_addr);
 	syslog(LOG_INFO, "Aliasing to %s, mtu %d bytes",
-	       inet_ntoa(sin->sin_addr), ifMTU);
+	       inet_ntoa(in->sin_addr), ifMTU);
 
 	free(buf);
 }
@@ -787,13 +787,13 @@
 		warn ("%s", msg);
 }
 
-static void RefreshAddr (int sig)
+static void RefreshAddr (int sig __unused)
 {
 	if (ifName)
 		assignAliasAddr = 1;
 }
 
-static void InitiateShutdown (int sig)
+static void InitiateShutdown (int sig __unused)
 {
 /*
  * Start timer to allow kernel gracefully
@@ -805,7 +805,7 @@
 	alarm (10);
 }
 
-static void Shutdown (int sig)
+static void Shutdown (int sig __unused)
 {
 	running = 0;
 }
@@ -1349,7 +1349,7 @@
 	char*		protoName;
 	char*		separator;
 	int             i;
-	struct alias_link *link = NULL;
+	struct alias_link *alink = NULL;
 
 	strcpy (buf, parms);
 /*
@@ -1443,7 +1443,7 @@
 	        if (numRemotePorts == 1 && remotePort == 0)
 		        remotePortCopy = 0;
 
-		link = PacketAliasRedirectPort (localAddr,
+		alink = PacketAliasRedirectPort(localAddr,
 						htons(localPort + i),
 						remoteAddr,
 						htons(remotePortCopy),
@@ -1455,7 +1455,7 @@
 /*
  * Setup LSNAT server pool.
  */
-	if (serverPool != NULL && link != NULL) {
+	if (serverPool != NULL && alink != NULL) {
 		ptr = strtok(serverPool, ",");
 		while (ptr != NULL) {
 			if (StrToAddrAndPortRange(ptr, &localAddr, protoName, &portRange) != 0)
@@ -1464,7 +1464,8 @@
 			localPort = GETLOPORT(portRange);
 			if (GETNUMPORTS(portRange) != 1)
 				errx(1, "redirect_port: local port must be single in this context");
-			PacketAliasAddServer(link, localAddr, htons(localPort));
+			PacketAliasAddServer(alink, localAddr,
+					     htons(localPort));
 			ptr = strtok(NULL, ",");
 		}
 	}
@@ -1533,7 +1534,7 @@
 	struct in_addr	localAddr;
 	struct in_addr	publicAddr;
 	char*		serverPool;
-	struct alias_link *link;
+	struct alias_link *alink;
 
 	strcpy (buf, parms);
 /*
@@ -1559,16 +1560,16 @@
 		errx (1, "redirect_address: missing public address");
 
 	StrToAddr (ptr, &publicAddr);
-	link = PacketAliasRedirectAddr(localAddr, publicAddr);
+	alink = PacketAliasRedirectAddr(localAddr, publicAddr);
 
 /*
  * Setup LSNAT server pool.
  */
-	if (serverPool != NULL && link != NULL) {
+	if (serverPool != NULL && alink != NULL) {
 		ptr = strtok(serverPool, ",");
 		while (ptr != NULL) {
 			StrToAddr(ptr, &localAddr);
-			PacketAliasAddServer(link, localAddr, htons(~0));
+			PacketAliasAddServer(alink, localAddr, htons(~0));
 			ptr = strtok(NULL, ",");
 		}
 	}


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]