Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Nov 2001 16:11:36 +0300
From:      "Sergey A. Osokin" <osa@freebsd.org.ru>
To:        audit@FreeBSD.org
Subject:   Re: date(1) WARNS=2 cleanup
Message-ID:  <20011123161136.A11027@freebsd.org.ru>
In-Reply-To: <20011123150934.A10406@freebsd.org.ru>; from osa@freebsd.org.ru on Fri, Nov 23, 2001 at 03:09:34PM %2B0300
References:  <20011123150934.A10406@freebsd.org.ru>

next in thread | previous in thread | raw e-mail | index | archive | help

--XsQoSWH+UP9D9v3l
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Oops, sorry.
This patch is more rightly :-)

-- 

Rgdz,                                /"\ 
Sergey Osokin aka oZZ,               \ /  ASCII RIBBON CAMPAIGN
osa@freebsd.org.ru                    X     AGAINST HTML MAIL
http://freebsd.org.ru/~osa/          / \

--XsQoSWH+UP9D9v3l
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch-date

diff -ruN date.orig/Makefile date/Makefile
--- date.orig/Makefile	Fri Nov 23 10:57:45 2001
+++ date/Makefile	Thu Nov 22 18:58:07 2001
@@ -6,4 +6,6 @@
 DPADD=	${LIBUTIL}
 LDADD=	-lutil
 
+WARNS?=	2
+
 .include <bsd.prog.mk>
diff -ruN date.orig/date.c date/date.c
--- date.orig/date.c	Fri Nov 23 10:57:45 2001
+++ date/date.c	Thu Nov 22 19:27:19 2001
@@ -71,7 +71,7 @@
 static void badformat __P((void));
 static void usage __P((void));
 
-int logwtmp __P((char *, char *, char *));
+int logwtmp __P((const char *, const char *, const char *));
 
 int
 main(argc, argv)
@@ -148,7 +148,7 @@
 	if (!rflag && time(&tval) == -1)
 		err(1, "time");
 
-	format = "%+";
+	format = strdup("%+");
 
 	/* allow the operands in any order */
 	if (*argv && **argv == '+') {
diff -ruN date.orig/netdate.c date/netdate.c
--- date.orig/netdate.c	Fri Nov 23 10:57:45 2001
+++ date/netdate.c	Fri Nov 23 13:08:41 2001
@@ -74,10 +74,10 @@
 	struct timeval tout;
 	struct servent *sp;
 	struct tsp msg;
-	struct sockaddr_in sin, dest, from;
+	struct sockaddr_in osin, dest, from;
 	fd_set ready;
 	long waittime;
-	int s, length, port, timed_ack, found, err;
+	int s, length, port, timed_ack, found, oerr;
 	char hostname[MAXHOSTNAMELEN];
 
 	if ((sp = getservbyname("timed", "udp")) == NULL) {
@@ -95,11 +95,11 @@
 		return (retval = 2);
 	}
 
-	memset(&sin, 0, sizeof(sin));
-	sin.sin_family = AF_INET;
+	memset(&osin, 0, sizeof(osin));
+	osin.sin_family = AF_INET;
 	for (port = IPPORT_RESERVED - 1; port > IPPORT_RESERVED / 2; port--) {
-		sin.sin_port = htons((u_short)port);
-		if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
+		osin.sin_port = htons((u_short)port);
+		if (bind(s, (struct sockaddr *)&osin, sizeof(osin)) >= 0)
 			break;
 		if (errno == EADDRINUSE)
 			continue;
@@ -143,11 +143,11 @@
 	FD_SET(s, &ready);
 	found = select(FD_SETSIZE, &ready, (fd_set *)0, (fd_set *)0, &tout);
 
-	length = sizeof(err);
+	length = sizeof(oerr);
 	if (!getsockopt(s,
-	    SOL_SOCKET, SO_ERROR, (char *)&err, &length) && err) {
-		if (err != ECONNREFUSED)
-			warnc(err, "send (delayed error)");
+	    SOL_SOCKET, SO_ERROR, (char *)&oerr, &length) && oerr) {
+		if (oerr != ECONNREFUSED)
+			warnc(oerr, "send (delayed error)");
 		goto bad;
 	}
 
diff -ruN date.orig/vary.c date/vary.c
--- date.orig/vary.c	Fri Nov 23 10:57:45 2001
+++ date/vary.c	Fri Nov 23 13:08:31 2001
@@ -37,7 +37,7 @@
 
 struct trans {
   int val;
-  char *str;
+  const char *str;
 };
 
 static struct trans trans_mon[] = {
@@ -203,14 +203,14 @@
 static int
 adjday(struct tm *t, char type, int val, int mk)
 {
-  int mdays;
+  int omdays;
 
   switch (type) {
     case '+':
       while (val) {
-        mdays = daysinmonth(t);
-        if (val > mdays - t->tm_mday) {
-          val -= mdays - t->tm_mday + 1;
+        omdays = daysinmonth(t);
+        if (val > omdays - t->tm_mday) {
+          val -= omdays - t->tm_mday + 1;
           t->tm_mday = 1;
           if (!adjmon(t, '+', 1, 0, 0))
             return 0;
@@ -430,7 +430,7 @@
     if (type == '\0')
       t->tm_isdst = -1;
 
-    if (strspn(arg, digits) != len-1) {
+    if ((int)strspn(arg, digits) != len-1) {
       val = trans(trans_wday, arg);
       if (val != -1) {
           if (!adjwday(t, type, val, 1, 1))

--XsQoSWH+UP9D9v3l--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011123161136.A11027>