most ptr.get() conversion

This commit is contained in:
gtsoul-tech 2024-05-13 14:24:16 +03:00
parent fc272868b8
commit 9798b57f9e
6 changed files with 24 additions and 24 deletions

View File

@ -250,7 +250,7 @@ int main(){
u32 id = 1000; u32 id = 1000;
ue2::hwlmLiteral lit(str, true, id); ue2::hwlmLiteral lit(str, true, id);
b.nt = ue2::noodBuildTable(lit); b.nt = ue2::noodBuildTable(lit);
assert(b.nt != nullptr); assert(b.nt.get() != nullptr);
}, },
[&](MicroBenchmark &b) { [&](MicroBenchmark &b) {
noodExec(b.nt.get(), b.buf.data(), b.size, 0, noodExec(b.nt.get(), b.buf.data(), b.size, 0,

View File

@ -505,7 +505,7 @@ bool operator<(const RoseEdgeProps &a, const RoseEdgeProps &b) {
#ifndef NDEBUG #ifndef NDEBUG
bool roseHasTops(const RoseBuildImpl &build, RoseVertex v) { bool roseHasTops(const RoseBuildImpl &build, RoseVertex v) {
const RoseGraph &g = build.g; const RoseGraph &g = build.g;
assert(left_id(g[v].left)); assert(g[v].left);
set<u32> graph_tops; set<u32> graph_tops;
if (!build.isRootSuccessor(v)) { if (!build.isRootSuccessor(v)) {

View File

@ -915,7 +915,7 @@ bool mergeSameCastle(RoseBuildImpl &build, RoseVertex a, RoseVertex b,
} }
} }
assert(contains(rai.rev_leftfix[b_left], b)); assert(contains(rai.rev_leftfix[left_id(b_left)], b));
rai.rev_leftfix[left_id(b_left)].erase(b); rai.rev_leftfix[left_id(b_left)].erase(b);
rai.rev_leftfix[left_id(a_left)].insert(b); rai.rev_leftfix[left_id(a_left)].insert(b);

View File

@ -61,10 +61,10 @@ using namespace ue2;
#define CHECK_WITH_TEDDY_OK_TO_FAIL(fdr, hint) \ #define CHECK_WITH_TEDDY_OK_TO_FAIL(fdr, hint) \
{ \ { \
auto descr = getTeddyDescription(hint); \ auto descr = getTeddyDescription(hint); \
if (descr && fdr == nullptr) { \ if (descr && fdr.get() == nullptr) { \
return; /* cannot build Teddy for this set of literals */ \ return; /* cannot build Teddy for this set of literals */ \
} else { \ } else { \
ASSERT_TRUE(fdr != nullptr); \ ASSERT_TRUE(fdr.get() != nullptr); \
} \ } \
} }
#endif #endif
@ -145,7 +145,7 @@ bytecode_ptr<FDR> buildFDREngineHinted(std::vector<hwlmLiteral> &lits,
auto proto = fdrBuildProtoHinted(HWLM_ENGINE_FDR, lits, make_small, hint, auto proto = fdrBuildProtoHinted(HWLM_ENGINE_FDR, lits, make_small, hint,
target, grey); target, grey);
if (!proto) { if (!proto) {
return nullptr; return ue2::bytecode_ptr<FDR>(nullptr);
} }
return fdrBuildTable(*proto, grey); return fdrBuildTable(*proto, grey);
} }
@ -156,7 +156,7 @@ bytecode_ptr<FDR> buildFDREngine(std::vector<hwlmLiteral> &lits,
const Grey &grey) { const Grey &grey) {
auto proto = fdrBuildProto(HWLM_ENGINE_FDR, lits, make_small, target, grey); auto proto = fdrBuildProto(HWLM_ENGINE_FDR, lits, make_small, target, grey);
if (!proto) { if (!proto) {
return nullptr; return bytecode_ptr<FDR>(nullptr);
} }
return fdrBuildTable(*proto, grey); return fdrBuildTable(*proto, grey);
} }
@ -421,7 +421,7 @@ TEST_P(FDRp, moveByteStream) {
size_t size = fdrSize(fdrTable0.get()); size_t size = fdrSize(fdrTable0.get());
auto fdrTable = make_bytecode_ptr<FDR>(size, 64); auto fdrTable = make_bytecode_ptr<FDR>(size, 64);
EXPECT_NE(nullptr, fdrTable); EXPECT_NE(nullptr, fdrTable.get());
memcpy(fdrTable.get(), fdrTable0.get(), size); memcpy(fdrTable.get(), fdrTable0.get(), size);
@ -706,7 +706,7 @@ TEST(FDR, FDRTermS) {
lits.push_back(hwlmLiteral("ff", 0, 1)); lits.push_back(hwlmLiteral("ff", 0, 1));
auto fdr = buildFDREngine(lits, false, get_current_target(), Grey()); auto fdr = buildFDREngine(lits, false, get_current_target(), Grey());
ASSERT_TRUE(fdr != nullptr); ASSERT_TRUE(fdr.get() != nullptr);
// check matches // check matches
@ -729,7 +729,7 @@ TEST(FDR, FDRTermB) {
lits.push_back(hwlmLiteral("ff", 0, 1)); lits.push_back(hwlmLiteral("ff", 0, 1));
auto fdr = buildFDREngine(lits, false, get_current_target(), Grey()); auto fdr = buildFDREngine(lits, false, get_current_target(), Grey());
ASSERT_TRUE(fdr != nullptr); ASSERT_TRUE(fdr.get() != nullptr);
// check matches // check matches
struct hs_scratch scratch; struct hs_scratch scratch;

View File

@ -55,10 +55,10 @@ using namespace ue2;
#define CHECK_WITH_TEDDY_OK_TO_FAIL(fdr, hint) \ #define CHECK_WITH_TEDDY_OK_TO_FAIL(fdr, hint) \
{ \ { \
auto descr = getTeddyDescription(hint); \ auto descr = getTeddyDescription(hint); \
if (descr && fdr != nullptr) { \ if (descr && fdr.get() != nullptr) { \
return; \ return; \
} else { \ } else { \
ASSERT_TRUE(fdr != nullptr); \ ASSERT_TRUE(fdr.get() != nullptr); \
} \ } \
} }
#endif #endif

View File

@ -87,7 +87,7 @@ protected:
nfa = constructNFA(*g, &rm, fixed_depth_tops, triggers, compress_state, nfa = constructNFA(*g, &rm, fixed_depth_tops, triggers, compress_state,
fast_nfa, type, cc); fast_nfa, type, cc);
ASSERT_TRUE(nfa != nullptr); ASSERT_TRUE(nfa.get() != nullptr);
full_state = make_bytecode_ptr<char>(nfa->scratchStateSize, 64); full_state = make_bytecode_ptr<char>(nfa->scratchStateSize, 64);
stream_state = make_bytecode_ptr<char>(nfa->streamStateSize); stream_state = make_bytecode_ptr<char>(nfa->streamStateSize);
@ -134,7 +134,7 @@ INSTANTIATE_TEST_CASE_P(
Range((int)LIMEX_NFA_32, (int)LIMEX_NFA_512)); Range((int)LIMEX_NFA_32, (int)LIMEX_NFA_512));
TEST_P(LimExModelTest, StateSize) { TEST_P(LimExModelTest, StateSize) {
ASSERT_TRUE(nfa != nullptr); ASSERT_TRUE(nfa.get() != nullptr);
hs_platform_info plat; hs_platform_info plat;
hs_error_t err = hs_populate_platform(&plat); hs_error_t err = hs_populate_platform(&plat);
@ -150,7 +150,7 @@ TEST_P(LimExModelTest, StateSize) {
} }
TEST_P(LimExModelTest, QueueExec) { TEST_P(LimExModelTest, QueueExec) {
ASSERT_TRUE(nfa != nullptr); ASSERT_TRUE(nfa.get() != nullptr);
initQueue(); initQueue();
nfaQueueInitState(nfa.get(), &q); nfaQueueInitState(nfa.get(), &q);
@ -165,7 +165,7 @@ TEST_P(LimExModelTest, QueueExec) {
} }
TEST_P(LimExModelTest, CompressExpand) { TEST_P(LimExModelTest, CompressExpand) {
ASSERT_TRUE(nfa != nullptr); ASSERT_TRUE(nfa.get() != nullptr);
u32 real_state_size = nfa->scratchStateSize; u32 real_state_size = nfa->scratchStateSize;
/* Only look at 8 bytes for limex 64 (rather than the padding) */ /* Only look at 8 bytes for limex 64 (rather than the padding) */
@ -197,7 +197,7 @@ TEST_P(LimExModelTest, CompressExpand) {
} }
TEST_P(LimExModelTest, InitCompressedState0) { TEST_P(LimExModelTest, InitCompressedState0) {
ASSERT_TRUE(nfa != nullptr); ASSERT_TRUE(nfa.get() != nullptr);
// 64-bit NFAs assume during compression that they have >= 5 bytes of // 64-bit NFAs assume during compression that they have >= 5 bytes of
// compressed NFA state, which isn't true for our 8-state test pattern. We // compressed NFA state, which isn't true for our 8-state test pattern. We
@ -212,7 +212,7 @@ TEST_P(LimExModelTest, InitCompressedState0) {
} }
TEST_P(LimExModelTest, QueueExecToMatch) { TEST_P(LimExModelTest, QueueExecToMatch) {
ASSERT_TRUE(nfa != nullptr); ASSERT_TRUE(nfa.get() != nullptr);
initQueue(); initQueue();
nfaQueueInitState(nfa.get(), &q); nfaQueueInitState(nfa.get(), &q);
@ -256,7 +256,7 @@ TEST_P(LimExModelTest, QueueExecToMatch) {
} }
TEST_P(LimExModelTest, QueueExecRose) { TEST_P(LimExModelTest, QueueExecRose) {
ASSERT_TRUE(nfa != nullptr); ASSERT_TRUE(nfa.get() != nullptr);
initQueue(); initQueue();
// For rose, there's no callback or context. // For rose, there's no callback or context.
@ -277,7 +277,7 @@ TEST_P(LimExModelTest, QueueExecRose) {
} }
TEST_P(LimExModelTest, CheckFinalState) { TEST_P(LimExModelTest, CheckFinalState) {
ASSERT_TRUE(nfa != nullptr); ASSERT_TRUE(nfa.get() != nullptr);
initQueue(); initQueue();
nfaQueueInitState(nfa.get(), &q); nfaQueueInitState(nfa.get(), &q);
@ -321,7 +321,7 @@ protected:
} }
nfa = constructReversedNFA(g_rev, type, cc); nfa = constructReversedNFA(g_rev, type, cc);
ASSERT_TRUE(nfa != nullptr); ASSERT_TRUE(nfa.get() != nullptr);
} }
// NFA type (enum NFAEngineType) // NFA type (enum NFAEngineType)
@ -338,7 +338,7 @@ INSTANTIATE_TEST_CASE_P(LimExReverse, LimExReverseTest,
Range((int)LIMEX_NFA_32, (int)LIMEX_NFA_512)); Range((int)LIMEX_NFA_32, (int)LIMEX_NFA_512));
TEST_P(LimExReverseTest, BlockExecReverse) { TEST_P(LimExReverseTest, BlockExecReverse) {
ASSERT_TRUE(nfa != nullptr); ASSERT_TRUE(nfa.get() != nullptr);
u64a offset = 0; u64a offset = 0;
const u8 *buf = (const u8 *)SCAN_DATA.c_str(); const u8 *buf = (const u8 *)SCAN_DATA.c_str();
@ -381,7 +381,7 @@ protected:
nfa = constructNFA(*g, &rm, fixed_depth_tops, triggers, compress_state, nfa = constructNFA(*g, &rm, fixed_depth_tops, triggers, compress_state,
fast_nfa, type, cc); fast_nfa, type, cc);
ASSERT_TRUE(nfa != nullptr); ASSERT_TRUE(nfa.get() != nullptr);
full_state = make_bytecode_ptr<char>(nfa->scratchStateSize, 64); full_state = make_bytecode_ptr<char>(nfa->scratchStateSize, 64);
stream_state = make_bytecode_ptr<char>(nfa->streamStateSize); stream_state = make_bytecode_ptr<char>(nfa->streamStateSize);
@ -427,7 +427,7 @@ INSTANTIATE_TEST_CASE_P(LimExZombie, LimExZombieTest,
Range((int)LIMEX_NFA_32, (int)LIMEX_NFA_512)); Range((int)LIMEX_NFA_32, (int)LIMEX_NFA_512));
TEST_P(LimExZombieTest, GetZombieStatus) { TEST_P(LimExZombieTest, GetZombieStatus) {
ASSERT_TRUE(nfa != nullptr); ASSERT_TRUE(nfa.get() != nullptr);
ASSERT_TRUE(nfa->flags & NFA_ZOMBIE); ASSERT_TRUE(nfa->flags & NFA_ZOMBIE);
initQueue(); initQueue();