diff options
author | Guy Harris <gharris@sonic.net> | 2020-06-17 13:28:39 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2020-06-17 13:28:39 -0700 |
commit | 6a613e03c2aafe1e16a9efbc9f89e6d0f7a28155 (patch) | |
tree | 8181df82049c3e353726974dcb6429d4899f1a01 /optimize.c | |
parent | 01afa17bf96ff719931c4f7dc644381132e72456 (diff) |
optimize: remove unnecessary tests.
We never insert more than 2 extra jumps in convert_code_r(); make the
count of extra jumps a u_char, so that no compiler doing insufficiently
careful data flow analysis thinks ZOMG IT CAN GET BIGGER THAN
256!!!!!!111ONEZ111!!!! and emits a bogus warning, and remove checks
whether it can get > 256.
This should address GitHub issue #944 without upsetting MSVC.
Diffstat (limited to 'optimize.c')
-rw-r--r-- | optimize.c | 15 |
1 files changed, 3 insertions, 12 deletions
@@ -2688,7 +2688,7 @@ convert_code_r(conv_state_t *conv_state, struct icode *ic, struct block *p) struct slist *src; u_int slen; u_int off; - u_int extrajmps; /* number of extra jumps inserted */ + u_char extrajmps; /* number of extra jumps inserted */ struct slist **offset = NULL; if (p == 0 || isMarked(ic, p)) @@ -2821,12 +2821,7 @@ filled: p->longjt++; return(0); } - /* branch if T to following jump */ - if (extrajmps >= 256) { - conv_error(conv_state, "too many extra jumps"); - /*NOTREACHED*/ - } - dst->jt = (u_char)extrajmps; + dst->jt = extrajmps; extrajmps++; dst[extrajmps].code = BPF_JMP|BPF_JA; dst[extrajmps].k = off - extrajmps; @@ -2843,11 +2838,7 @@ filled: } /* branch if F to following jump */ /* if two jumps are inserted, F goes to second one */ - if (extrajmps >= 256) { - conv_error(conv_state, "too many extra jumps"); - /*NOTREACHED*/ - } - dst->jf = (u_char)extrajmps; + dst->jf = extrajmps; extrajmps++; dst[extrajmps].code = BPF_JMP|BPF_JA; dst[extrajmps].k = off - extrajmps; |