From 16b226d06513c41e6172abc51f56973fa472b34b Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Mon, 7 Jan 2019 15:33:39 +0100 Subject: [PATCH] CxxUtils: Fix thread-safety checker warnings. The thread-safety checker wasn't property checking class constructors. Fix a few warnings that appear once that is corrected. --- Control/CxxUtils/CxxUtils/checker_macros.h | 4 +++- Control/CxxUtils/Root/SealDebug.cxx | 5 +++-- Control/CxxUtils/src/exctrace/exctrace_collector.cxx | 5 +++-- Control/CxxUtils/test/ConcurrentBitset_test.cxx | 12 +++++++----- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Control/CxxUtils/CxxUtils/checker_macros.h b/Control/CxxUtils/CxxUtils/checker_macros.h index db9951d5e3a..f1a43895ab4 100644 --- a/Control/CxxUtils/CxxUtils/checker_macros.h +++ b/Control/CxxUtils/CxxUtils/checker_macros.h @@ -1,7 +1,7 @@ // This file's extension implies that it's C, but it's really -*- C++ -*-. /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // $Id$ @@ -124,6 +124,8 @@ * Add to a function to suppress warnings about uses of static variables, * mutable variables, or discarding const. * + * Add to a class to so mark all functions in the class. + * * A function calling an ATLAS_NOT_THREAD_SAFE function must also be marked * ATLAS_NOT_THREAD_SAFE. */ diff --git a/Control/CxxUtils/Root/SealDebug.cxx b/Control/CxxUtils/Root/SealDebug.cxx index 6f9c5a423b5..057c47ba197 100644 --- a/Control/CxxUtils/Root/SealDebug.cxx +++ b/Control/CxxUtils/Root/SealDebug.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /** @@ -22,6 +22,7 @@ #include "CxxUtils/SealDebug.h" // wlav #include "CxxUtils/SealSignal.h" // wlav #include "CxxUtils/SealSharedLib.h" // wlav +#include "CxxUtils/checker_macros.h" // wlav copied from SealBase/sysapi/DebugAids.h #include <cstring> @@ -116,7 +117,7 @@ namespace { std::string addr2LinePath = "/usr/bin/addr2line"; -struct BacktraceInit +struct ATLAS_NOT_THREAD_SAFE BacktraceInit { BacktraceInit() { diff --git a/Control/CxxUtils/src/exctrace/exctrace_collector.cxx b/Control/CxxUtils/src/exctrace/exctrace_collector.cxx index db7acb303ec..1051c375bed 100644 --- a/Control/CxxUtils/src/exctrace/exctrace_collector.cxx +++ b/Control/CxxUtils/src/exctrace/exctrace_collector.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // $Id$ @@ -21,6 +21,7 @@ #include <execinfo.h> #include <cstdio> #include <typeinfo> +#include "CxxUtils/checker_macros.h" // Maximum stack depth. static @@ -50,7 +51,7 @@ extern "C" void __cxa_throw (void* thrown_exception, namespace CxxUtils { -struct extrace_init +struct ATLAS_NOT_THREAD_SAFE extrace_init { extrace_init(); }; diff --git a/Control/CxxUtils/test/ConcurrentBitset_test.cxx b/Control/CxxUtils/test/ConcurrentBitset_test.cxx index 22cb557282f..3b5e985a608 100644 --- a/Control/CxxUtils/test/ConcurrentBitset_test.cxx +++ b/Control/CxxUtils/test/ConcurrentBitset_test.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /* */ @@ -791,13 +791,14 @@ public: struct const_iterator : public ck_hs_iterator_t { - const_iterator(const ck_hs_t* hs) : m_hs (const_cast<ck_hs_t*>(hs)) + const_iterator(const ck_hs_t* hs) : m_hs (hs) { cursor = nullptr; offset = 0; } const_iterator() : const_iterator(nullptr) {} size_t operator* () const { return reinterpret_cast<size_t> (m_elt); } const_iterator& operator++() { - if (!ck_hs_next (m_hs, this, &m_elt)) { + ck_hs_t* hs_nc ATLAS_THREAD_SAFE = const_cast<ck_hs_t*> (m_hs); + if (!ck_hs_next (hs_nc, this, &m_elt)) { cursor = nullptr; offset = 0; } @@ -813,7 +814,7 @@ public: return !(*this == other); } - ck_hs_t* m_hs; + const ck_hs_t* m_hs; void* m_elt = nullptr; }; @@ -863,7 +864,8 @@ CKHSAdapter::CKHSAdapter (const CKHSAdapter& other) { ck_hs_iterator it { nullptr, 0}; void* obj; - while (ck_hs_next (const_cast<ck_hs_t*>(&other.m_hs), &it, &obj)) { + ck_hs_t* hs_nc ATLAS_THREAD_SAFE = const_cast<ck_hs_t*>(&other.m_hs); + while (ck_hs_next (hs_nc, &it, &obj)) { insert (reinterpret_cast<size_t> (obj)); } } -- GitLab