From owner-freebsd-audit Tue May 29 20:23:28 2001 Delivered-To: freebsd-audit@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id CAB3B37B422 for ; Tue, 29 May 2001 20:23:24 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from hornet.unixfreak.org (hornet [63.198.170.140]) by bazooka.unixfreak.org (Postfix) with ESMTP id 6D5A13E0B for ; Tue, 29 May 2001 20:23:24 -0700 (PDT) To: audit@freebsd.org Subject: last(1) WARNS patch for review Date: Tue, 29 May 2001 20:23:24 -0700 From: Dima Dorfman Message-Id: <20010530032324.6D5A13E0B@bazooka.unixfreak.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Please review the attached patch to last(1) which silences most of the warnings. I'm particuarly doubtful about the printf formatting changes. They seem to be correct, but there might've been a reason why they were originally written incorrectly (a reason other than not compiling with the right -W flags). With this, last(1) is ready for WARNS=2 modulo the lack of a prototype for main(), but that shouldn't be a problem once David O'Brien applies my patch to gcc which shuts it up in this case (see cvs-all thread about jot). Thanks, Dima Dorfman dima@unixfreak.org Index: last.c =================================================================== RCS file: /stl/src/FreeBSD/src/usr.bin/last/last.c,v retrieving revision 1.18 diff -u -r1.18 last.c --- last.c 2001/05/28 09:57:19 1.18 +++ last.c 2001/05/30 02:32:28 @@ -34,13 +34,13 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1987, 1993, 1994\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)last.c 8.2 (Berkeley) 4/2/94"; +static const char sccsid[] = "@(#)last.c 8.2 (Berkeley) 4/2/94"; #endif /* not lint */ #include @@ -86,7 +86,7 @@ static long currentout, /* current logout value */ maxrec; /* records to display */ -static char *file = _PATH_WTMP; /* wtmp file */ +static const char *file = _PATH_WTMP; /* wtmp file */ static int sflag = 0; /* show delta in seconds */ static int width = 5; /* show seconds in delta */ static int d_first; @@ -102,6 +102,7 @@ time_t dateconv __P((char *)); int want __P((struct utmp *)); void wtmp __P((void)); +void usage __P((void)); void usage(void) @@ -196,7 +197,7 @@ long bl; time_t delta; /* time difference */ int bytes, wfd; - char *crmsg; + const char *crmsg; char ct[80]; struct tm *tm; int snapfound = 0; /* found snapshot entry? */ @@ -338,7 +339,7 @@ } delta = tt->logout - bp->ut_time; if ( sflag ) { - printf(" (%8lu)\n", + printf(" (%8u)\n", delta); } else { tm = gmtime(&delta); @@ -348,7 +349,7 @@ if (delta < 86400) printf(" (%s)\n", ct); else - printf(" (%ld+%s)\n", + printf(" (%d+%s)\n", delta / 86400, ct); } } @@ -359,7 +360,7 @@ } } tm = localtime(&buf[0].ut_time); - (void) strftime(ct, sizeof(ct), "\nwtmp begins %c\n", tm); + (void) strftime(ct, sizeof(ct), "\nwtmp begins %+\n", tm); printf("%s", ct); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message