[PATCH] sbin/rconfig WARNS=6 cleanup

Sepherosa Ziehau sepherosa at softhome.net
Fri Apr 1 00:27:05 PST 2005


WARNS=6 cleanupIndex: Makefile
===================================================================
RCS file: /opt/df_cvs/src/sbin/rconfig/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- Makefile	18 Jun 2004 02:46:46 -0000	1.1
+++ Makefile	1 Apr 2005 08:27:32 -0000
@@ -1,8 +1,8 @@
 # $DragonFly: src/sbin/rconfig/Makefile,v 1.1 2004/06/18 02:46:46 dillon Exp $
 
+WARNS		= 6
 PROG		= rconfig
 SRCS		= rconfig.c subs.c server.c client.c
-CFLAGS	       += -Wall -Wstrict-prototypes
 MAN		= rconfig.8
 
 .include <bsd.prog.mk>
Index: client.c
===================================================================
RCS file: /opt/df_cvs/src/sbin/rconfig/client.c,v
retrieving revision 1.3
diff -u -r1.3 client.c
--- client.c	19 Aug 2004 23:57:02 -0000	1.3
+++ client.c	1 Apr 2005 08:27:32 -0000
@@ -77,9 +77,7 @@
 	host = strdup(tag->name);
 	if ((tagName = strchr(host, ':')) != NULL)
 	    *tagName++ = 0;
-	else
-	    tagName = "auto";
-	tagName = strdup(tagName);
+	tagName = strdup(tagName == NULL ? "auto" : tagName);
 	if (inet_aton(host, &sain.sin_addr) == 0) {
 	    struct hostent *hp;
 	    if ((hp = gethostbyname2(host, AF_INET)) == NULL) {
Index: server.c
===================================================================
RCS file: /opt/df_cvs/src/sbin/rconfig/server.c,v
retrieving revision 1.2
diff -u -r1.2 server.c
--- server.c	19 Aug 2004 23:57:02 -0000	1.2
+++ server.c	1 Apr 2005 08:27:32 -0000
@@ -54,7 +54,7 @@
     signal(SIGCHLD, SIG_IGN);
     for (tag = AddrBase; tag; tag = tag->next) {
 	struct sockaddr_in sain;
-	char *host;
+	const char *host;
 	int lfd;
 	int fd;
 	int on = 1;
@@ -64,18 +64,19 @@
 	    sain.sin_addr.s_addr = INADDR_ANY;
 	    host = "<any>";
 	} else {
-	    host = strdup(tag->name);
-	    if (inet_aton(host, &sain.sin_addr) == 0) {
+	    char *h = strdup(tag->name);
+	    if (inet_aton(h, &sain.sin_addr) == 0) {
 		struct hostent *hp;
-		if ((hp = gethostbyname2(host, AF_INET)) == NULL) {
-		    fprintf(stderr, "Unable to resolve %s\n", host);
+		if ((hp = gethostbyname2(h, AF_INET)) == NULL) {
+		    fprintf(stderr, "Unable to resolve %s\n", h);
 		    exit(1);
 		}
 		bcopy(hp->h_addr_list[0], &sain.sin_addr, hp->h_length);
-		free(host);
-		host = strdup(hp->h_name);
+		free(h);
+		h = strdup(hp->h_name);
 		endhostent();
 	    }
+	    host = h;
 	}
 	sain.sin_port = htons(257);
 	sain.sin_len = sizeof(sain);
@@ -133,7 +134,7 @@
 
 static
 void
-server_chld_exit(int signo)
+server_chld_exit(int signo __unused)
 {
     while (wait3(NULL, WNOHANG, NULL) > 0)
 	--nconnects;
@@ -186,13 +187,13 @@
 		    fseek(fp, 0L, 0);
 		    fprintf(fo, "201 SIZE=%ld\r\n", bytes);
 		    while (bytes > 0) {
-			n = (bytes > sizeof(buf)) ? sizeof(buf) : bytes;
+			n = ((size_t)bytes > sizeof(buf)) ? sizeof(buf) : bytes;
 			n = fread(buf, 1, n, fp);
 			if (n <= 0) {
 			    error = 1;
 			    break;
 			}
-			if (fwrite(buf, 1, n, fo) != n) {
+			if (fwrite(buf, 1, n, fo) != (size_t)n) {
 			    error = 1;
 			    break;
 			}
@@ -202,8 +203,9 @@
 		    if (bytes > 0 && ferror(fo) == 0) {
 			bzero(buf, sizeof(buf));
 			while (bytes > 0) {
-			    n = (bytes > sizeof(buf)) ? sizeof(buf) : bytes;
-			    if (fwrite(buf, 1, n, fo) != n)
+			    n = ((size_t)bytes > sizeof(buf)) ? sizeof(buf)
+							      : bytes;
+			    if (fwrite(buf, 1, n, fo) != (size_t)n)
 				break;
 			    bytes -= n;
 			}
Index: subs.c
===================================================================
RCS file: /opt/df_cvs/src/sbin/rconfig/subs.c,v
retrieving revision 1.3
diff -u -r1.3 subs.c
--- subs.c	19 Aug 2004 23:57:02 -0000	1.3
+++ subs.c	1 Apr 2005 08:27:32 -0000
@@ -212,7 +212,7 @@
 	    if (*lenp > 0)
 		*bufp = malloc(*lenp);
 	    for (rc = 0; *bufp && rc < *lenp; rc += n) {
-		if ((n = *lenp - rc) > sizeof(buf))
+		if ((size_t)(n = *lenp - rc) > sizeof(buf))
 		    n = sizeof(buf);
 		n = fread(*bufp + rc, 1, n, *pfi);
 		if (n <= 0)
@@ -256,7 +256,7 @@
 
 static
 void
-udp_alarm(int signo)
+udp_alarm(int signo __unused)
 {
     /* do nothing */
 }




More information about the Submit mailing list