Kaydet (Commit) 77b51290 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

coverity#1441101: Use std::atomic instead of volatile

ee9ccdf6 "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/63073Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 35b6f75b
......@@ -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
{
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment