summaryrefslogtreecommitdiff
path: root/text2pcap.c
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2008-09-21 14:04:41 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2008-09-21 14:04:41 +0000
commit76037635d3685249d21d9c1d331e4de81c364c47 (patch)
treeb15973c4fb10f52b4dcb2124fbd78653fd845396 /text2pcap.c
parent19e29e857e2b7f0917bf643dc366aaf74dfb995b (diff)
downloadwireshark-76037635d3685249d21d9c1d331e4de81c364c47.tar.gz
Declare ts_sec as a time_t because that's how it's used; this avoids a warning
about how dereferencing a type-punned pointer will break strict-aliasing rules when calling localtime(). Make ts_sec in text2pcap's definition of a PCAP record header unsigned to match that in libpcap.h . Cast the time_t into guint32 as necessary. svn path=/trunk/; revision=26242
Diffstat (limited to 'text2pcap.c')
-rw-r--r--text2pcap.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/text2pcap.c b/text2pcap.c
index 359cacb45f..0dc78694c1 100644
--- a/text2pcap.c
+++ b/text2pcap.c
@@ -194,7 +194,7 @@ static unsigned long num_packets_read = 0;
static unsigned long num_packets_written = 0;
/* Time code of packet, derived from packet_preamble */
-static gint32 ts_sec = 0;
+static time_t ts_sec = 0;
static guint32 ts_usec = 0;
static char *ts_fmt = NULL;
static struct tm timecode_default;
@@ -339,7 +339,7 @@ struct pcap_hdr {
/* "libpcap" record header. */
struct pcaprec_hdr {
- gint32 ts_sec; /* timestamp seconds */
+ guint32 ts_sec; /* timestamp seconds */
guint32 ts_usec; /* timestamp microseconds */
guint32 incl_len; /* number of octets of packet saved in file */
guint32 orig_len; /* actual length of packet */
@@ -565,8 +565,8 @@ write_current_packet (void)
}
}
- /* Write PCap header */
- ph.ts_sec = ts_sec;
+ /* Write PCAP header */
+ ph.ts_sec = (guint32)ts_sec;
ph.ts_usec = ts_usec;
if (ts_fmt == NULL) { ts_usec++; } /* fake packet counter */
ph.incl_len = length;
@@ -774,7 +774,7 @@ parse_preamble (void)
if (subsecs != NULL) {
/* Get the long time from the tm structure */
/* (will return -1 if failure) */
- ts_sec = (gint32)mktime( &timecode );
+ ts_sec = mktime( &timecode );
} else
ts_sec = -1; /* we failed to parse it */
@@ -830,7 +830,7 @@ parse_preamble (void)
char *c;
while ((c = strchr(packet_preamble, '\r')) != NULL) *c=' ';
fprintf(stderr, "[[parse_preamble: \"%s\"]]\n", packet_preamble);
- fprintf(stderr, "Format(%s), time(%u), subsecs(%u)\n", ts_fmt, ts_sec, ts_usec);
+ fprintf(stderr, "Format(%s), time(%u), subsecs(%u)\n", ts_fmt, (guint32)ts_sec, ts_usec);
}
@@ -1320,8 +1320,8 @@ parse_options (int argc, char *argv[])
output_filename = "Standard output";
}
- ts_sec = (gint32) time(0); /* initialize to current time */
- timecode_default = *localtime((time_t *)&ts_sec);
+ ts_sec = time(0); /* initialize to current time */
+ timecode_default = *localtime(&ts_sec);
/* Display summary of our state */
if (!quiet) {