From 375ccd95341779289dbafc250fda96c3bb39f9cc Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 19 Aug 2016 12:49:14 +0200 Subject: [PATCH] reduce the amount of casts --- src/kernel/routing/AsCluster.hpp | 2 +- src/kernel/routing/AsClusterTorus.cpp | 4 ++-- src/kernel/routing/AsFloyd.cpp | 2 +- src/kernel/routing/AsVivaldi.cpp | 4 ++-- src/surf/sg_platf.cpp | 4 ++-- src/surf/surf_routing.hpp | 6 +++--- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/kernel/routing/AsCluster.hpp b/src/kernel/routing/AsCluster.hpp index 013ca08bc6..229b73fe5d 100644 --- a/src/kernel/routing/AsCluster.hpp +++ b/src/kernel/routing/AsCluster.hpp @@ -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) */ }; diff --git a/src/kernel/routing/AsClusterTorus.cpp b/src/kernel/routing/AsClusterTorus.cpp index b88ed42d4e..70f254997b 100644 --- a/src/kernel/routing/AsClusterTorus.cpp +++ b/src/kernel/routing/AsClusterTorus.cpp @@ -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 diff --git a/src/kernel/routing/AsFloyd.cpp b/src/kernel/routing/AsFloyd.cpp index 78d60e1db9..eb4c8adecf 100644 --- a/src/kernel/routing/AsFloyd.cpp +++ b/src/kernel/routing/AsFloyd.cpp @@ -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) diff --git a/src/kernel/routing/AsVivaldi.cpp b/src/kernel/routing/AsVivaldi.cpp index c922633842..007a4539f6 100644 --- a/src/kernel/routing/AsVivaldi.cpp +++ b/src/kernel/routing/AsVivaldi.cpp @@ -68,7 +68,7 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb } /* Retrieve the private links */ - if (static_cast(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(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); diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index b69168e344..ea4fa5ae44 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -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(current_as); - if (rankId*as_cluster->linkCountPerNode_ >= static_cast(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(current_routing); - if(static_cast(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 { diff --git a/src/surf/surf_routing.hpp b/src/surf/surf_routing.hpp index 56b51464c0..5e096cefc5 100644 --- a/src/surf/surf_routing.hpp +++ b/src/surf/surf_routing.hpp @@ -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_; -- 2.20.1