]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
fdr: rely on fixed size confirm structures
authorJustin Viiret <justin.viiret@intel.com>
Tue, 20 Dec 2016 04:10:47 +0000 (15:10 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 26 Apr 2017 04:41:29 +0000 (14:41 +1000)
src/fdr/fdr_confirm_compile.cpp
src/fdr/fdr_confirm_runtime.h

index e77c46d1fe919593939fac7cdf548a3381531ae6..4aa2df0d439a6fb5ac9278d5ceee5f0e95940dfa 100644 (file)
@@ -322,32 +322,15 @@ getFDRConfirm(const vector<hwlmLiteral> &lits, bool applyOneCharOpt,
             LiteralIndex litIdx = *i;
 
             // Write LitInfo header.
-            u8 *oldPtr = ptr;
             LitInfo &finalLI = *(LitInfo *)ptr;
             finalLI = tmpLitInfo[litIdx];
 
             ptr += sizeof(LitInfo); // String starts directly after LitInfo.
-
-            // Write literal prefix (everything before the last N characters,
-            // as the last N are already confirmed).
-            const string &t = lits[litIdx].s;
-            if (t.size() > sizeof(CONF_TYPE)) {
-                size_t prefix_len = t.size() - sizeof(CONF_TYPE);
-                memcpy(ptr, t.c_str(), prefix_len);
-                ptr += prefix_len;
-            }
-
-            ptr = ROUNDUP_PTR(ptr, alignof(LitInfo));
+            assert(lits[litIdx].s.size() <= sizeof(CONF_TYPE));
             if (next(i) == e) {
                 finalLI.next = 0;
             } else {
-                // our next field represents an adjustment on top of
-                // current address + the actual size of the literal
-                // so we track any rounding up done for alignment and
-                // add this in - that way we don't have to use bigger
-                // than a u8 (for now)
-                assert((size_t)(ptr - oldPtr) > t.size());
-                finalLI.next = verify_u8(ptr - oldPtr - t.size());
+                finalLI.next = 1;
             }
         }
         assert((size_t)(ptr - fdrc_base) <= size);
index aaaecb387c59b2df2f37140ee4dab93600fc6268..559858464299804229f2123c3ce0737d2975a415 100644 (file)
@@ -101,7 +101,7 @@ void confWithBit(const struct FDRConfirm *fdrc, const struct FDR_Runtime_Args *a
         *control = a->cb(loc - buf, i, li->id, a->ctxt);
     out:
         oldNext = li->next; // oldNext is either 0 or an 'adjust' value
-        li = (const struct LitInfo *)((const u8 *)li + oldNext + li->size);
+        li++;
     } while (oldNext);
 }