diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-02-23 07:18:00 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-02-23 07:18:00 +0200 |
commit | 0b849a441afaa5f4ce1ad1af877363d7b5c4a1e2 (patch) | |
tree | 3182051655a273f906ea7d0fd27d3dae25a19341 | |
parent | b5fe7ab8412d63b784ab318f11506954639f1d3c (diff) | |
download | mariadb-git-0b849a441afaa5f4ce1ad1af877363d7b5c4a1e2.tar.gz |
WSREP: Fix GCC 12.0.1 -Wuninitialized
GCC 12 complains if a reference to an uninitialized object is
being passed to a constructor. The mysql_mutex_t, mysql_cond_t
would be initialized in the constructor body, which is executed
after the initializer list. There is no problem passing a pointer
instead of a reference. The wrapper classes do not dereference
the pointers in the constructor or destructor, so there does not
appear to be any correctness issue.
-rw-r--r-- | sql/sql_class.cc | 4 | ||||
-rw-r--r-- | sql/wsrep_condition_variable.h | 10 | ||||
-rw-r--r-- | sql/wsrep_mutex.h | 10 | ||||
-rw-r--r-- | sql/wsrep_server_state.cc | 4 |
4 files changed, 14 insertions, 14 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 21546ddaebf..7ed58555be1 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -669,8 +669,8 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) /* wsrep-lib */ m_wsrep_next_trx_id(WSREP_UNDEFINED_TRX_ID), - m_wsrep_mutex(LOCK_thd_data), - m_wsrep_cond(COND_wsrep_thd), + m_wsrep_mutex(&LOCK_thd_data), + m_wsrep_cond(&COND_wsrep_thd), m_wsrep_client_service(this, m_wsrep_client_state), m_wsrep_client_state(this, m_wsrep_mutex, diff --git a/sql/wsrep_condition_variable.h b/sql/wsrep_condition_variable.h index 6ad53a3086c..c97b47378f7 100644 --- a/sql/wsrep_condition_variable.h +++ b/sql/wsrep_condition_variable.h @@ -26,7 +26,7 @@ class Wsrep_condition_variable : public wsrep::condition_variable { public: - Wsrep_condition_variable(mysql_cond_t& cond) + Wsrep_condition_variable(mysql_cond_t* cond) : m_cond(cond) { } ~Wsrep_condition_variable() @@ -34,21 +34,21 @@ public: void notify_one() { - mysql_cond_signal(&m_cond); + mysql_cond_signal(m_cond); } void notify_all() { - mysql_cond_broadcast(&m_cond); + mysql_cond_broadcast(m_cond); } void wait(wsrep::unique_lock<wsrep::mutex>& lock) { mysql_mutex_t* mutex= static_cast<mysql_mutex_t*>(lock.mutex()->native()); - mysql_cond_wait(&m_cond, mutex); + mysql_cond_wait(m_cond, mutex); } private: - mysql_cond_t& m_cond; + mysql_cond_t* m_cond; }; #endif /* WSREP_CONDITION_VARIABLE_H */ diff --git a/sql/wsrep_mutex.h b/sql/wsrep_mutex.h index 3454b44e0ec..f396c1be331 100644 --- a/sql/wsrep_mutex.h +++ b/sql/wsrep_mutex.h @@ -25,26 +25,26 @@ class Wsrep_mutex : public wsrep::mutex { public: - Wsrep_mutex(mysql_mutex_t& mutex) + Wsrep_mutex(mysql_mutex_t* mutex) : m_mutex(mutex) { } void lock() { - mysql_mutex_lock(&m_mutex); + mysql_mutex_lock(m_mutex); } void unlock() { - mysql_mutex_unlock(&m_mutex); + mysql_mutex_unlock(m_mutex); } void* native() { - return &m_mutex; + return m_mutex; } private: - mysql_mutex_t& m_mutex; + mysql_mutex_t* m_mutex; }; #endif /* WSREP_MUTEX_H */ diff --git a/sql/wsrep_server_state.cc b/sql/wsrep_server_state.cc index ebc4efaabe5..973850871b1 100644 --- a/sql/wsrep_server_state.cc +++ b/sql/wsrep_server_state.cc @@ -43,8 +43,8 @@ Wsrep_server_state::Wsrep_server_state(const std::string& name, initial_position, max_protocol_version, wsrep::server_state::rm_sync) - , m_mutex(LOCK_wsrep_server_state) - , m_cond(COND_wsrep_server_state) + , m_mutex(&LOCK_wsrep_server_state) + , m_cond(&COND_wsrep_server_state) , m_service(*this) { } |