From: Martin Quinson Date: Sat, 17 Aug 2019 14:57:04 +0000 (+0200) Subject: use assignment to non-trivial class rather than artificial trivialization and memset X-Git-Tag: v3.24~182 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b41c921fc0a6a13f5db4d6cefb9b6955d5f21e3b use assignment to non-trivial class rather than artificial trivialization and memset plus some other small cleanups --- diff --git a/src/mc/mc_config.cpp b/src/mc/mc_config.cpp index 8f60917531..9353d3e87d 100644 --- a/src/mc/mc_config.cpp +++ b/src/mc/mc_config.cpp @@ -20,10 +20,6 @@ simgrid::mc::ReductionMode reduction_mode = simgrid::mc::ReductionMode::unset; } #endif -#if !SIMGRID_HAVE_MC -#define _sg_do_model_check 0 -#endif - static void _mc_cfg_cb_check(const char* spec, bool more_check = true) { if (_sg_cfg_init_status && not _sg_do_model_check && more_check) diff --git a/src/mc/mc_record.cpp b/src/mc/mc_record.cpp index 4ea2c9573c..4c7f441c1c 100644 --- a/src/mc/mc_record.cpp +++ b/src/mc/mc_record.cpp @@ -35,7 +35,7 @@ void replay(RecordTrace const& trace) if (not process) xbt_die("Unexpected process (pid:%d).", transition.pid_); smx_simcall_t simcall = &(process->simcall); - if (not simcall || simcall->call_ == SIMCALL_NONE) + if (simcall == nullptr || simcall->call_ == SIMCALL_NONE) xbt_die("No simcall for process %d.", transition.pid_); if (not simgrid::mc::request_is_visible(simcall) || not simgrid::mc::actor_is_enabled(process)) xbt_die("Unexpected simcall."); diff --git a/src/mc/mc_state.cpp b/src/mc/mc_state.cpp index 88254304b8..0106b84c8a 100644 --- a/src/mc/mc_state.cpp +++ b/src/mc/mc_state.cpp @@ -21,8 +21,8 @@ namespace mc { State::State(unsigned long state_number) : num_(state_number) { this->internal_comm.clear(); - std::memset(&this->internal_req, 0, sizeof(this->internal_req)); - std::memset(&this->executed_req_, 0, sizeof(this->executed_req_)); + this->internal_req = s_smx_simcall(); + this->executed_req_ = s_smx_simcall(); actor_states_.resize(MC_smx_get_maxpid()); /* Stateful model checking */ diff --git a/src/simix/popping_private.hpp b/src/simix/popping_private.hpp index fdd0b56b37..fce643ccda 100644 --- a/src/simix/popping_private.hpp +++ b/src/simix/popping_private.hpp @@ -43,13 +43,13 @@ union u_smx_scalar { * @brief Represents a simcall to the kernel. */ struct s_smx_simcall { - e_smx_simcall_t call_; - smx_actor_t issuer_; - smx_timer_t timeout_cb_; // Callback to timeouts - simgrid::mc::SimcallInspector* inspector_; // makes that simcall observable by the MC - int mc_value_; - u_smx_scalar args_[11]; - u_smx_scalar result_; + e_smx_simcall_t call_ = SIMCALL_NONE; + smx_actor_t issuer_ = nullptr; + smx_timer_t timeout_cb_ = nullptr; // Callback to timeouts + simgrid::mc::SimcallInspector* inspector_ = nullptr; // makes that simcall observable by the MC + int mc_value_ = 0; + u_smx_scalar args_[11] = {{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}}; + u_smx_scalar result_ = {0}; }; #define SIMCALL_SET_MC_VALUE(simcall, value) ((simcall).mc_value_ = (value)) diff --git a/teshsuite/mc/random-bug/random-bug.cpp b/teshsuite/mc/random-bug/random-bug.cpp index 6f8463d135..03bc2ae7df 100644 --- a/teshsuite/mc/random-bug/random-bug.cpp +++ b/teshsuite/mc/random-bug/random-bug.cpp @@ -12,7 +12,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(random_bug, "For this example"); enum { ABORT, ASSERT, PRINTF } behavior; -/** An (fake) application with a bug occuring for some random values */ +/** A fake application with a bug occuring for some random values */ static void app() { int x = MC_random(0, 5); @@ -42,6 +42,9 @@ int main(int argc, char* argv[]) } else if (strcmp(argv[1], "printf") == 0) { XBT_INFO("Behavior: printf"); behavior = PRINTF; + } else { + xbt_die("Please use either 'abort', 'assert' or 'printf' as first parameter, to specify what to do when the error " + "is found."); } e.load_platform(argv[2]);