From a0eb6ee981f8851b7348355a9ebe59a4479d6189 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 8 Jan 2017 16:36:20 +0100 Subject: [PATCH] Initialize a field in the constructor (+cosmetics) --- src/mc/Process.cpp | 11 ++++------- src/mc/mc_checkpoint.cpp | 5 +---- src/mc/mc_snapshot.cpp | 14 +++++++------- src/mc/mc_snapshot.h | 2 +- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/mc/Process.cpp b/src/mc/Process.cpp index 2fc57aa573..14f08904b1 100644 --- a/src/mc/Process.cpp +++ b/src/mc/Process.cpp @@ -430,13 +430,10 @@ simgrid::mc::Variable* Process::find_variable(const char* name) const void Process::read_variable(const char* name, void* target, size_t size) const { simgrid::mc::Variable* var = this->find_variable(name); - if (!var->address) - xbt_die("No simple location for this variable"); - if (!var->type->full_type) - xbt_die("Partial type for %s, cannot check size", name); - if ((size_t) var->type->full_type->byte_size != size) - xbt_die("Unexpected size for %s (expected %zi, was %zi)", - name, size, (size_t) var->type->full_type->byte_size); + xbt_assert(var->address, "No simple location for this variable"); + xbt_assert(var->type->full_type, "Partial type for %s, cannot check size", name); + xbt_assert((size_t)var->type->full_type->byte_size == size, "Unexpected size for %s (expected %zi, was %zi)", name, + size, (size_t)var->type->full_type->byte_size); this->read_bytes(target, size, remote(var->address)); } diff --git a/src/mc/mc_checkpoint.cpp b/src/mc/mc_checkpoint.cpp index d17abc84c1..24a03ae2ad 100644 --- a/src/mc/mc_checkpoint.cpp +++ b/src/mc/mc_checkpoint.cpp @@ -563,10 +563,7 @@ std::shared_ptr take_snapshot(int num_state) simgrid::mc::Process* mc_process = &mc_model_checker->process(); - std::shared_ptr snapshot = - std::make_shared(mc_process); - - snapshot->num_state = num_state; + std::shared_ptr snapshot = std::make_shared(mc_process, num_state); for (auto& p : mc_model_checker->process().simix_processes()) snapshot->enabled_processes.insert(p.copy.getBuffer()->pid); diff --git a/src/mc/mc_snapshot.cpp b/src/mc/mc_snapshot.cpp index 7e67049042..0e92ed0ef3 100644 --- a/src/mc/mc_snapshot.cpp +++ b/src/mc/mc_snapshot.cpp @@ -159,13 +159,13 @@ int MC_snapshot_memcmp( namespace simgrid { namespace mc { -Snapshot::Snapshot(Process* process) : - AddressSpace(process), - num_state(0), - heap_bytes_used(0), - enabled_processes(), - privatization_index(0), - hash(0) +Snapshot::Snapshot(Process* process, int _num_state) + : AddressSpace(process) + , num_state(_num_state) + , heap_bytes_used(0) + , enabled_processes() + , privatization_index(0) + , hash(0) { } diff --git a/src/mc/mc_snapshot.h b/src/mc/mc_snapshot.h index c799698414..e224509304 100644 --- a/src/mc/mc_snapshot.h +++ b/src/mc/mc_snapshot.h @@ -133,7 +133,7 @@ namespace mc { class XBT_PRIVATE Snapshot final : public AddressSpace { public: - Snapshot(Process* process); + Snapshot(Process* process, int num_state); ~Snapshot(); const void* read_bytes(void* buffer, std::size_t size, RemotePtr address, int process_index = ProcessIndexAny, -- 2.20.1