Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Aug 2001 15:23:39 -0400
From:      Mike Barcroft <mike@FreeBSD.org>
To:        audit@FreeBSD.org
Subject:   wc(1) warns patch
Message-ID:  <20010821152339.A54793@coffee.q9media.com>

next in thread | raw e-mail | index | archive | help
I would appreciate comments on the following patch to wc(1).  I would
like to commit it shortly.

Best regards,
Mike Barcroft

----------------------------------------------------------------------

wc.20010821.patch

o Quiet warnings on alpha
o Constify, staticize, set WARNS=2

Index: wc/Makefile
===================================================================
RCS file: /home/ncvs/src/usr.bin/wc/Makefile,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Makefile
--- wc/Makefile	1994/05/27 12:33:28	1.1.1.1
+++ wc/Makefile	2001/08/20 03:47:24
@@ -1,5 +1,6 @@
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
 PROG=	wc
+WARNS?=	2
 
 .include <bsd.prog.mk>
Index: wc/wc.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/wc/wc.c,v
retrieving revision 1.11
diff -u -r1.11 wc.c
--- wc/wc.c	1999/08/28 01:07:34	1.11
+++ wc/wc.c	2001/08/20 03:47:24
@@ -58,11 +58,11 @@
 #include <string.h>
 #include <unistd.h>
 
-u_quad_t tlinect, twordct, tcharct;
+unsigned long long tlinect, twordct, tcharct;
 int doline, doword, dochar;
 
-int cnt __P((char *));
-void usage __P((void));
+static int cnt __P((const char *));
+static void usage __P((void));
 
 int
 main(argc, argv)
@@ -113,22 +113,22 @@
 
 	if (total > 1) {
 		if (doline)
-			(void)printf(" %7qu", tlinect);
+			(void)printf(" %7llu", tlinect);
 		if (doword)
-			(void)printf(" %7qu", twordct);
+			(void)printf(" %7llu", twordct);
 		if (dochar)
-			(void)printf(" %7qu", tcharct);
+			(void)printf(" %7llu", tcharct);
 		(void)printf(" total\n");
 	}
 	exit(errors == 0 ? 0 : 1);
 }
 
-int
+static int
 cnt(file)
-	char *file;
+	const char *file;
 {
 	struct stat sb;
-	u_quad_t linect, wordct, charct;
+	unsigned long long linect, wordct, charct;
 	int fd, len;
 	short gotsp;
 	u_char *p;
@@ -163,10 +163,10 @@
 						++linect;
 			}
 			tlinect += linect;
-			(void)printf(" %7qu", linect);
+			(void)printf(" %7llu", linect);
 			if (dochar) {
 				tcharct += charct;
-				(void)printf(" %7qu", charct);
+				(void)printf(" %7llu", charct);
 			}
 			(void)close(fd);
 			return (0);
@@ -217,21 +217,21 @@
 	}
 	if (doline) {
 		tlinect += linect;
-		(void)printf(" %7qu", linect);
+		(void)printf(" %7llu", linect);
 	}
 	if (doword) {
 		twordct += wordct;
-		(void)printf(" %7qu", wordct);
+		(void)printf(" %7llu", wordct);
 	}
 	if (dochar) {
 		tcharct += charct;
-		(void)printf(" %7qu", charct);
+		(void)printf(" %7llu", charct);
 	}
 	(void)close(fd);
 	return (0);
 }
 
-void
+static void
 usage()
 {
 	(void)fprintf(stderr, "usage: wc [-clw] [file ...]\n");

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?20010821152339.A54793>