From: Raza Shafiq (rshafiq) Date: Tue, 12 Sep 2023 13:45:49 +0000 (+0000) Subject: Pull request #3988: host_cache: cppcheck fix X-Git-Tag: 3.1.71.0~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d05ee3a1bde0a90c0f56ff49eba26dd52aaa382;p=thirdparty%2Fsnort3.git Pull request #3988: host_cache: cppcheck fix Merge in SNORT/snort3 from ~RSHAFIQ/snort3:cppcheck_fix to master Squashed commit of the following: commit e031ab24740026fd43fdd062dfd830c389dc820d Author: rshafiq Date: Fri Sep 8 09:34:46 2023 -0400 host_cache: cppcheck fix --- diff --git a/src/host_tracker/test/cache_allocator_test.cc b/src/host_tracker/test/cache_allocator_test.cc index c43adfd31..7b6961410 100644 --- a/src/host_tracker/test/cache_allocator_test.cc +++ b/src/host_tracker/test/cache_allocator_test.cc @@ -46,7 +46,7 @@ void FatalError(const char* fmt, ...) { (void)fmt; exit(1); } } // Derive an allocator from CacheAlloc: template -class Allocator : public CacheAlloc +class Alloc : public CacheAlloc { public: @@ -54,12 +54,12 @@ public: template struct rebind { - typedef Allocator other; + typedef Alloc other; }; using CacheAlloc::lru; - Allocator(); + Alloc(); }; @@ -68,7 +68,7 @@ class Item { public: typedef int ValueType; - vector> data; + vector> data; }; // Instantiate a cache, as soon as we know the Item type: @@ -78,7 +78,7 @@ CacheType cache(100); // Implement the allocator constructor AFTER we have a cache object // to point to and the implementation of our base CacheAlloc: template -Allocator::Allocator() +Alloc::Alloc() { lru = &cache; } diff --git a/src/host_tracker/test/host_cache_allocator_ht_test.cc b/src/host_tracker/test/host_cache_allocator_ht_test.cc index 7bc9b5edb..559793759 100644 --- a/src/host_tracker/test/host_cache_allocator_ht_test.cc +++ b/src/host_tracker/test/host_cache_allocator_ht_test.cc @@ -86,13 +86,13 @@ public: }; typedef LruCacheSharedMemcap> CacheType; -CacheType cache(100); +CacheType cache1(100); CacheType cache2(100); template Allocator::Allocator() { - lru = &cache; + lru = &cache1; } @@ -105,7 +105,7 @@ TEST(host_cache_allocator_ht, allocate_update) { //declare a list with allocator cache std::list> test_list; - CHECK(test_list.get_allocator().get_lru() == &cache); + CHECK(test_list.get_allocator().get_lru() == &cache1); //update cache interface of test_list to cache_2 update_allocator(test_list, &cache2); CHECK(test_list.get_allocator().get_lru() == &cache2);