From 9b9df1b3974e2680eed0c4923991e7cf72cc32a1 Mon Sep 17 00:00:00 2001 From: gtsoul-tech Date: Wed, 24 Apr 2024 11:07:23 +0300 Subject: [PATCH 1/6] invalidPrintfArgType_sint --- src/parser/ComponentRepeat.cpp | 2 +- unit/internal/multi_bit_compress.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parser/ComponentRepeat.cpp b/src/parser/ComponentRepeat.cpp index 7090459f..919dbccb 100644 --- a/src/parser/ComponentRepeat.cpp +++ b/src/parser/ComponentRepeat.cpp @@ -320,7 +320,7 @@ void ComponentRepeat::wireRepeats(GlushkovBuildState &bs) { } } - DEBUG_PRINTF("wiring up %d optional repeats\n", copies - m_min); + DEBUG_PRINTF("wiring up %u optional repeats\n", copies - m_min); for (u32 rep = MAX(m_min, 1); rep < copies; rep++) { vector lasts = m_lasts[rep - 1]; if (rep != m_min) { diff --git a/unit/internal/multi_bit_compress.cpp b/unit/internal/multi_bit_compress.cpp index 14c3f480..e0ec475c 100644 --- a/unit/internal/multi_bit_compress.cpp +++ b/unit/internal/multi_bit_compress.cpp @@ -46,7 +46,7 @@ UNUSED static void mmbit_display(const u8 *bits, u32 total_bits) { for (u32 i = 0; i < mmbit_size(total_bits); i += 8) { - printf("block %d:", i / 8); + printf("block %u:", i / 8); for (s32 j = 7; j >= 0; j--) { u8 a = (*(bits + i + j)); printf(" %02x", a); @@ -72,7 +72,7 @@ UNUSED static void mmbit_display_comp(const u8 *bits, u32 comp_size) { for (u32 i = 0; i < comp_size; i += 8) { - printf("block %d:", i / 8); + printf("block %u:", i / 8); for (s32 j = 7; j >= 0; j--) { u8 a = (*(bits + i + j)); printf(" %02x", a); From e6c884358e96b15ca57dbfecd8cfff8edcf80f96 Mon Sep 17 00:00:00 2001 From: gtsoul-tech Date: Wed, 24 Apr 2024 11:13:02 +0300 Subject: [PATCH 2/6] uninitvar --- unit/internal/pqueue.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unit/internal/pqueue.cpp b/unit/internal/pqueue.cpp index a0a37990..bd7e4650 100644 --- a/unit/internal/pqueue.cpp +++ b/unit/internal/pqueue.cpp @@ -245,7 +245,7 @@ TEST(pqueue, queue1) { u32 in[] = {1, 2, 3, 4, 5, 6, 7, 8}; u32 expected[] = {4, 5, 6, 7, 8, 3, 2, 1}; u32 temp[ARRAY_LENGTH(in)]; - u32 output[ARRAY_LENGTH(in)]; + u32 output[ARRAY_LENGTH(in)] = {0}; u32 queue_size = 0; u32 i = 0, o = 0; @@ -275,7 +275,7 @@ TEST(pqueue, queue2) { u32 in[] = {8, 7, 6, 5, 4, 3, 2, 1}; u32 expected[] = {8, 7, 6, 5, 4, 3, 2, 1}; u32 temp[ARRAY_LENGTH(in)]; - u32 output[ARRAY_LENGTH(in)]; + u32 output[ARRAY_LENGTH(in)] = {0}; u32 queue_size = 0; u32 i = 0, o = 0; @@ -301,7 +301,7 @@ TEST(pqueue, queue3) { u32 in[] = {1, 8, 2, 7, 3, 6, 4, 5}; u32 expected[] = {8, 7, 6, 4, 5, 3, 2, 1}; u32 temp[ARRAY_LENGTH(in)]; - u32 output[ARRAY_LENGTH(in)]; + u32 output[ARRAY_LENGTH(in)] = {0}; u32 queue_size = 0; u32 i = 0, o = 0; From adda613f516eb067c457dce9a5df2101ac4d9708 Mon Sep 17 00:00:00 2001 From: gtsoul-tech Date: Wed, 24 Apr 2024 11:13:28 +0300 Subject: [PATCH 3/6] shiftTooManyBitsSigned --- unit/internal/bitutils.cpp | 4 ++-- unit/internal/supervector.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/unit/internal/bitutils.cpp b/unit/internal/bitutils.cpp index 8af8f9a4..6adfc2d6 100644 --- a/unit/internal/bitutils.cpp +++ b/unit/internal/bitutils.cpp @@ -62,7 +62,7 @@ u32 our_clzll(u64a x) { TEST(BitUtils, findAndClearLSB32_1) { // test that it can find every single-bit case for (unsigned int i = 0; i < 32; i++) { - u32 input = 1 << i; + u32 input = 1U << i; u32 idx = findAndClearLSB_32(&input); EXPECT_EQ(i, idx); EXPECT_EQ(0U, input); @@ -112,7 +112,7 @@ TEST(BitUtils, findAndClearLSB64_2) { TEST(BitUtils, findAndClearMSB32_1) { // test that it can find every single-bit case for (unsigned int i = 0; i < 32; i++) { - u32 input = 1 << i; + u32 input = 1U << i; u32 idx = findAndClearMSB_32(&input); EXPECT_EQ(i, idx); EXPECT_EQ(0U, input); diff --git a/unit/internal/supervector.cpp b/unit/internal/supervector.cpp index 2432e598..ac3daf2a 100644 --- a/unit/internal/supervector.cpp +++ b/unit/internal/supervector.cpp @@ -508,7 +508,7 @@ TEST(SuperVectorUtilsTest,Movemask256c){ u8 vec2[32] = {0}; u32 r = rand() % 100 + 1; for(int i=0; i<32; i++) { - if (r & (1 << i)) { + if (r & (1U << i)) { vec[i] = 0xff; } } From fd3e251afa1240a4c85bb472abb171a803a56690 Mon Sep 17 00:00:00 2001 From: gtsoul-tech Date: Wed, 24 Apr 2024 12:40:55 +0300 Subject: [PATCH 4/6] redundantInitialization --- src/nfa/limex_compile.cpp | 2 +- src/nfa/mpv.c | 8 ++++---- src/nfagraph/ng_anchored_dots.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/nfa/limex_compile.cpp b/src/nfa/limex_compile.cpp index f84cdc32..2ec65552 100644 --- a/src/nfa/limex_compile.cpp +++ b/src/nfa/limex_compile.cpp @@ -1572,7 +1572,7 @@ u32 findMaxVarShift(const build_info &args, u32 nShifts) { static int getLimexScore(const build_info &args, u32 nShifts) { const NGHolder &h = args.h; - u32 maxVarShift = nShifts; + u32 maxVarShift; int score = 0; score += SHIFT_COST * nShifts; diff --git a/src/nfa/mpv.c b/src/nfa/mpv.c index cba3d159..2b1b5c5f 100644 --- a/src/nfa/mpv.c +++ b/src/nfa/mpv.c @@ -512,7 +512,7 @@ size_t find_last_bad(const struct mpv_kilopuff *kp, const u8 *buf, verm_restart:; assert(buf[curr] == kp->u.verm.c); - size_t test = curr; + size_t test; if (curr + min_rep < length) { test = curr + min_rep; } else { @@ -534,7 +534,7 @@ size_t find_last_bad(const struct mpv_kilopuff *kp, const u8 *buf, m128 hi = kp->u.shuf.mask_hi; shuf_restart: assert(do_single_shufti(lo, hi, buf[curr])); - size_t test = curr; + size_t test; if (curr + min_rep < length) { test = curr + min_rep; } else { @@ -556,7 +556,7 @@ size_t find_last_bad(const struct mpv_kilopuff *kp, const u8 *buf, const m128 mask1 = kp->u.truffle.mask1; const m128 mask2 = kp->u.truffle.mask2; truffle_restart:; - size_t test = curr; + size_t test; if (curr + min_rep < length) { test = curr + min_rep; } else { @@ -582,7 +582,7 @@ size_t find_last_bad(const struct mpv_kilopuff *kp, const u8 *buf, nverm_restart:; assert(buf[curr] != kp->u.verm.c); - size_t test = curr; + size_t test; if (curr + min_rep < length) { test = curr + min_rep; } else { diff --git a/src/nfagraph/ng_anchored_dots.cpp b/src/nfagraph/ng_anchored_dots.cpp index 9a13376d..8286d816 100644 --- a/src/nfagraph/ng_anchored_dots.cpp +++ b/src/nfagraph/ng_anchored_dots.cpp @@ -165,9 +165,9 @@ void reformAnchoredRepeatsComponent(NGHolder &g, return; } - NFAVertex dotV = NGHolder::null_vertex(); + set otherV; - dotV = findReformable(g, compAnchoredStarts, otherV); + NFAVertex dotV = findReformable(g, compAnchoredStarts, otherV); if (dotV == NGHolder::null_vertex()) { DEBUG_PRINTF("no candidate reformable dot found.\n"); return; @@ -268,9 +268,9 @@ void reformUnanchoredRepeatsComponent(NGHolder &g, } while (true) { - NFAVertex dotV = NGHolder::null_vertex(); + set otherV; - dotV = findReformable(g, compUnanchoredStarts, otherV); + NFAVertex dotV = findReformable(g, compUnanchoredStarts, otherV); if (dotV == NGHolder::null_vertex()) { DEBUG_PRINTF("no candidate reformable dot found.\n"); return; From 72371a05dca2d3a768429461fd7af4a618c554b2 Mon Sep 17 00:00:00 2001 From: gtsoul-tech Date: Wed, 24 Apr 2024 13:15:17 +0300 Subject: [PATCH 5/6] derefInvalidIteratorRedundantCheck --- src/nfagraph/ng_som.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nfagraph/ng_som.cpp b/src/nfagraph/ng_som.cpp index 359fa17b..0e42b4b5 100644 --- a/src/nfagraph/ng_som.cpp +++ b/src/nfagraph/ng_som.cpp @@ -1292,8 +1292,8 @@ bool doTreePlanningIntl(NGHolder &g, DEBUG_PRINTF("add mapped reporters for region %u\n", it->first); addMappedReporterVertices(it->second, g, copy_to_orig, plan.back().reporters); - } while (it->second.optional && it != info.rend() && - (++it)->first > furthest->first); + } while (it != info.rend() && it->second.optional && + (++it)->first > furthest->first); return true; } @@ -1551,7 +1551,7 @@ bool doSomPlanning(NGHolder &g, bool stuck_in, DEBUG_PRINTF("region %u contributes reporters to last plan\n", it->first); addReporterVertices(it->second, g, plan.back().reporters); - } while (it->second.optional && it != info.rend() && + } while (it != info.rend() && it->second.optional && (++it)->first > furthest->first); DEBUG_PRINTF("done!\n"); From 5dab841cea8809a64686fe75503439cb4096bcc0 Mon Sep 17 00:00:00 2001 From: gtsoul-tech Date: Wed, 24 Apr 2024 15:50:55 +0300 Subject: [PATCH 6/6] badBitmaskCheck --- src/database.h | 9 +++------ src/fdr/teddy_engine_description.cpp | 16 ++++++++-------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/database.h b/src/database.h index a4d6e4dc..1b94f1b0 100644 --- a/src/database.h +++ b/src/database.h @@ -79,21 +79,18 @@ static UNUSED const platform_t hs_current_platform_no_avx2 = { HS_PLATFORM_NOAVX2 | HS_PLATFORM_NOAVX512 | - HS_PLATFORM_NOAVX512VBMI | - 0, + HS_PLATFORM_NOAVX512VBMI }; static UNUSED const platform_t hs_current_platform_no_avx512 = { HS_PLATFORM_NOAVX512 | - HS_PLATFORM_NOAVX512VBMI | - 0, + HS_PLATFORM_NOAVX512VBMI }; static UNUSED const platform_t hs_current_platform_no_avx512vbmi = { - HS_PLATFORM_NOAVX512VBMI | - 0, + HS_PLATFORM_NOAVX512VBMI }; /* diff --git a/src/fdr/teddy_engine_description.cpp b/src/fdr/teddy_engine_description.cpp index 7cd33ab2..5f05a055 100644 --- a/src/fdr/teddy_engine_description.cpp +++ b/src/fdr/teddy_engine_description.cpp @@ -52,14 +52,14 @@ u32 TeddyEngineDescription::getDefaultFloodSuffixLength() const { void getTeddyDescriptions(vector *out) { static const TeddyEngineDef defns[] = { - { 3, 0 | HS_CPU_FEATURES_AVX2, 1, 16, false }, - { 4, 0 | HS_CPU_FEATURES_AVX2, 1, 16, true }, - { 5, 0 | HS_CPU_FEATURES_AVX2, 2, 16, false }, - { 6, 0 | HS_CPU_FEATURES_AVX2, 2, 16, true }, - { 7, 0 | HS_CPU_FEATURES_AVX2, 3, 16, false }, - { 8, 0 | HS_CPU_FEATURES_AVX2, 3, 16, true }, - { 9, 0 | HS_CPU_FEATURES_AVX2, 4, 16, false }, - { 10, 0 | HS_CPU_FEATURES_AVX2, 4, 16, true }, + { 3, HS_CPU_FEATURES_AVX2, 1, 16, false }, + { 4, HS_CPU_FEATURES_AVX2, 1, 16, true }, + { 5, HS_CPU_FEATURES_AVX2, 2, 16, false }, + { 6, HS_CPU_FEATURES_AVX2, 2, 16, true }, + { 7, HS_CPU_FEATURES_AVX2, 3, 16, false }, + { 8, HS_CPU_FEATURES_AVX2, 3, 16, true }, + { 9, HS_CPU_FEATURES_AVX2, 4, 16, false }, + { 10, HS_CPU_FEATURES_AVX2, 4, 16, true }, { 11, 0, 1, 8, false }, { 12, 0, 1, 8, true }, { 13, 0, 2, 8, false },