Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
reduce the amount of casts
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 19 Aug 2016 10:49:14 +0000 (12:49 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 19 Aug 2016 10:49:14 +0000 (12:49 +0200)
src/kernel/routing/AsCluster.hpp
src/kernel/routing/AsClusterTorus.cpp
src/kernel/routing/AsFloyd.cpp
src/kernel/routing/AsVivaldi.cpp
src/surf/sg_platf.cpp
src/surf/surf_routing.hpp

index 013ca08..229b73f 100644 (file)
@@ -30,7 +30,7 @@ public:
   NetCard *router_ = nullptr;
   bool hasLimiter_  = false;
   bool hasLoopback_ = false;
-  int linkCountPerNode_ = 1; /* may be 1 (if only a private link), 2 or 3 (if limiter and loopback) */
+  unsigned int linkCountPerNode_ = 1; /* may be 1 (if only a private link), 2 or 3 (if limiter and loopback) */
 
 };
 
index b88ed42..70f2549 100644 (file)
@@ -132,8 +132,8 @@ namespace simgrid {
        * TODO Change to dynamic assignment
        */
       unsigned int j, cur_dim, dim_product = 1;
-      int current_node = src->id();
-      int unsigned next_node = 0;
+      unsigned int current_node = src->id();
+      unsigned int next_node = 0;
       /*
        * Arrays that hold the coordinates of the current node and
        * the target; comparing the values at the i-th position of
index 78d60e1..eb4c8ad 100644 (file)
@@ -49,7 +49,7 @@ void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbar
   /* create a result route */
   xbt_dynar_t route_stack = xbt_dynar_new(sizeof(sg_platf_route_cbarg_t), nullptr);
   int pred;
-  int cur = dst->id();
+  unsigned int cur = dst->id();
   do {
     pred = TO_FLOYD_PRED(src->id(), cur);
     if (pred == -1)
index c922633..007a453 100644 (file)
@@ -68,7 +68,7 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb
   }
 
   /* Retrieve the private links */
-  if (static_cast<int>(privateLinks_.size()) > src->id()) {
+  if (privateLinks_.size() > src->id()) {
     s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id());
     if(info.linkUp) {
       route->link_list->push_back(info.linkUp);
@@ -76,7 +76,7 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb
         *lat += info.linkUp->getLatency();
     }
   }
-  if (static_cast<int>(privateLinks_.size()) >dst->id()) {
+  if (privateLinks_.size() >dst->id()) {
     s_surf_parsing_link_up_down_t info = privateLinks_.at(dst->id());
     if(info.linkDown) {
       route->link_list->push_back(info.linkDown);
index b69168e..ea4fa5a 100644 (file)
@@ -333,7 +333,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
       info_loop.linkDown = Link::byName(tmp_link);
       free(tmp_link);
       auto as_cluster = static_cast<AsCluster*>(current_as);
-      if (rankId*as_cluster->linkCountPerNode_ >= static_cast<int>(as_cluster->privateLinks_.size())){
+      if (rankId*as_cluster->linkCountPerNode_ >= as_cluster->privateLinks_.size()) {
         s_surf_parsing_link_up_down_t dummy;
         dummy.linkUp = nullptr;
         dummy.linkDown = nullptr;
@@ -913,7 +913,7 @@ void sg_platf_new_hostlink(sg_platf_host_link_cbarg_t hostlink)
 
   // If dynar is is greater than netcard id and if the host_link is already defined
   auto as_cluster = static_cast<simgrid::kernel::routing::AsCluster*>(current_routing);
-  if(static_cast<int>(as_cluster->privateLinks_.size()) > netcard->id()){
+  if (as_cluster->privateLinks_.size() > netcard->id()){
     if (as_cluster->privateLinks_.at(netcard->id()).linkUp != nullptr)
     surf_parse_error("Host_link for '%s' is already defined!",hostlink->id);
   } else {
index 56b5146..5e096ce 100644 (file)
@@ -45,7 +45,7 @@ class RoutingPlatf;
 class NetCard {
 public:
   virtual ~NetCard(){};
-  virtual int id()=0; // Our rank in the vertices_ array of our containing AS.
+  virtual unsigned int id()=0; // Our rank in the vertices_ array of our containing AS.
   virtual char *name()=0;
   virtual AsImpl *containingAS()=0; // This is the AS in which I am
   virtual bool isAS()=0;
@@ -69,7 +69,7 @@ public:
   }
   ~NetCardImpl() { xbt_free(name_);};
 
-  int id()           override {return id_;}
+  unsigned int id()  override {return id_;}
   char *name()       override {return name_;}
   AsImpl *containingAS() override {return containingAS_;}
 
@@ -78,7 +78,7 @@ public:
   bool isRouter()    override {return componentType_ == Type::Router;}
 
 private:
-  int id_ = -1;
+  unsigned int id_;
   char *name_;
   NetCard::Type componentType_;
   AsImpl *containingAS_;