aboutsummaryrefslogtreecommitdiff
path: root/sf-pcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-07-25 16:05:27 -0700
committerGuy Harris <guy@alum.mit.edu>2016-07-25 16:05:27 -0700
commit2d96be0322d71ce62e2f68d038070b10a7c9201b (patch)
tree140084663640fd718cb3bb1d01e649a23a883e4d /sf-pcap.c
parent1a796886890fb989e2071d63d9d0279a046ec62c (diff)
Check for, and squelch, signed vs. unsigned comparison errors.
Use -Wsign-compare if the compiler supports it. If we're comparing an unsigned value with a signed value, and we've already determined that the signed value is >= 0, just cast it to an unsigned type. Use 0xffffffffU instead of -1 as the "unknown"/"unset"/etc. value for unsigned variables and fields. Assign the result of str2tok() to an int, not a u_int, as it can return -1. Declare some variables and fields unsigned if they don't need to be signed. Make sure some arguments passed into "set" functions are non-negative (and otherwise not invalid). In the BPF optimizer, cast the "constant" fields of a struct block to an unsigned type - the actual constant field of a BPF instruction is unsigned. Also, cast away one warning from MSVC.
Diffstat (limited to 'sf-pcap.c')
-rw-r--r--sf-pcap.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sf-pcap.c b/sf-pcap.c
index 55c9a579..061964d1 100644
--- a/sf-pcap.c
+++ b/sf-pcap.c
@@ -876,13 +876,13 @@ pcap_dump_open_append(pcap_t *p, const char *fname)
fclose(f);
return (NULL);
}
- if (linktype != ph.linktype) {
+ if ((bpf_u_int32)linktype != ph.linktype) {
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"%s: different linktype, cannot append to file", fname);
fclose(f);
return (NULL);
}
- if (p->snapshot != ph.snaplen) {
+ if ((bpf_u_int32)p->snapshot != ph.snaplen) {
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"%s: different snaplen, cannot append to file", fname);
fclose(f);