Commit 0b849a44 authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent b5fe7ab8
......@@ -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,
......
......@@ -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 @@ class Wsrep_condition_variable : public wsrep::condition_variable
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 */
......@@ -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 */
......@@ -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)
{ }
......
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