From 30539716ca470c3621aa9440a593facf763e7a30 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 9 Jan 2022 23:49:08 +0100 Subject: [PATCH] Fix various Wcast-qual g_atomic_int_get() requires a non-const pointer, however many APIs are declared virtual const, so const_cast<> is preferred over an API change. --- libs/ardour/ardour/audioengine.h | 2 +- libs/ardour/ardour/automation_list.h | 2 +- libs/ardour/ardour/midi_channel_filter.h | 6 +++--- libs/ardour/ardour/session.h | 4 ++-- libs/ardour/ardour/source.h | 2 +- libs/pbd/pbd/stateful.h | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index 2dbc6b1232..b40f1ad27a 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -118,7 +118,7 @@ class LIBARDOUR_API AudioEngine : public PortManager, public SessionHandlePtr bool is_realtime() const; // for the user which hold state_lock to check if reset operation is pending - bool is_reset_requested() const { return g_atomic_int_get (&_hw_reset_request_count); } + bool is_reset_requested() const { return g_atomic_int_get (const_cast (&_hw_reset_request_count)); } int set_device_name (const std::string&); int set_sample_rate (float); diff --git a/libs/ardour/ardour/automation_list.h b/libs/ardour/ardour/automation_list.h index da496df32a..3b61336f64 100644 --- a/libs/ardour/ardour/automation_list.h +++ b/libs/ardour/ardour/automation_list.h @@ -109,7 +109,7 @@ public: void start_touch (timepos_t const & when); void stop_touch (timepos_t const & when); - bool touching () const { return g_atomic_int_get (&_touching) != 0; } + bool touching () const { return g_atomic_int_get (const_cast(&_touching)) != 0; } bool writing () const { return _state == Write; } bool touch_enabled () const { return _state & (Touch | Latch); } diff --git a/libs/ardour/ardour/midi_channel_filter.h b/libs/ardour/ardour/midi_channel_filter.h index db2dac16b3..7a57e78260 100644 --- a/libs/ardour/ardour/midi_channel_filter.h +++ b/libs/ardour/ardour/midi_channel_filter.h @@ -73,17 +73,17 @@ public: /** Atomically get both the channel mode and mask. */ void get_mode_and_mask(ChannelMode* mode, uint16_t* mask) const { - const uint32_t mm = g_atomic_int_get (&_mode_mask); + const uint32_t mm = g_atomic_int_get (const_cast (&_mode_mask)); *mode = static_cast((mm & 0xFFFF0000) >> 16); *mask = (mm & 0x0000FFFF); } ChannelMode get_channel_mode() const { - return static_cast((g_atomic_int_get (&_mode_mask) & 0xFFFF0000) >> 16); + return static_cast((g_atomic_int_get (const_cast (&_mode_mask)) & 0xFFFF0000) >> 16); } uint16_t get_channel_mask() const { - return g_atomic_int_get (&_mode_mask) & 0x0000FFFF; + return g_atomic_int_get (const_cast (&_mode_mask)) & 0x0000FFFF; } PBD::Signal0 ChannelMaskChanged; diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index dfb3aa6e66..6c33ab21aa 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -390,7 +390,7 @@ public: } RecordState record_status() const { - return (RecordState) g_atomic_int_get (&_record_status); + return (RecordState) g_atomic_int_get (const_cast (&_record_status)); } bool actively_recording () const { @@ -1613,7 +1613,7 @@ private: static const PostTransportWork ProcessCannotProceedMask = PostTransportWork (PostTransportAudition); GATOMIC_QUAL gint _post_transport_work; /* accessed only atomic ops */ - PostTransportWork post_transport_work() const { return (PostTransportWork) g_atomic_int_get (&_post_transport_work); } + PostTransportWork post_transport_work() const { return (PostTransportWork) g_atomic_int_get (const_cast (&_post_transport_work)); } void set_post_transport_work (PostTransportWork ptw) { g_atomic_int_set (&_post_transport_work, (gint) ptw); } void add_post_transport_work (PostTransportWork ptw); diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h index 4b75ad06cc..f69f6bf740 100644 --- a/libs/ardour/ardour/source.h +++ b/libs/ardour/ardour/source.h @@ -134,7 +134,7 @@ public: virtual void inc_use_count (); virtual void dec_use_count (); - int use_count() const { return g_atomic_int_get (&_use_count); } + int use_count() const { return g_atomic_int_get (const_cast (&_use_count)); } bool used() const { return use_count() > 0; } uint32_t level() const { return _level; } diff --git a/libs/pbd/pbd/stateful.h b/libs/pbd/pbd/stateful.h index e474357c4f..4988064f3f 100644 --- a/libs/pbd/pbd/stateful.h +++ b/libs/pbd/pbd/stateful.h @@ -105,7 +105,7 @@ class LIBPBD_API Stateful { virtual void suspend_property_changes (); virtual void resume_property_changes (); - bool property_changes_suspended() const { return g_atomic_int_get (&_stateful_frozen) > 0; } + bool property_changes_suspended() const { return g_atomic_int_get (const_cast (&_stateful_frozen)) > 0; } protected: