From 3b235615bf741dbe2fff5938a708cd9ab6865384 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 27 Feb 2015 19:49:28 -0800 Subject: Don't use struct timeval if we only care about seconds. time_t suffices in that case. Change-Id: Ica7a79fb6f8c7cc7fb6decd5fcd391dccfdb3fc6 Reviewed-on: https://code.wireshark.org/review/7440 Reviewed-by: Guy Harris --- wiretap/peekclassic.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'wiretap/peekclassic.c') diff --git a/wiretap/peekclassic.c b/wiretap/peekclassic.c index b58ab15758..613018e2dd 100644 --- a/wiretap/peekclassic.c +++ b/wiretap/peekclassic.c @@ -134,7 +134,7 @@ static const peekclassic_encap_lookup_t peekclassic_encap[] = { (sizeof (peekclassic_encap) / sizeof (peekclassic_encap[0])) typedef struct { - struct timeval reference_time; + time_t reference_time; } peekclassic_t; static gboolean peekclassic_read_v7(wtap *wth, int *err, gchar **err_info, @@ -153,7 +153,7 @@ static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh, wtap_open_return_val peekclassic_open(wtap *wth, int *err, gchar **err_info) { peekclassic_header_t ep_hdr; - struct timeval reference_time; + time_t reference_time; int file_encap; peekclassic_t *peekclassic; @@ -298,10 +298,8 @@ wtap_open_return_val peekclassic_open(wtap *wth, int *err, gchar **err_info) ep_hdr.secondary.v567.linkSpeed = g_ntohl(ep_hdr.secondary.v567.linkSpeed); - /* Get the reference time as a "struct timeval" */ - reference_time.tv_sec = - ep_hdr.secondary.v567.timeDate - mac2unix; - reference_time.tv_usec = 0; + /* Get the reference time as a time_t */ + reference_time = ep_hdr.secondary.v567.timeDate - mac2unix; break; default: @@ -573,8 +571,7 @@ static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh, phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; /* timestamp is in milliseconds since reference_time */ - phdr->ts.secs = peekclassic->reference_time.tv_sec - + (timestamp / 1000); + phdr->ts.secs = peekclassic->reference_time + (timestamp / 1000); phdr->ts.nsecs = 1000 * (timestamp % 1000) * 1000; phdr->len = length; phdr->caplen = sliceLength; -- cgit v1.2.3