Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Jun 2001 11:19:04 -0400 (EDT)
From:      Mike Barcroft <mike@q9media.com>
To:        Warner Losh <imp@harmony.village.org>
Cc:        audit@FreeBSD.ORG
Subject:   Re: src/usr.bin/lastcomm patch 
Message-ID:  <200106251519.f5PFJ4J92475@coffee.q9media.com>

next in thread | raw e-mail | index | archive | help
Warner Losh <imp@harmony.village.org> writes:
> Is there a specific reason you left register in place?

Good point.  Patch which also removes register is available at
the bottom of this e-mail and also at:
http://testbed.q9media.net/freebsd/lastcomm.20010625.patch

Best regards,
Mike Barcroft

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

lastcomm.20010625.patch

o s/time/flags/g; to avoid shadowing a global declaration.
o Make some variables const to silence compiler warnings.
o Remove register storage-classes.
o Set WARNS?=2

Index: lastcomm/Makefile
===================================================================
RCS file: /home/ncvs/src/usr.bin/lastcomm/Makefile,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Makefile
--- lastcomm/Makefile	1994/05/27 12:31:57	1.1.1.1
+++ lastcomm/Makefile	2001/06/25 14:41:49
@@ -1,5 +1,6 @@
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
 PROG=	lastcomm
+WARNS?=	2
 
 .include <bsd.prog.mk>
Index: lastcomm/lastcomm.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/lastcomm/lastcomm.c,v
retrieving revision 1.12
diff -u -r1.12 lastcomm.c
--- lastcomm/lastcomm.c	2001/06/16 07:08:37	1.12
+++ lastcomm/lastcomm.c	2001/06/25 14:41:50
@@ -32,7 +32,7 @@
  */
 
 #ifndef lint
-static char copyright[] =
+static const char copyright[] =
 "@(#) Copyright (c) 1980, 1993\n\
 	The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
@@ -61,10 +61,9 @@
 
 time_t	 expand __P((u_int));
 char	*flagbits __P((int));
-char	*getdev __P((dev_t));
+const char	*getdev __P((dev_t));
 int	 requested __P((char *[], struct acct *));
 static void	 usage __P((void));
-char	*user_from_uid();
 
 #define AC_UTIME 1 /* user */
 #define AC_STIME 2 /* system */
@@ -81,15 +80,15 @@
 	int argc;
 	char *argv[];
 {
-	register char *p;
+	char *p;
 	struct acct ab;
 	struct stat sb;
 	FILE *fp;
 	off_t size;
 	time_t t;
 	int ch;
-	char *acctfile;
-	int time = 0;
+	const char *acctfile;
+	int flags = 0;
 
 	acctfile = _PATH_ACCT;
 	while ((ch = getopt(argc, argv, "f:usecSE")) != -1)
@@ -99,24 +98,24 @@
 			break;
 
 		case 'u': 
-			time |= AC_UTIME; /* user time */
+			flags |= AC_UTIME; /* user time */
 			break;
 		case 's':
-			time |= AC_STIME; /* system time */
+			flags |= AC_STIME; /* system time */
 			break;
 		case 'e':
-			time |= AC_ETIME; /* elapsed time */
+			flags |= AC_ETIME; /* elapsed time */
 			break;
         	case 'c':
-                        time |= AC_CTIME; /* user + system time */
+                        flags |= AC_CTIME; /* user + system time */
 			break;
 
         	case 'S':
-                        time |= AC_BTIME; /* starting time */
+                        flags |= AC_BTIME; /* starting time */
 			break;
         	case 'E':
 			/* exit time (starting time + elapsed time )*/
-                        time |= AC_FTIME; 
+                        flags |= AC_FTIME; 
 			break;
 
 		case '?':
@@ -125,8 +124,8 @@
 		}
 
 	/* default user + system time and starting time */
-	if (!time) {
-	    time = AC_CTIME | AC_BTIME;
+	if (!flags) {
+	    flags = AC_CTIME | AC_BTIME;
 	}
 
 	argc -= optind;
@@ -184,34 +183,34 @@
 		
 		
 		/* user + system time */
-		if (time & AC_CTIME) {
+		if (flags & AC_CTIME) {
 			(void)printf(" %6.2f secs", 
 				     (expand(ab.ac_utime) + 
 				      expand(ab.ac_stime))/AC_HZ);
 		}
 		
 		/* usr time */
-		if (time & AC_UTIME) {
+		if (flags & AC_UTIME) {
 			(void)printf(" %6.2f us", expand(ab.ac_utime)/AC_HZ);
 		}
 		
 		/* system time */
-		if (time & AC_STIME) {
+		if (flags & AC_STIME) {
 			(void)printf(" %6.2f sy", expand(ab.ac_stime)/AC_HZ);
 		}
 		
 		/* elapsed time */
-		if (time & AC_ETIME) {
+		if (flags & AC_ETIME) {
 			(void)printf(" %8.2f es", expand(ab.ac_etime)/AC_HZ);
 		}
 		
 		/* starting time */
-		if (time & AC_BTIME) {
+		if (flags & AC_BTIME) {
 			(void)printf(" %.16s", ctime(&ab.ac_btime));
 		}
 		
 		/* exit time (starting time + elapsed time )*/
-		if (time & AC_FTIME) {
+		if (flags & AC_FTIME) {
 			t = ab.ac_btime;
 			t += (time_t)(expand(ab.ac_etime)/AC_HZ);
 			(void)printf(" %.16s", ctime(&t));
@@ -225,7 +224,7 @@
 expand(t)
 	u_int t;
 {
-	register time_t nt;
+	time_t nt;
 
 	nt = t & 017777;
 	t >>= 13;
@@ -238,7 +237,7 @@
 
 char *
 flagbits(f)
-	register int f;
+	int f;
 {
 	static char flags[20] = "-";
 	char *p;
@@ -257,10 +256,10 @@
 
 int
 requested(argv, acp)
-	register char *argv[];
-	register struct acct *acp;
+	char *argv[];
+	struct acct *acp;
 {
-	register char *p;
+	const char *p;
 
 	do {
 		p = user_from_uid(acp->ac_uid, 0);
@@ -274,12 +273,12 @@
 	return (0);
 }
 
-char *
+const char *
 getdev(dev)
 	dev_t dev;
 {
 	static dev_t lastdev = (dev_t)-1;
-	static char *lastname;
+	static const char *lastname;
 
 	if (dev == NODEV)			/* Special case. */
 		return ("__");

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?200106251519.f5PFJ4J92475>