From: khizmax Date: Wed, 22 Jun 2016 20:08:21 +0000 (+0300) Subject: Fixed CppCheck warnings X-Git-Tag: v2.2.0~201 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2cf8e8bb9dc140e6b6e313d2f754e3d14dfa900c;p=libcds.git Fixed CppCheck warnings --- diff --git a/test/stress/map/delodd/map_delodd.h b/test/stress/map/delodd/map_delodd.h index 003c15dd..158119ed 100644 --- a/test/stress/map/delodd/map_delodd.h +++ b/test/stress/map/delodd/map_delodd.h @@ -25,7 +25,7 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "map_type.h" @@ -46,6 +46,8 @@ namespace map { {} key_thread() + : nKey() + , nThread() {} }; } @@ -156,15 +158,16 @@ namespace map { struct ensure_func { template - void operator()( bool /*bNew*/, Q const& ) + void operator()( bool /*bNew*/, Q const& ) const {} + template - void operator()( bool /*bNew*/, Q const&, V& ) + void operator()( bool /*bNew*/, Q const&, V& ) const {} // FeldmanHashMap template - void operator()( Q&, Q*) + void operator()( Q&, Q*) const {} }; public: diff --git a/test/stress/map/find_string/map_find_string.h b/test/stress/map/find_string/map_find_string.h index 056c2cb0..52e25619 100644 --- a/test/stress/map/find_string/map_find_string.h +++ b/test/stress/map/find_string/map_find_string.h @@ -25,7 +25,7 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "map_type.h" @@ -201,6 +201,12 @@ namespace map { EXPECT_EQ( w.m_KeyNotExists.nFailed, 0 ) << "thread " << i; } + propout() + << std::make_pair( "exist_found", nExistSuccess ) + << std::make_pair( "exist_not_found", nExistFailed ) // must = 0 + << std::make_pair( "missing_not_found", nMissingSuccess ) + << std::make_pair( "missing_found", nMissingFailed ); // must = 0 + check_before_cleanup( testMap ); testMap.clear(); diff --git a/test/stress/map/insdel_func/map_insdel_func.h b/test/stress/map/insdel_func/map_insdel_func.h index b56f5fed..1e3daeef 100644 --- a/test/stress/map/insdel_func/map_insdel_func.h +++ b/test/stress/map/insdel_func/map_insdel_func.h @@ -25,7 +25,7 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "map_type.h" @@ -79,6 +79,7 @@ namespace map { , nUpdateCall( s.nUpdateCall ) , bInitialized( s.bInitialized.load(atomics::memory_order_relaxed)) , threadId( cds::OS::get_current_thread_id()) + , m_access() {} // boost::container::flat_map requires operator = @@ -87,6 +88,7 @@ namespace map { nKey = v.nKey; nData = v.nData; nUpdateCall = v.nUpdateCall; + threadId = v.threadId; bInitialized.store(v.bInitialized.load(atomics::memory_order_relaxed), atomics::memory_order_relaxed); return *this; @@ -324,7 +326,8 @@ namespace map { size_t nFailedItem; value_container() - : nSuccessItem(0) + : nKeyExpected() + , nSuccessItem(0) , nFailedItem(0) {} }; diff --git a/test/stress/map/insdel_item_int/map_insdel_item_int.h b/test/stress/map/insdel_item_int/map_insdel_item_int.h index 66d783c9..7376014b 100644 --- a/test/stress/map/insdel_item_int/map_insdel_item_int.h +++ b/test/stress/map/insdel_item_int/map_insdel_item_int.h @@ -25,7 +25,7 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "map_type.h" @@ -72,27 +72,28 @@ namespace map { struct update_func { - void operator()( bool bNew, std::pair& item ) + void operator()( bool bNew, std::pair& item ) const { if ( bNew ) item.second = item.first; } + // for boost::container::flat_map - void operator()( bool bNew, std::pair& item ) + void operator()( bool bNew, std::pair& item ) const { if ( bNew ) item.second = item.first; } // for BronsonAVLTreeMap - void operator()( bool bNew, key_type key, value_type& val ) + void operator()( bool bNew, key_type key, value_type& val ) const { if ( bNew ) val = key; } // for FeldmanHashMap - void operator()( std::pair& item, std::pair * pOld ) + void operator()( std::pair& item, std::pair* pOld ) const { if ( !pOld ) item.second = item.first; diff --git a/test/stress/map/insdelfind/map_insdelfind.h b/test/stress/map/insdelfind/map_insdelfind.h index 87a5c853..8b05946c 100644 --- a/test/stress/map/insdelfind/map_insdelfind.h +++ b/test/stress/map/insdelfind/map_insdelfind.h @@ -25,7 +25,7 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "map_type.h" @@ -103,19 +103,19 @@ namespace map { struct update_functor { template - void operator()( bool /*bNew*/, map_value_type& /*cur*/, Q const& /*val*/ ) + void operator()( bool /*bNew*/, map_value_type& /*cur*/, Q const& /*val*/ ) const {} // FeldmanHashMap - void operator()( map_value_type& /*cur*/, map_value_type * /*old*/) + void operator()( map_value_type& /*cur*/, map_value_type* /*old*/) const {} // MichaelMap - void operator()( bool /*bNew*/, map_value_type& /*cur*/ ) + void operator()( bool /*bNew*/, map_value_type& /*cur*/ ) const {} // BronsonAVLTreeMap - void operator()( bool /*bNew*/, key_type /*key*/, value_type& /*val*/ ) + void operator()( bool /*bNew*/, key_type /*key*/, value_type& /*val*/ ) const {} }; diff --git a/test/stress/set/delodd/set_delodd.h b/test/stress/set/delodd/set_delodd.h index e07090f7..5d8df8aa 100644 --- a/test/stress/set/delodd/set_delodd.h +++ b/test/stress/set/delodd/set_delodd.h @@ -25,7 +25,7 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "set_type.h" @@ -45,6 +45,9 @@ namespace set { {} key_thread() + : nKey() + , nThread() + , pad_( 0 ) {} }; @@ -103,6 +106,7 @@ namespace set { { return std::hash()(k.nKey); } + size_t operator()( size_t k ) const { return std::hash()(k); @@ -156,10 +160,10 @@ namespace set { struct update_functor { template - void operator()( bool /*bNew*/, key_value_pair const&, Q const& ) + void operator()( bool /*bNew*/, key_value_pair const&, Q const& ) const {} - void operator()(key_value_pair& /*cur*/, key_value_pair * /*prev*/) + void operator()(key_value_pair& /*cur*/, key_value_pair * /*prev*/) const {} }; public: diff --git a/test/stress/set/insdel_func/set_insdel_func.h b/test/stress/set/insdel_func/set_insdel_func.h index 8d6a5bf8..081bf7a2 100644 --- a/test/stress/set/insdel_func/set_insdel_func.h +++ b/test/stress/set/insdel_func/set_insdel_func.h @@ -81,6 +81,7 @@ namespace set { , nUpdateCall(s.nUpdateCall.load(atomics::memory_order_relaxed)) , bInitialized( s.bInitialized ) , threadId( cds::OS::get_current_thread_id() ) + , m_access() {} // boost::container::flat_map requires operator = @@ -88,6 +89,7 @@ namespace set { { nKey = v.nKey; nData = v.nData; + threadId = v.threadId; nUpdateCall.store( v.nUpdateCall.load(atomics::memory_order_relaxed), atomics::memory_order_relaxed ); bInitialized = v.bInitialized;