X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/63dae9fee48b67ed8302130aa84c8a54cd42241b..3f367762081b50ecd16c09ef850e2daa823a99a0:/src/s4u/s4u_Link.cpp diff --git a/src/s4u/s4u_Link.cpp b/src/s4u/s4u_Link.cpp index 65d544b48d..2e2a3ba652 100644 --- a/src/s4u/s4u_Link.cpp +++ b/src/s4u/s4u_Link.cpp @@ -37,10 +37,12 @@ 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"); - return dynamic_cast(pimpl_); + auto* link_impl = dynamic_cast(pimpl_); + 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; } Link* Link::by_name_or_null(const std::string& name) @@ -195,12 +197,16 @@ Link* Link::set_properties(const std::unordered_map& p Link* SplitDuplexLink::get_link_up() const { - return dynamic_cast(pimpl_)->get_link_up(); + const auto* pimpl = dynamic_cast(pimpl_); + xbt_assert(pimpl, "Requesting link_up from a non split-duplex link: %s", get_cname()); + return pimpl->get_link_up(); } Link* SplitDuplexLink::get_link_down() const { - return dynamic_cast(pimpl_)->get_link_down(); + const auto* pimpl = dynamic_cast(pimpl_); + xbt_assert(pimpl, "Requesting link_down from a non split-duplex link: %s", get_cname()); + return pimpl->get_link_down(); } SplitDuplexLink* SplitDuplexLink::by_name(const std::string& name)