Subject: bin/4037: Why the variable `bl' in function wtmp() of last(1) is
To: None <gnats-bugs@gnats.netbsd.org>
From: None <enami@but-b.or.jp>
List: netbsd-bugs
Date: 08/26/1997 07:50:24
>Number:         4037
>Category:       bin
>Synopsis:       why `bl' in last(1) is declared as time_t?
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 25 16:05:02 1997
>Last-Modified:
>Originator:     enami tsugutomo
>Organization:
>Release:        NetBSD-current as of 1997 Aug 24
>Environment:
System: NetBSD pavlov.enami.ba2.so-net.or.jp 1.2G NetBSD 1.2G (PAVLOV) #318: Sun Aug 24 10:28:41 JST 1997 enami@pavlov.enami.ba2.so-net.or.jp:/b/netbsd/kernel/compile/PAVLOV i386


>Description:
	Why the variable `bl' in function wtmp() of last(1) is
	declared as time_t?

>How-To-Repeat:
	% vi /usr/src/usr.bin/last/last.c
	or C-x C-f ...

>Fix:
	I think off_t is better than time_t.

cvs diff: Diffing .
Index: last.c
===================================================================
RCS file: /a/cvsroot/NetBSD/src/usr.bin/last/last.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 last.c
--- last.c	1997/08/25 14:22:29	1.1.1.3
+++ last.c	1997/08/25 22:38:28
@@ -172,7 +172,8 @@
 	struct utmp	*bp;		/* current structure */
 	TTY	*T;			/* tty list entry */
 	struct stat	stb;		/* stat of file for size */
-	time_t	bl, delta;		/* time difference */
+	time_t	delta;			/* time difference */
+	off_t	bl;
 	int	timesize;		/* how much of time string to print */
 	int	bytes, wfd;
 	char	*ct, *crmsg;
@@ -193,7 +194,7 @@
 	(void)signal(SIGQUIT, onintr);
 
 	while (--bl >= 0) {
-		if (lseek(wfd, (off_t)(bl * sizeof(buf)), SEEK_SET) == -1 ||
+		if (lseek(wfd, bl * sizeof(buf), SEEK_SET) == -1 ||
 		    (bytes = read(wfd, buf, sizeof(buf))) == -1)
 			err(1, "%s", file);
 		for (bp = &buf[bytes / sizeof(buf[0]) - 1]; bp >= buf; --bp) {
>Audit-Trail:
>Unformatted: