[Libreoffice-commits] core.git: comphelper/source include/comphelper
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Nov 8 13:19:45 UTC 2018
comphelper/source/misc/profilezone.cxx | 6 +++++-
include/comphelper/profilezone.hxx | 6 +++++-
2 files changed, 10 insertions(+), 2 deletions(-)
New commits:
commit 77b5129078906e52f15e2a5c0fdefe934ef13d0c
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Nov 8 10:31:49 2018 +0100
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Nov 8 14:17:16 2018 +0100
coverity#1441101: Use std::atomic instead of volatile
ee9ccdf6ecd944c2f448a30d10700754d1f0cfa2 "reduce cost of ProfileZone when it is
not active" had changed g_bRecording from a bool guarded by g_aMutex to a
volatile bool. But having been guarded by a mutex indicates that g_bRecording
is potentially accessed from multiple threads, and volatile does not avoid
races.
Change-Id: I933ff5d912cbc7acce52155c605d9c19049c66aa
Reviewed-on: https://gerrit.libreoffice.org/63073
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/comphelper/source/misc/profilezone.cxx b/comphelper/source/misc/profilezone.cxx
index dc2a713228b8..72d9bcde06b9 100644
--- a/comphelper/source/misc/profilezone.cxx
+++ b/comphelper/source/misc/profilezone.cxx
@@ -7,6 +7,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <sal/config.h>
+
+#include <atomic>
+
#include <comphelper/sequence.hxx>
#include <comphelper/profilezone.hxx>
#include <osl/time.h>
@@ -15,7 +19,7 @@
namespace comphelper
{
-volatile bool ProfileZone::g_bRecording(false);
+std::atomic<bool> ProfileZone::g_bRecording(false);
namespace ProfileRecording
{
diff --git a/include/comphelper/profilezone.hxx b/include/comphelper/profilezone.hxx
index 9def6f994fba..8cbc078f6621 100644
--- a/include/comphelper/profilezone.hxx
+++ b/include/comphelper/profilezone.hxx
@@ -10,6 +10,10 @@
#ifndef INCLUDED_COMPHELPER_PROFILEZONE_HXX
#define INCLUDED_COMPHELPER_PROFILEZONE_HXX
+#include <sal/config.h>
+
+#include <atomic>
+
#include <com/sun/star/uno/Sequence.h>
#include <comphelper/comphelperdllapi.h>
#include <rtl/ustring.hxx>
@@ -36,7 +40,7 @@ private:
const char * m_sProfileId;
long long const m_aCreateTime;
public:
- static volatile bool g_bRecording; // true during recording
+ static std::atomic<bool> g_bRecording; // true during recording
// Note that the char pointer is stored as such in the ProfileZone object and used in the
// destructor, so be sure to pass a pointer that stays valid for the duration of the object's
More information about the Libreoffice-commits
mailing list