From: Russ Combs (rucombs) Date: Wed, 8 Apr 2020 18:08:06 +0000 (+0000) Subject: Merge pull request #2141 in SNORT/snort3 from ~RUCOMBS/snort3:flowbits_fixups to... X-Git-Tag: 3.0.1-2~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85649d973df3c755eda5c6660a72873296ebd013;p=thirdparty%2Fsnort3.git Merge pull request #2141 in SNORT/snort3 from ~RUCOMBS/snort3:flowbits_fixups to master Squashed commit of the following: commit 6a0647dc39ea3806b2cbb51cd19833a25b6b1d51 Author: russ Date: Wed Apr 8 10:00:16 2020 -0400 flowbits: fix build warnings from latest cleanup --- diff --git a/src/ips_options/ips_flowbits.cc b/src/ips_options/ips_flowbits.cc index 80e8f6325..25d1ad576 100644 --- a/src/ips_options/ips_flowbits.cc +++ b/src/ips_options/ips_flowbits.cc @@ -452,7 +452,7 @@ class FlowbitsModule : public Module { public: FlowbitsModule() : Module(s_name, s_help, s_params) { } - ~FlowbitsModule() { delete fbc; } + ~FlowbitsModule() override { delete fbc; } bool begin(const char*, int, SnortConfig*) override; bool set(const char*, Value&, SnortConfig*) override; diff --git a/src/utils/sflsq.cc b/src/utils/sflsq.cc index 0627955ae..4f54d6c1b 100644 --- a/src/utils/sflsq.cc +++ b/src/utils/sflsq.cc @@ -145,7 +145,7 @@ NODE_DATA sflist_next(SF_LNODE** v) NODE_DATA sflist_remove_head(SF_LIST* s) { NODE_DATA ndata = nullptr; - SF_QNODE* q; + SF_LNODE* q; if ( s && s->head ) { q = s->head; @@ -166,7 +166,7 @@ NODE_DATA sflist_remove_head(SF_LIST* s) NODE_DATA sflist_remove_tail(SF_LIST* s) { NODE_DATA ndata = nullptr; - SF_QNODE* q; + SF_LNODE* q; if (s && s->tail) { q = s->tail; @@ -185,53 +185,6 @@ NODE_DATA sflist_remove_tail(SF_LIST* s) return (NODE_DATA)ndata; } -void sflist_remove_node(SF_LIST* s, SF_LNODE* n) -{ - SF_LNODE* cur; - - if ( n == s->head ) - { - s->head = s->head->next; - s->count--; - - if (!s->head) - s->tail = nullptr; - else - s->head->prev = nullptr; - - snort_free(n); - return; - } - else if ( n == s->tail ) - { - s->tail = s->tail->prev; - s->count--; - - if (!s->tail ) - s->head = nullptr; - else - s->tail->next = nullptr; - - snort_free(n); - return; - } - - for (cur = s->head; - cur!= nullptr; - cur = cur->next ) - { - if ( n == cur ) - { - /* unlink a middle node */ - n->next->prev = n->prev; - n->prev->next = n->next; - s->count--; - snort_free(n); - return; - } - } -} - int sflist_count(SF_LIST* s) { if (!s) @@ -279,34 +232,3 @@ void sflist_static_free_all(SF_LIST* s, void (* nfree)(void*) ) } -// ----- queue methods ----- - -using namespace snort; - -SF_QUEUE* sfqueue_new() -{ - return (SF_QUEUE*)sflist_new(); -} - -void sfqueue_add(SF_QUEUE* s, NODE_DATA ndata) -{ - sflist_add_tail(s, ndata); -} - - -NODE_DATA sfqueue_remove(SF_QUEUE* s) -{ - return (NODE_DATA)sflist_remove_head(s); -} - -int sfqueue_count(SF_QUEUE* s) -{ - if (!s) - return 0; - return s->count; -} - -void sfqueue_free_all(SF_QUEUE* s,void (* nfree)(void*) ) -{ - sflist_free_all(s, nfree); -} diff --git a/src/utils/sflsq.h b/src/utils/sflsq.h index 78a7c0792..3e736dbb4 100644 --- a/src/utils/sflsq.h +++ b/src/utils/sflsq.h @@ -23,57 +23,32 @@ #include "main/snort_types.h" -// Simple LIST, STACK, QUEUE DICTIONARY (LIST BASED) interface -// All of these functions are based on lists. -// Use STL containers instead of these if possible. +// Simple LIST interface +// Switch to STL containers ASAP +// FIXIT-M deprecated, we are going to delete this -// FIXIT-L if we're going to keep sflsq around (instead of using STL data -// structures) it would make sense to template the interfaces instead of -// using a void* for data - -// FIXIT-M but we are going to delete sflsq and use STL instead - -// Note that NODE_DATA can be redefined with the typedef below typedef void* NODE_DATA; -// Simple list, stack, or queue NODE typedef struct sf_lnode { struct sf_lnode* next; struct sf_lnode* prev; NODE_DATA ndata; } -SF_QNODE,SF_SNODE,SF_LNODE; - -// Integer Stack - uses an array from the subroutines stack -struct SF_ISTACK -{ - unsigned* stack; - unsigned nstack; - unsigned n; -}; - -// Pointer Stack - uses an array from the subroutines stack -struct SF_PSTACK -{ - void** stack; - unsigned nstack; - unsigned n; -}; +SF_LNODE; -// Simple Structure for Queue's, stacks, lists struct sf_list { SF_LNODE* head, * tail; unsigned count; }; -typedef sf_list SF_QUEUE; typedef sf_list SF_LIST; // ----------------------------------------------------------------------------- // Linked List Interface // ----------------------------------------------------------------------------- + namespace snort { SO_PUBLIC SF_LIST* sflist_new(); @@ -83,7 +58,6 @@ SO_PUBLIC void sflist_add_head(SF_LIST*, NODE_DATA); SO_PUBLIC void sflist_add_before(SF_LIST*, SF_LNODE*, NODE_DATA); SO_PUBLIC NODE_DATA sflist_remove_head(SF_LIST*); SO_PUBLIC NODE_DATA sflist_remove_tail(SF_LIST*); -SO_PUBLIC void sflist_remove_node(SF_LIST*, SF_LNODE*); SO_PUBLIC int sflist_count(SF_LIST*); SO_PUBLIC NODE_DATA sflist_first(SF_LIST*, SF_LNODE**); SO_PUBLIC NODE_DATA sflist_next(SF_LNODE**); @@ -92,14 +66,5 @@ SO_PUBLIC void sflist_free_all(SF_LIST*, void (* free)(void*) ); SO_PUBLIC void sflist_static_free_all(SF_LIST*, void (* nfree)(void*)); } -// ----------------------------------------------------------------------------- -// Queue Interface ( FIFO - First in, First out ) -// ----------------------------------------------------------------------------- -SF_QUEUE* sfqueue_new(); -void sfqueue_add(SF_QUEUE*, NODE_DATA); -NODE_DATA sfqueue_remove(SF_QUEUE*); -int sfqueue_count(SF_QUEUE*); -void sfqueue_free_all(SF_QUEUE*, void (* free)(void*) ); - #endif