]> The Tcpdump Group git mirrors - libpcap/commitdiff
Add casts to finish eliminating those warnings.
authorGuy Harris <[email protected]>
Fri, 23 Mar 2018 01:41:04 +0000 (18:41 -0700)
committerGuy Harris <[email protected]>
Fri, 23 Mar 2018 01:41:04 +0000 (18:41 -0700)
At the point we're doing the cast, we know the offset in question is <
256, so we can cast it to u_char safely.

optimize.c

index e866879c8e5b5898a51467560ff0398fabd65dea..0ca639cc4049445cb6a7caaa8d176faf554073f8 100644 (file)
@@ -2209,13 +2209,13 @@ filled:
                        bpf_error(cstate, "too many extra jumps");
                        /*NOTREACHED*/
                    }
-                   dst->jt = extrajmps;
+                   dst->jt = (u_char)extrajmps;
                    extrajmps++;
                    dst[extrajmps].code = BPF_JMP|BPF_JA;
                    dst[extrajmps].k = off - extrajmps;
                }
                else
-                   dst->jt = off;
+                   dst->jt = (u_char)off;
                off = JF(p)->offset - (p->offset + slen) - 1;
                if (off >= 256) {
                    /* offset too large for branch, must add a jump */
@@ -2230,13 +2230,13 @@ filled:
                        bpf_error(cstate, "too many extra jumps");
                        /*NOTREACHED*/
                    }
-                   dst->jf = extrajmps;
+                   dst->jf = (u_char)extrajmps;
                    extrajmps++;
                    dst[extrajmps].code = BPF_JMP|BPF_JA;
                    dst[extrajmps].k = off - extrajmps;
                }
                else
-                   dst->jf = off;
+                   dst->jf = (u_char)off;
        }
        return (1);
 }