From ab05e68061d6ff1f3903a113f32743e8b217a87e Mon Sep 17 00:00:00 2001 From: bde Date: Mon, 29 Jun 1998 17:06:00 +0000 Subject: [PATCH] Don't assume that time_t is long. --- libexec/talkd/announce.c | 6 ++++-- usr.bin/lock/lock.c | 6 ++++-- usr.bin/pr/pr.c | 10 +++++++--- usr.bin/tip/tip/log.c | 4 ++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/libexec/talkd/announce.c b/libexec/talkd/announce.c index f6211665b708..cd4dc55d4c18 100644 --- a/libexec/talkd/announce.c +++ b/libexec/talkd/announce.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)announce.c 8.3 (Berkeley) 4/28/95"; #endif static const char rcsid[] = - "$Id$"; + "$Id: announce.c,v 1.9 1997/12/02 12:33:11 charnier Exp $"; #endif /* not lint */ #include @@ -104,6 +104,7 @@ print_mesg(tty, tf, request, remote_machine) char *remote_machine; { struct timeval clock; + time_t clock_sec; struct timezone zone; struct tm *localtime(); struct tm *localclock; @@ -117,7 +118,8 @@ print_mesg(tty, tf, request, remote_machine) i = 0; max_size = 0; gettimeofday(&clock, &zone); - localclock = localtime( &clock.tv_sec ); + clock_sec = clock.tv_sec; + localclock = localtime(&clock_sec); (void)snprintf(line_buf[i], N_CHARS, " "); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); diff --git a/usr.bin/lock/lock.c b/usr.bin/lock/lock.c index 1bbec1dbfb68..786c31ac762b 100644 --- a/usr.bin/lock/lock.c +++ b/usr.bin/lock/lock.c @@ -45,7 +45,7 @@ static const char copyright[] = static char sccsid[] = "@(#)lock.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id$"; + "$Id: lock.c,v 1.4 1997/07/21 12:09:34 charnier Exp $"; #endif /* not lint */ /* @@ -88,6 +88,7 @@ main(argc, argv) { struct passwd *pw; struct timeval timval; + time_t timval_sec; struct itimerval ntimer, otimer; struct tm *timp; int ch, sectimeout, usemine; @@ -130,7 +131,8 @@ main(argc, argv) if (gettimeofday(&timval, (struct timezone *)NULL)) err(1, "gettimeofday"); nexttime = timval.tv_sec + (sectimeout * 60); - timp = localtime(&timval.tv_sec); + timval_sec = timval.tv_sec; + timp = localtime(&timval_sec); ap = asctime(timp); tzn = timp->tm_zone; diff --git a/usr.bin/pr/pr.c b/usr.bin/pr/pr.c index ed729d891cb2..c4fac42fa0f3 100644 --- a/usr.bin/pr/pr.c +++ b/usr.bin/pr/pr.c @@ -1255,6 +1255,7 @@ nxtfile(argc, argv, fname, buf, dt) { FILE *inf = NULL; struct timeval tv; + time_t tv_sec; struct timezone tz; struct tm *timeptr = NULL; struct stat statbuf; @@ -1282,7 +1283,8 @@ nxtfile(argc, argv, fname, buf, dt) eoptind = argc - 1; return(NULL); } - timeptr = localtime(&(tv.tv_sec)); + tv_sec = tv.tv_sec; + timeptr = localtime(&tv_sec); } for (; eoptind < argc; ++eoptind) { if (strcmp(argv[eoptind], "-") == 0) { @@ -1305,7 +1307,8 @@ nxtfile(argc, argv, fname, buf, dt) strerror(errno)); return(NULL); } - timeptr = localtime(&(tv.tv_sec)); + tv_sec = tv.tv_sec; + timeptr = localtime(&tv_sec); } else { /* * normal file processing @@ -1336,7 +1339,8 @@ nxtfile(argc, argv, fname, buf, dt) strerror(errno)); return(NULL); } - timeptr = localtime(&(tv.tv_sec)); + tv_sec = tv.tv_sec; + timeptr = localtime(&tv_sec); } else { if (fstat(fileno(inf), &statbuf) < 0) { ++errcnt; diff --git a/usr.bin/tip/tip/log.c b/usr.bin/tip/tip/log.c index 2a57c84485ae..acf5d87e4cd4 100644 --- a/usr.bin/tip/tip/log.c +++ b/usr.bin/tip/tip/log.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)log.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id$"; + "$Id: log.c,v 1.2 1997/08/18 07:16:03 charnier Exp $"; #endif /* not lint */ #include "tipconf.h" @@ -56,7 +56,7 @@ logent(group, num, acu, message) { char *user, *timestamp; struct passwd *pwd; - long t; + time_t t; if (flog == NULL) return;