From: Russ Combs (rucombs) Date: Mon, 6 Dec 2021 12:01:04 +0000 (+0000) Subject: Pull request #3195: Suppressions X-Git-Tag: 3.1.19.0~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19b0534eac68ed52d47de24d7ecb351d6b93fc38;p=thirdparty%2Fsnort3.git Pull request #3195: Suppressions Merge in SNORT/snort3 from ~RUCOMBS/snort3:suppressions to master Squashed commit of the following: commit 31b54def9246a74832e9738c959dfc0f9d0bb5c2 Author: russ Date: Thu Dec 2 10:14:27 2021 -0500 build: clean up some cppcheck style issues commit b1b17796b9f24c5666af92f2f6939da9decd5020 Author: russ Date: Wed Dec 1 09:45:46 2021 -0500 build: add cppcheck suppressions for unusedFunctions Start migrating suppressions from an external file to source comments. Only functions that are actually called (and reported as covered) are candidates for suppression. In this case, we have Lua FFI and STL overrides. --- diff --git a/src/connectors/tcp_connector/test/tcp_connector_test.cc b/src/connectors/tcp_connector/test/tcp_connector_test.cc index d71ed9ddb..c238448b9 100644 --- a/src/connectors/tcp_connector/test/tcp_connector_test.cc +++ b/src/connectors/tcp_connector/test/tcp_connector_test.cc @@ -506,22 +506,6 @@ TEST_GROUP(tcp_connector_tinit_tterm_answer) } }; -TEST(tcp_connector_tinit_tterm_answer, null) -{ - CHECK(1==1); -} - -TEST(tcp_connector_tinit_tterm_call, null) -{ - CHECK(1==1); -} - -TEST(tcp_connector_tinit_tterm_thread_call, null) -{ - sleep(1); - CHECK(1==1); -} - TEST(tcp_connector_tinit_tterm_call, alloc_discard) { const uint8_t* data = nullptr; diff --git a/src/detection/fp_detect.cc b/src/detection/fp_detect.cc index 4640d94ab..e78eccefb 100644 --- a/src/detection/fp_detect.cc +++ b/src/detection/fp_detect.cc @@ -836,7 +836,7 @@ void fp_set_context(IpsContext& c) c.context_num = 0; } -void fp_clear_context(IpsContext& c) +void fp_clear_context(const IpsContext& c) { delete c.stash; snort_free(c.otnx->matchInfo); diff --git a/src/detection/fp_detect.h b/src/detection/fp_detect.h index d54b9393e..bfce59c45 100644 --- a/src/detection/fp_detect.h +++ b/src/detection/fp_detect.h @@ -93,7 +93,7 @@ struct OtnxMatchData int fpAddMatch(OtnxMatchData*, const OptTreeNode*); void fp_set_context(snort::IpsContext&); -void fp_clear_context(snort::IpsContext&); +void fp_clear_context(const snort::IpsContext&); void fp_full(snort::Packet*); void fp_partial(snort::Packet*); diff --git a/src/helpers/test/hyper_search_test.cc b/src/helpers/test/hyper_search_test.cc index 68662998f..5c88ecd96 100644 --- a/src/helpers/test/hyper_search_test.cc +++ b/src/helpers/test/hyper_search_test.cc @@ -146,6 +146,7 @@ TEST_GROUP(hyper_search_test_group) { s_parse_errors = 0; handle = HyperSearch::setup(); + CHECK(handle); } void teardown() override diff --git a/src/managers/module_manager.cc b/src/managers/module_manager.cc index b0efb5b0a..4a1e35b6a 100644 --- a/src/managers/module_manager.cc +++ b/src/managers/module_manager.cc @@ -630,15 +630,17 @@ static bool interested(Module* m) //------------------------------------------------------------------------- -// ffi methods +// ffi methods - only called from Lua so cppcheck suppressions required //------------------------------------------------------------------------- +// cppcheck-suppress unusedFunction SO_PUBLIC void clear_alias() { s_aliased_name.clear(); s_aliased_type.clear(); } +// cppcheck-suppress unusedFunction SO_PUBLIC bool set_alias(const char* from, const char* to) { if ( !from or !to ) @@ -667,16 +669,38 @@ SO_PUBLIC bool set_alias(const char* from, const char* to) return true; } +// cppcheck-suppress unusedFunction SO_PUBLIC void snort_whitelist_append(const char* s) { Shell::allowlist_append(s, false); } +// cppcheck-suppress unusedFunction SO_PUBLIC void snort_whitelist_add_prefix(const char* s) { Shell::allowlist_append(s, true); } +// cppcheck-suppress unusedFunction +SO_PUBLIC const char* push_include_path(const char* file) +{ + static std::string path; + path = ""; + const char* code = get_config_file(file, path); + push_parse_location(code, path.c_str(), file); + return path.c_str(); +} + +// cppcheck-suppress unusedFunction +SO_PUBLIC void pop_include_path() +{ + pop_parse_location(); +} + +//------------------------------------------------------------------------- +// ffi methods - also called internally so no cppcheck suppressions +//------------------------------------------------------------------------- + SO_PUBLIC bool open_table(const char* s, int idx) { const char* orig = s; @@ -810,20 +834,6 @@ SO_PUBLIC bool set_string(const char* fqn, const char* s) return set_value(fqn, v); } -SO_PUBLIC const char* push_include_path(const char* file) -{ - static std::string path; - path = ""; - const char* code = get_config_file(file, path); - push_parse_location(code, path.c_str(), file); - return path.c_str(); -} - -SO_PUBLIC void pop_include_path() -{ - pop_parse_location(); -} - //------------------------------------------------------------------------- // private methods //------------------------------------------------------------------------- diff --git a/src/utils/streambuf.cc b/src/utils/streambuf.cc index 66ac96868..d7134e170 100644 --- a/src/utils/streambuf.cc +++ b/src/utils/streambuf.cc @@ -48,6 +48,7 @@ streamsize istreambuf_glue::last_chunk_offset() const return get<2>(chunks.back()); } +// cppcheck-suppress unusedFunction streambuf* istreambuf_glue::setbuf(char* s, streamsize n) { n = max(0, n); @@ -69,6 +70,7 @@ streambuf* istreambuf_glue::setbuf(char* s, streamsize n) return this; } +// cppcheck-suppress unusedFunction streampos istreambuf_glue::seekoff(streamoff off, ios_base::seekdir way, ios_base::openmode which) { if (!(which & ios_base::in)) @@ -118,6 +120,7 @@ streampos istreambuf_glue::seekoff(streamoff off, ios_base::seekdir way, ios_bas return pos; } +// cppcheck-suppress unusedFunction streampos istreambuf_glue::seekpos(streampos pos, ios_base::openmode which) { if (!(which & ios_base::in)) @@ -156,6 +159,7 @@ int istreambuf_glue::sync() return -1; } +// cppcheck-suppress unusedFunction streamsize istreambuf_glue::showmanyc() { if (chunks.empty()) @@ -168,6 +172,7 @@ streamsize istreambuf_glue::showmanyc() return size - off; } +// cppcheck-suppress unusedFunction streamsize istreambuf_glue::xsgetn(char* s, streamsize n) { assert(n >= 0); @@ -202,6 +207,7 @@ streamsize istreambuf_glue::xsgetn(char* s, streamsize n) return r; } +// cppcheck-suppress unusedFunction int istreambuf_glue::underflow() { if (chunks.empty()) @@ -344,6 +350,7 @@ int ostreambuf_infl::sync() return -1; } +// cppcheck-suppress unusedFunction streamsize ostreambuf_infl::xsputn(const char* s, streamsize n) { assert(n >= 0); @@ -362,6 +369,7 @@ streamsize ostreambuf_infl::xsputn(const char* s, streamsize n) return n; } +// cppcheck-suppress unusedFunction int ostreambuf_infl::overflow(int c) { if (traits_type::eof() == c)