1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-28 20:02:00 +03:00

Work around GCC 12 warning of uninitialized use

Use pointers to pass state objects to service constructors
to work around GCC 12 warning

  error: member ‘wsrep::mock_storage_service::client_state_’
  is used uninitialized
This commit is contained in:
Teemu Ollakka
2023-02-26 10:31:07 +02:00
parent 9e8708af7e
commit 3b3429d8df
10 changed files with 46 additions and 42 deletions

View File

@ -34,7 +34,7 @@ namespace wsrep
class mock_server_service : public wsrep::server_service
{
public:
mock_server_service(wsrep::server_state& server_state)
mock_server_service(wsrep::server_state* server_state)
: sync_point_enabled_()
, sync_point_action_()
, sst_before_init_()
@ -44,18 +44,20 @@ namespace wsrep
, logged_view_()
, position_()
{ }
mock_server_service(const mock_server_service&) = delete;
mock_server_service& operator=(const mock_server_service&) = delete;
wsrep::storage_service* storage_service(wsrep::client_service&)
WSREP_OVERRIDE
{
return new wsrep::mock_storage_service(server_state_,
return new wsrep::mock_storage_service(*server_state_,
wsrep::client_id(++last_client_id_));
}
wsrep::storage_service* storage_service(wsrep::high_priority_service&)
WSREP_OVERRIDE
{
return new wsrep::mock_storage_service(server_state_,
return new wsrep::mock_storage_service(*server_state_,
wsrep::client_id(++last_client_id_));
}
@ -70,11 +72,11 @@ namespace wsrep
WSREP_OVERRIDE
{
wsrep::mock_client* cs(new wsrep::mock_client(
server_state_,
*server_state_,
wsrep::client_id(++last_client_id_),
wsrep::client_state::m_high_priority));
wsrep::mock_high_priority_service* ret(
new wsrep::mock_high_priority_service(server_state_,
new wsrep::mock_high_priority_service(*server_state_,
cs, false));
cs->open(cs->id());
cs->before_command();
@ -85,11 +87,11 @@ namespace wsrep
wsrep::high_priority_service&) WSREP_OVERRIDE
{
wsrep::mock_client* cs(new wsrep::mock_client(
server_state_,
*server_state_,
wsrep::client_id(++last_client_id_),
wsrep::client_state::m_high_priority));
wsrep::mock_high_priority_service* ret(
new wsrep::mock_high_priority_service(server_state_,
new wsrep::mock_high_priority_service(*server_state_,
cs, false));
cs->open(cs->id());
cs->before_command();
@ -115,7 +117,7 @@ namespace wsrep
void log_message(enum wsrep::log::level level, const char* message)
WSREP_OVERRIDE
{
wsrep::log(level, server_state_.name().c_str()) << message;
wsrep::log(level, server_state_->name().c_str()) << message;
}
void log_dummy_write_set(wsrep::client_state&,
const wsrep::ws_meta&)
@ -196,7 +198,7 @@ namespace wsrep
case spa_none:
break;
case spa_initialize:
server_state_.initialized();
server_state_->initialized();
break;
case spa_initialize_error:
throw wsrep::runtime_error("Inject initialization error");
@ -224,7 +226,7 @@ namespace wsrep
position_ = position;
}
private:
wsrep::server_state& server_state_;
wsrep::server_state* server_state_;
unsigned long long last_client_id_;
unsigned long long last_transaction_id_;
wsrep::view logged_view_;