]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #3195: Suppressions
authorRuss Combs (rucombs) <rucombs@cisco.com>
Mon, 6 Dec 2021 12:01:04 +0000 (12:01 +0000)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Mon, 6 Dec 2021 12:01:04 +0000 (12:01 +0000)
Merge in SNORT/snort3 from ~RUCOMBS/snort3:suppressions to master

Squashed commit of the following:

commit 31b54def9246a74832e9738c959dfc0f9d0bb5c2
Author: russ <rucombs@cisco.com>
Date:   Thu Dec 2 10:14:27 2021 -0500

    build: clean up some cppcheck style issues

commit b1b17796b9f24c5666af92f2f6939da9decd5020
Author: russ <rucombs@cisco.com>
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.

src/connectors/tcp_connector/test/tcp_connector_test.cc
src/detection/fp_detect.cc
src/detection/fp_detect.h
src/helpers/test/hyper_search_test.cc
src/managers/module_manager.cc
src/utils/streambuf.cc

index d71ed9ddbf52939f10d7fdd3281391b890c3a11a..c238448b93cab59e3b4d13388498e4362a6b3c1e 100644 (file)
@@ -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;
index 4640d94ab922d134815fd49bfa2af20070e25d0b..e78eccefbd4a5e7ef741d9823844e2494cb99476 100644 (file)
@@ -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);
index d54b9393e41ec50fc44d4b29fbc1d1e2b39d7bdc..bfce59c4523f3d2acc0087702d4bd40a8c9a6377 100644 (file)
@@ -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*);
index 68662998fb8808c894d16643994464664ec205b6..5c88ecd96acfe780a728f530886a6c80153359dd 100644 (file)
@@ -146,6 +146,7 @@ TEST_GROUP(hyper_search_test_group)
     {
         s_parse_errors = 0;
         handle = HyperSearch::setup();
+        CHECK(handle);
     }
 
     void teardown() override
index b0efb5b0a2ba4879821b2474fb3dc76c6e8de719..4a1e35b6a4dd19eec4301214aef606ecf605932b 100644 (file)
@@ -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
 //-------------------------------------------------------------------------
index 66ac96868ea5725683a146a66dc828ca6268e275..d7134e17000c49a4d34be188dca6965b3093a247 100644 (file)
@@ -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)