aboutsummaryrefslogtreecommitdiff
path: root/pcap-bpf.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 /pcap-bpf.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 'pcap-bpf.c')
-rw-r--r--pcap-bpf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/pcap-bpf.c b/pcap-bpf.c
index b7fe0856..17732056 100644
--- a/pcap-bpf.c
+++ b/pcap-bpf.c
@@ -2123,7 +2123,7 @@ pcap_activate_bpf(pcap_t *p)
* the default mode, attempt to
* select the new mode.
*/
- if (new_dlt != v) {
+ if ((u_int)new_dlt != v) {
if (ioctl(p->fd, BIOCSDLT,
&new_dlt) != -1) {
/*
@@ -2765,7 +2765,7 @@ static int
find_802_11(struct bpf_dltlist *bdlp)
{
int new_dlt;
- int i;
+ u_int i;
/*
* Scan the list of DLT_ values, looking for 802.11 values,