diff --git a/test/config.cc b/test/config.cc index f7f960c5..2142eb26 100644 --- a/test/config.cc +++ b/test/config.cc @@ -450,18 +450,14 @@ using namespace config; actor_config::actor_config(actor_testcase testcase, const actor_params ¶ms, unsigned space_id, unsigned wait4id) - : params(params) { - this->space_id = space_id; - this->actor_id = 1 + (unsigned)global::actors.size(); - this->testcase = testcase; - this->wait4id = wait4id; - signal_nops = 0; -} + : actor_config_pod(1 + unsigned(global::actors.size()), testcase, space_id, + wait4id), + params(params) {} const std::string actor_config::serialize(const char *prefix) const { simple_checksum checksum; - std::string result; + if (prefix) result.append(prefix); @@ -473,13 +469,13 @@ const std::string actor_config::serialize(const char *prefix) const { result.append(params.pathname_log); result.push_back('|'); - static_assert(std::is_pod::value, + static_assert(std::is_trivially_copyable::value, "actor_params_pod should by POD"); result.append(data2hex(static_cast(¶ms), sizeof(actor_params_pod), checksum)); result.push_back('|'); - static_assert(std::is_pod::value, + static_assert(std::is_trivially_copyable::value, "actor_config_pod should by POD"); result.append(data2hex(static_cast(this), sizeof(actor_config_pod), checksum)); @@ -525,7 +521,7 @@ bool actor_config::deserialize(const char *str, actor_config &config) { TRACE("<< actor_config::deserialize: slash-3\n"); return false; } - static_assert(std::is_pod::value, + static_assert(std::is_trivially_copyable::value, "actor_params_pod should by POD"); if (!hex2data(str, slash, static_cast(&config.params), sizeof(actor_params_pod), checksum)) { @@ -540,7 +536,7 @@ bool actor_config::deserialize(const char *str, actor_config &config) { TRACE("<< actor_config::deserialize: slash-4\n"); return false; } - static_assert(std::is_pod::value, + static_assert(std::is_trivially_copyable::value, "actor_config_pod should by POD"); if (!hex2data(str, slash, static_cast(&config), sizeof(actor_config_pod), checksum)) { diff --git a/test/config.h b/test/config.h index 7efd09dd..38fe9c09 100644 --- a/test/config.h +++ b/test/config.h @@ -224,55 +224,61 @@ struct keygen_params_pod { * номера будет отрезано для генерации значения. */ - uint8_t width; - uint8_t mesh; - uint8_t rotate; - uint8_t split; - uint32_t seed; - uint64_t offset; - keygen_case keycase; + uint8_t width{0}; + uint8_t mesh{0}; + uint8_t rotate{0}; + uint8_t split{0}; + uint32_t seed{0}; + uint64_t offset{0}; + keygen_case keycase{kc_random}; }; struct actor_params_pod { - unsigned mode_flags; - unsigned table_flags; - intptr_t size_lower; - intptr_t size_now; - intptr_t size_upper; - int shrink_threshold; - int growth_step; - int pagesize; + unsigned mode_flags{0}; + unsigned table_flags{0}; + intptr_t size_lower{0}; + intptr_t size_now{0}; + intptr_t size_upper{0}; + int shrink_threshold{0}; + int growth_step{0}; + int pagesize{0}; - unsigned test_duration; - unsigned test_nops; - unsigned nrepeat; - unsigned nthreads; + unsigned test_duration{0}; + unsigned test_nops{0}; + unsigned nrepeat{0}; + unsigned nthreads{0}; - unsigned keylen_min, keylen_max; - unsigned datalen_min, datalen_max; + unsigned keylen_min{0}, keylen_max{0}; + unsigned datalen_min{0}, datalen_max{0}; - unsigned batch_read; - unsigned batch_write; + unsigned batch_read{0}; + unsigned batch_write{0}; - unsigned delaystart; - unsigned waitfor_nops; - unsigned inject_writefaultn; + unsigned delaystart{0}; + unsigned waitfor_nops{0}; + unsigned inject_writefaultn{0}; - unsigned max_readers; - unsigned max_tables; + unsigned max_readers{0}; + unsigned max_tables{0}; keygen_params_pod keygen; - uint8_t loglevel; - bool drop_table; - bool ignore_dbfull; - bool speculum; + uint8_t loglevel{0}; + bool drop_table{0}; + bool ignore_dbfull{0}; + bool speculum{0}; }; struct actor_config_pod { - unsigned actor_id, space_id; - actor_testcase testcase; - unsigned wait4id; - unsigned signal_nops; + unsigned actor_id{0}, space_id{0}; + actor_testcase testcase{ac_none}; + unsigned wait4id{0}; + unsigned signal_nops{0}; + + actor_config_pod() = default; + actor_config_pod(unsigned actor_id, actor_testcase testcase, + unsigned space_id, unsigned wait4id) + : actor_id(actor_id), space_id(space_id), testcase(testcase), + wait4id(wait4id) {} }; #pragma pack(pop) @@ -286,8 +292,9 @@ void dump(const char *title = "config-dump: "); struct actor_params : public config::actor_params_pod { std::string pathname_log; std::string pathname_db; - void set_defaults(const std::string &tmpdir); + actor_params() = default; + void set_defaults(const std::string &tmpdir); unsigned mdbx_keylen_min() const; unsigned mdbx_keylen_max() const; unsigned mdbx_datalen_min() const; @@ -299,10 +306,11 @@ struct actor_config : public config::actor_config_pod { bool wanna_event4signalling() const { return true /* TODO ? */; } + actor_config() = default; actor_config(actor_testcase testcase, const actor_params ¶ms, unsigned space_id, unsigned wait4id); - actor_config(const char *str) { + actor_config(const char *str) : actor_config() { if (!deserialize(str, *this)) failure("Invalid internal parameter '%s'\n", str); } diff --git a/test/keygen.h b/test/keygen.h index b5674f1c..052fc7ef 100644 --- a/test/keygen.h +++ b/test/keygen.h @@ -103,13 +103,13 @@ buffer alloc(size_t limit); class maker { config::keygen_params_pod mapping; - serial_t base; - serial_t salt; + serial_t base{0}; + serial_t salt{0}; struct essentials { - uint16_t minlen; - uint16_t flags; - uint32_t maxlen; + uint16_t minlen{0}; + uint16_t flags{0}; + uint32_t maxlen{0}; } key_essentials, value_essentials; static void mk_begin(const serial_t serial, const essentials ¶ms, @@ -122,8 +122,6 @@ class maker { } public: - maker() { memset(this, 0, sizeof(*this)); } - void pair(serial_t serial, const buffer &key, buffer &value, serial_t value_age, const bool keylen_changeable); void setup(const config::actor_params_pod &actor, unsigned actor_id, diff --git a/test/utils.h b/test/utils.h index a5061c14..9e6d4627 100644 --- a/test/utils.h +++ b/test/utils.h @@ -243,9 +243,9 @@ static __inline void cpu_relax() { //----------------------------------------------------------------------------- struct simple_checksum { - uint64_t value; + uint64_t value{0}; - simple_checksum() : value(0) {} + simple_checksum() = default; void push(const uint32_t &data) { value += data * UINT64_C(9386433910765580089) + 1;