]> The Tcpdump Group git mirrors - libpcap/commitdiff
Merge pull request #613 from mkubecek/mk/master/opt-unknown
authorGuy Harris <[email protected]>
Mon, 18 Sep 2017 00:45:27 +0000 (17:45 -0700)
committerGitHub <[email protected]>
Mon, 18 Sep 2017 00:45:27 +0000 (17:45 -0700)
optimizer: replacing unknown value with unknown value is not a no-op

1  2 
optimize.c

diff --combined optimize.c
index 53e981332ec2ad5cd81f5a9227a07905e52d821f,8544f3e19d1e9cb1d914573b4523fcb37d3cef30..0bf52cdd8f4f2c72c077f309b8474cf588b6ec77
@@@ -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
        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");