diff options
author | Guy Harris <guy@alum.mit.edu> | 2012-12-26 05:57:06 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2012-12-26 05:57:06 +0000 |
commit | 8ed7a73e22c049a2e013bb436e599bff41fc5b9b (patch) | |
tree | ad4a4cc6fb4ff4d3e3ffe3a3f8e3d056e441ae46 /rawshark.c | |
parent | 8ede6b7dc09aa636f87147ab432a137c209e8aca (diff) |
Fix a bunch of warnings.
Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
sizeof.
Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
strtol() and strtoul().
Change some data types to avoid those implicit conversion warnings.
When assigning a constant to a float, make sure the constant isn't a
double, by appending "f" to the constant.
Constify a bunch of variables, parameters, and return values to
eliminate warnings due to strings being given const qualifiers. Cast
away those warnings in some cases where an API we don't control forces
us to do so.
Enable a bunch of additional warnings by default. Note why at least
some of the other warnings aren't enabled.
randpkt.c and text2pcap.c are used to build programs, so they don't need
to be in EXTRA_DIST.
If the user specifies --enable-warnings-as-errors, add -Werror *even if
the user specified --enable-extra-gcc-flags; assume they know what
they're doing and are willing to have the compile fail due to the extra
GCC warnings being treated as errors.
svn path=/trunk/; revision=46748
Diffstat (limited to 'rawshark.c')
-rw-r--r-- | rawshark.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/rawshark.c b/rawshark.c index e0eba8605b..186082da03 100644 --- a/rawshark.c +++ b/rawshark.c @@ -810,10 +810,10 @@ main(int argc, char *argv[]) /* Do we need to PCAP header and magic? */ if (skip_pcap_header) { - guint bytes_left = sizeof(struct pcap_hdr) + sizeof(guint32); + size_t bytes_left = sizeof(struct pcap_hdr) + sizeof(guint32); gchar buf[sizeof(struct pcap_hdr) + sizeof(guint32)]; - while (bytes_left > 0) { - guint bytes = read(fd, buf, bytes_left); + while (bytes_left != 0) { + ssize_t bytes = read(fd, buf, bytes_left); if (bytes <= 0) { cmdarg_err("Not enough bytes for pcap header."); exit(2); @@ -884,8 +884,8 @@ static gboolean raw_pipe_read(struct wtap_pkthdr *phdr, guchar * pd, int *err, const gchar **err_info, gint64 *data_offset) { struct pcap_pkthdr mem_hdr; struct pcaprec_hdr disk_hdr; - int bytes_read = 0; - int bytes_needed = sizeof(disk_hdr); + ssize_t bytes_read = 0; + size_t bytes_needed = sizeof(disk_hdr); guchar *ptr = (guchar*) &disk_hdr; static gchar err_str[100]; @@ -913,14 +913,15 @@ raw_pipe_read(struct wtap_pkthdr *phdr, guchar * pd, int *err, const gchar **err if (want_pcap_pkthdr) { phdr->ts.secs = mem_hdr.ts.tv_sec; phdr->ts.nsecs = mem_hdr.ts.tv_usec * 1000; - phdr->caplen = bytes_needed = mem_hdr.caplen; + phdr->caplen = mem_hdr.caplen; phdr->len = mem_hdr.len; } else { phdr->ts.secs = disk_hdr.ts_sec; phdr->ts.nsecs = disk_hdr.ts_usec * 1000; - phdr->caplen = bytes_needed = disk_hdr.incl_len; + phdr->caplen = disk_hdr.incl_len; phdr->len = disk_hdr.orig_len; } + bytes_needed = phdr->caplen; phdr->pkt_encap = encap; @@ -932,7 +933,8 @@ raw_pipe_read(struct wtap_pkthdr *phdr, guchar * pd, int *err, const gchar **err #endif if (bytes_needed > WTAP_MAX_PACKET_SIZE) { *err = WTAP_ERR_BAD_FILE; - g_snprintf(err_str, 100, "Bad packet length: %d (%04x)", bytes_needed, bytes_needed); + g_snprintf(err_str, 100, "Bad packet length: %lu\n", + (unsigned long) bytes_needed); *err_info = err_str; return FALSE; } |