* (It's currently not, in MSVC, even on 64-bit platforms, but....)
*/
if (_BitScanForward(&bit, (unsigned int)mask) == 0)
- return -1; /* mask is zero */
+ abort(); /* mask is zero */
return (int)bit;
}
#elif defined(MSDOS) && defined(__DJGPP__)
*/
if (b->s.code == (BPF_JMP|BPF_JEQ|BPF_K) &&
!ATOMELEM(b->out_use, A_ATOM)) {
- /*
- * We can optimize away certain subtractions of the
- * X register.
- */
+ /*
+ * We can optimize away certain subtractions of the
+ * X register.
+ */
if (last->s.code == (BPF_ALU|BPF_SUB|BPF_X)) {
val = b->val[X_ATOM];
if (opt_state->vmap[val].is_const) {
if (opt_state->errbuf != NULL) {
va_start(ap, fmt);
- (void)pcap_vsnprintf(opt_state->errbuf,
+ (void)vsnprintf(opt_state->errbuf,
PCAP_ERRBUF_SIZE, fmt, ap);
va_end(ap);
}
opt_state->n_edges = 2 * opt_state->n_blocks;
opt_state->edges = (struct edge **)calloc(opt_state->n_edges, sizeof(*opt_state->edges));
if (opt_state->edges == NULL) {
- free(opt_state->blocks);
opt_error(opt_state, "malloc");
}
*/
opt_state->levels = (struct block **)calloc(opt_state->n_blocks, sizeof(*opt_state->levels));
if (opt_state->levels == NULL) {
- free(opt_state->edges);
- free(opt_state->blocks);
opt_error(opt_state, "malloc");
}
opt_state->space = (bpf_u_int32 *)malloc(2 * opt_state->n_blocks * opt_state->nodewords * sizeof(*opt_state->space)
+ opt_state->n_edges * opt_state->edgewords * sizeof(*opt_state->space));
if (opt_state->space == NULL) {
- free(opt_state->levels);
- free(opt_state->edges);
- free(opt_state->blocks);
opt_error(opt_state, "malloc");
}
p = opt_state->space;
opt_state->maxval = 3 * max_stmts;
opt_state->vmap = (struct vmapinfo *)calloc(opt_state->maxval, sizeof(*opt_state->vmap));
if (opt_state->vmap == NULL) {
- free(opt_state->space);
- free(opt_state->levels);
- free(opt_state->edges);
- free(opt_state->blocks);
opt_error(opt_state, "malloc");
}
opt_state->vnode_base = (struct valnode *)calloc(opt_state->maxval, sizeof(*opt_state->vnode_base));
if (opt_state->vnode_base == NULL) {
- free(opt_state->vmap);
- free(opt_state->space);
- free(opt_state->levels);
- free(opt_state->edges);
- free(opt_state->blocks);
opt_error(opt_state, "malloc");
}
}
if (off >= 256) {
/* offset too large for branch, must add a jump */
if (p->longjt == 0) {
- /* mark this instruction and retry */
+ /* mark this instruction and retry */
p->longjt++;
return(0);
}
if (off >= 256) {
/* offset too large for branch, must add a jump */
if (p->longjf == 0) {
- /* mark this instruction and retry */
+ /* mark this instruction and retry */
p->longjf++;
return(0);
}
* done with the filter program. See the pcap man page.
*/
struct bpf_insn *
-icode_to_fcode(struct icode *ic, struct block *root, u_int *lenp,
+icode_to_fcode(struct icode *ic, struct block *root, u_int *lenp,
char *errbuf)
{
u_int n;
fp = (struct bpf_insn *)malloc(sizeof(*fp) * n);
if (fp == NULL) {
- (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
"malloc");
free(fp);
return NULL;
va_list ap;
va_start(ap, fmt);
- (void)pcap_vsnprintf(conv_state->errbuf,
+ (void)vsnprintf(conv_state->errbuf,
PCAP_ERRBUF_SIZE, fmt, ap);
va_end(ap);
longjmp(conv_state->top_ctx, 1);
* Validate the program.
*/
if (!pcap_validate_filter(fp->bf_insns, fp->bf_len)) {
- pcap_snprintf(p->errbuf, sizeof(p->errbuf),
+ snprintf(p->errbuf, sizeof(p->errbuf),
"BPF program is not valid");
return (-1);
}
"block1":sw -> "block3":n [label="F"];
}
*
- * After install graphviz on http://www.graphviz.org/, save it as bpf.dot
+ * After install graphviz on https://www.graphviz.org/, save it as bpf.dot
* and run `dot -Tpng -O bpf.dot' to draw the graph.
*/
static int