From: Arnaud Giersch Date: Tue, 6 Jul 2021 08:54:27 +0000 (+0200) Subject: SplitDuplexLinkImpl always have SharingPolicy::SPLITDUPLEX. Use a sdingle assert... X-Git-Tag: v3.28~35 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/3f367762081b50ecd16c09ef850e2daa823a99a0 SplitDuplexLinkImpl always have SharingPolicy::SPLITDUPLEX. Use a sdingle assert in Link::get_impl(). --- diff --git a/src/s4u/s4u_Link.cpp b/src/s4u/s4u_Link.cpp index 0f5c751013..2e2a3ba652 100644 --- a/src/s4u/s4u_Link.cpp +++ b/src/s4u/s4u_Link.cpp @@ -37,11 +37,11 @@ Link* Link::by_name(const std::string& name) kernel::resource::LinkImpl* Link::get_impl() const { - xbt_assert( - get_sharing_policy() != SharingPolicy::SPLITDUPLEX, - "Impossible to get a LinkImpl* from a Split-Duplex link. You should call this method to each UP/DOWN member"); auto* link_impl = dynamic_cast(pimpl_); - xbt_assert(link_impl != nullptr); + xbt_assert(link_impl != nullptr, "Impossible to get a LinkImpl* from link. %s.", + (get_sharing_policy() == SharingPolicy::SPLITDUPLEX + ? "For a Split-Duplex link, you should call this method to each UP/DOWN member" + : "Please report this bug")); return link_impl; } diff --git a/src/surf/SplitDuplexLinkImpl.cpp b/src/surf/SplitDuplexLinkImpl.cpp index 329955a538..2b2b003a6f 100644 --- a/src/surf/SplitDuplexLinkImpl.cpp +++ b/src/surf/SplitDuplexLinkImpl.cpp @@ -30,11 +30,6 @@ void SplitDuplexLinkImpl::set_sharing_policy(s4u::Link::SharingPolicy policy) xbt_die("Impossible to change sharing policy of split-duplex links"); } -s4u::Link::SharingPolicy SplitDuplexLinkImpl::get_sharing_policy() const -{ - return sharing_policy_; -} - void SplitDuplexLinkImpl::set_bandwidth(double value) { link_up_->set_bandwidth(value); @@ -96,4 +91,4 @@ void SplitDuplexLinkImpl::set_concurrency_limit(int limit) const } // namespace resource } // namespace kernel -} // namespace simgrid \ No newline at end of file +} // namespace simgrid diff --git a/src/surf/SplitDuplexLinkImpl.hpp b/src/surf/SplitDuplexLinkImpl.hpp index 15ed708538..e8c17213ad 100644 --- a/src/surf/SplitDuplexLinkImpl.hpp +++ b/src/surf/SplitDuplexLinkImpl.hpp @@ -25,7 +25,6 @@ namespace resource { */ class SplitDuplexLinkImpl : public LinkImplIntf { s4u::SplitDuplexLink piface_; - s4u::Link::SharingPolicy sharing_policy_ = s4u::Link::SharingPolicy::SPLITDUPLEX; LinkImpl* link_up_; LinkImpl* link_down_; @@ -49,7 +48,7 @@ public: /** @brief The sharing policy */ void set_sharing_policy(s4u::Link::SharingPolicy policy) override; - s4u::Link::SharingPolicy get_sharing_policy() const override; + s4u::Link::SharingPolicy get_sharing_policy() const override { return s4u::Link::SharingPolicy::SPLITDUPLEX; } /** @brief Get link composing this split-duplex link */ s4u::Link* get_link_up() const { return link_up_->get_iface(); }