From: Guy Harris Date: Mon, 18 Sep 2017 00:45:27 +0000 (-0700) Subject: Merge pull request #613 from mkubecek/mk/master/opt-unknown X-Git-Tag: libpcap-1.9-bp~675 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/d7bdf180b158a11d116bb8a77674200e72baff44?ds=inline;hp=-c Merge pull request #613 from mkubecek/mk/master/opt-unknown optimizer: replacing unknown value with unknown value is not a no-op --- d7bdf180b158a11d116bb8a77674200e72baff44 diff --combined optimize.c index 53e98133,8544f3e1..0bf52cdd --- a/optimize.c +++ b/optimize.c @@@ -115,7 -115,7 +115,7 @@@ struct vmapinfo bpf_int32 const_val; }; -struct _opt_state { +typedef struct { /* * A flag to indicate that further optimization is needed. * Iterative passes are continued until a given pass yields no @@@ -198,7 -198,7 +198,7 @@@ struct vmapinfo *vmap; struct valnode *vnode_base; struct valnode *next_vnode; -}; +} opt_state_t; typedef struct { /* @@@ -578,7 -578,7 +578,7 @@@ F(opt_state_t *opt_state, int code, in static inline void vstore(struct stmt *s, int *valp, int newval, int alter) { - if (alter && *valp == newval) + if (alter && newval != 0 && *valp == newval) s->code = NOP; else *valp = newval; @@@ -2334,8 -2334,10 +2334,8 @@@ dot_dump(compiler_state_t *cstate, stru f.bf_insns = icode_to_fcode(cstate, ic, ic->root, &f.bf_len); fprintf(out, "digraph BPF {\n"); - ic->cur_mark = 0; unMarkAll(ic); dot_dump_node(ic, ic->root, &f, out); - ic->cur_mark = 0; unMarkAll(ic); dot_dump_edge(ic, ic->root, out); fprintf(out, "}\n");