diff options
author | dillon <dillon@FreeBSD.org> | 2001-10-28 20:53:17 +0000 |
---|---|---|
committer | dillon <dillon@FreeBSD.org> | 2001-10-28 20:53:17 +0000 |
commit | 532052c2b0d361a734f4675296e424713b0ed93a (patch) | |
tree | 5acba7f45da4b708998a02a853f4f97511f879c1 /usr.sbin/tcpdump | |
parent | 18ba58febf38930f93246a3550f9a017cd68002f (diff) | |
download | FreeBSD-src-532052c2b0d361a734f4675296e424713b0ed93a.zip FreeBSD-src-532052c2b0d361a734f4675296e424713b0ed93a.tar.gz |
Do not assume that sizeof(tv_sec) is sizeof(time_t) - it will be, but
it isn't yet because our tv_sec is currently a long (so 64 bit architectures
are already broken to a degree).
Diffstat (limited to 'usr.sbin/tcpdump')
-rw-r--r-- | usr.sbin/tcpdump/tcpslice/tcpslice.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.sbin/tcpdump/tcpslice/tcpslice.c b/usr.sbin/tcpdump/tcpslice/tcpslice.c index 3ee5d50..46fa549 100644 --- a/usr.sbin/tcpdump/tcpslice/tcpslice.c +++ b/usr.sbin/tcpdump/tcpslice/tcpslice.c @@ -195,12 +195,13 @@ long local_time_zone(long timestamp) struct timeval now; struct timezone tz; long localzone; + time_t t = long_to_time(timestamp); if (gettimeofday(&now, &tz) < 0) err(1, "gettimeofday"); localzone = tz.tz_minuteswest * -60; - if (localtime((time_t *) ×tamp)->tm_isdst) + if (localtime(&t)->tm_isdst) localzone += 3600; return localzone; @@ -214,7 +215,8 @@ long local_time_zone(long timestamp) struct timeval parse_time(char *time_string, struct timeval base_time) { - struct tm *bt = localtime((time_t *) &base_time.tv_sec); + time_t tt = long_to_time(base_time.tv_sec); + struct tm *bt = localtime(&tt); struct tm t; struct timeval result; time_t usecs = 0; @@ -556,6 +558,7 @@ char * timestamp_to_string(struct timeval *timestamp) { struct tm *t; + time_t tt; #define NUM_BUFFERS 2 static char buffers[NUM_BUFFERS][128]; static int buffer_to_use = 0; @@ -571,13 +574,15 @@ timestamp_to_string(struct timeval *timestamp) break; case TIMESTAMP_READABLE: - t = localtime((time_t *) ×tamp->tv_sec); + tt = long_to_time(timestamp->tv_sec); + t = localtime(&tt); strcpy( buf, asctime( t ) ); buf[24] = '\0'; /* nuke final newline */ break; case TIMESTAMP_PARSEABLE: - t = localtime((time_t *) ×tamp->tv_sec); + tt = long_to_time(timestamp->tv_sec); + t = localtime(&tt); if (t->tm_year >= 100) t->tm_year += 1900; sprintf( buf, "%02dy%02dm%02dd%02dh%02dm%02ds%06ldu", |