From 60bea6943e6b95947e2a49c22cdd369220d76db2 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Fri, 8 Jun 2018 11:01:23 +0200 Subject: [PATCH] cosmetics: this is a bool --- include/simgrid/kernel/resource/Action.hpp | 2 +- src/kernel/resource/Action.cpp | 6 +++--- src/plugins/vm/VirtualMachineImpl.cpp | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/simgrid/kernel/resource/Action.hpp b/include/simgrid/kernel/resource/Action.hpp index 5c33f5ba20..9ed8456001 100644 --- a/include/simgrid/kernel/resource/Action.hpp +++ b/include/simgrid/kernel/resource/Action.hpp @@ -158,7 +158,7 @@ public: void ref(); /** @brief Unref that action (and destroy it if refcount reaches 0) * @return true if the action was destroyed and false if someone still has references on it */ - int unref(); + bool unref(); /** @brief Cancel the current Action if running */ virtual void cancel(); diff --git a/src/kernel/resource/Action.cpp b/src/kernel/resource/Action.cpp index 86f2e2a460..4615d31dcb 100644 --- a/src/kernel/resource/Action.cpp +++ b/src/kernel/resource/Action.cpp @@ -149,14 +149,14 @@ void Action::cancel() } } -int Action::unref() +bool Action::unref() { refcount_--; if (not refcount_) { delete this; - return 1; + return true; } - return 0; + return false; } void Action::suspend() diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index 07bb1691c9..e57230a484 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -135,8 +135,8 @@ VirtualMachineImpl::~VirtualMachineImpl() allVms_.erase(iter); /* Free the cpu_action of the VM. */ - XBT_ATTRIB_UNUSED int ret = action_->unref(); - xbt_assert(ret == 1, "Bug: some resource still remains"); + XBT_ATTRIB_UNUSED bool ret = action_->unref(); + xbt_assert(ret, "Bug: some resource still remains"); } void VirtualMachineImpl::suspend(smx_actor_t issuer) @@ -252,7 +252,8 @@ void VirtualMachineImpl::set_physical_host(s4u::Host* destination) new_cpu_action->set_bound(old_bound); } - xbt_assert(action_->unref() == 1, "Bug: some resource still remains"); + XBT_ATTRIB_UNUSED bool ret = action_->unref(); + xbt_assert(ret, "Bug: some resource still remains"); action_ = new_cpu_action; -- 2.20.1