Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SplitDuplexLinkImpl always have SharingPolicy::SPLITDUPLEX. Use a sdingle assert...
[simgrid.git] / src / s4u / s4u_Link.cpp
index 74ad674..2e2a3ba 100644 (file)
@@ -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<kernel::resource::LinkImpl*>(pimpl_);
+  auto* link_impl = dynamic_cast<kernel::resource::LinkImpl*>(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)