From 40d3b67a85d3234e873dd757fa6d863d58707534 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 20 Nov 2013 22:35:51 +0100 Subject: [PATCH] Fix warnings about comparisons of integers of different types. --- src/surf/cpu.cpp | 12 ++++-------- src/surf/cpu_cas01.cpp | 4 ++-- src/surf/network.cpp | 2 +- src/surf/surf_routing.cpp | 4 ++-- src/surf/surf_routing_dijkstra.cpp | 2 +- src/surf/surf_routing_floyd.cpp | 6 +++--- src/surf/surf_routing_full.cpp | 6 +++--- src/surf/vm_workstation.cpp | 15 ++++++--------- 8 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/surf/cpu.cpp b/src/surf/cpu.cpp index 2a9acf9ac0..342c1bb9a6 100644 --- a/src/surf/cpu.cpp +++ b/src/surf/cpu.cpp @@ -205,8 +205,7 @@ void CpuActionLmm::setAffinity(CpuLmmPtr cpu, unsigned long mask) unsigned long nbits = 0; /* FIXME: There is much faster algorithms doing this. */ - unsigned long i; - for (i = 0; i < cpu->m_core; i++) { + for (int i = 0; i < cpu->m_core; i++) { unsigned long has_affinity = (1UL << i) & mask; if (has_affinity) nbits += 1; @@ -219,11 +218,8 @@ void CpuActionLmm::setAffinity(CpuLmmPtr cpu, unsigned long mask) } } - - - unsigned long i; - for (i = 0; i < cpu->m_core; i++) { - XBT_DEBUG("clear affinity %p to cpu-%lu@%s", this, i, cpu->m_name); + for (int i = 0; i < cpu->m_core; i++) { + XBT_DEBUG("clear affinity %p to cpu-%d@%s", this, i, cpu->m_name); lmm_shrink(cpu->p_model->p_maxminSystem, cpu->p_constraintCore[i], var_obj); unsigned long has_affinity = (1UL << i) & mask; @@ -237,7 +233,7 @@ void CpuActionLmm::setAffinity(CpuLmmPtr cpu, unsigned long mask) * accept affinity settings on a future host. We might be able to assign * zero to elem->value to maintain such inactive affinity settings in the * system. But, this will make the system complex. */ - XBT_DEBUG("set affinity %p to cpu-%lu@%s", this, i, cpu->m_name); + XBT_DEBUG("set affinity %p to cpu-%d@%s", this, i, cpu->m_name); lmm_expand(cpu->p_model->p_maxminSystem, cpu->p_constraintCore[i], var_obj, 1.0); } } diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 2cca94a334..2191f8b8d2 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -463,7 +463,7 @@ double CpuCas01Lmm::getCurrentPowerPeak() double CpuCas01Lmm::getPowerPeakAt(int pstate_index) { xbt_dynar_t plist = p_powerPeakList; - xbt_assert((pstate_index <= xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)"); + xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)"); return xbt_dynar_get_as(plist, pstate_index, double); } @@ -476,7 +476,7 @@ int CpuCas01Lmm::getNbPstates() void CpuCas01Lmm::setPowerPeakAt(int pstate_index) { xbt_dynar_t plist = p_powerPeakList; - xbt_assert((pstate_index <= xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)"); + xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)"); double new_power_peak = xbt_dynar_get_as(plist, pstate_index, double); m_pstate = pstate_index; diff --git a/src/surf/network.cpp b/src/surf/network.cpp index 66d2a314e8..05165946a5 100644 --- a/src/surf/network.cpp +++ b/src/surf/network.cpp @@ -322,7 +322,7 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double delta) #ifdef HAVE_TRACING if (TRACE_is_enabled()) { int n = lmm_get_number_of_cnst_from_var(p_maxminSystem, action->p_variable); - unsigned int i; + int i; for (i = 0; i < n; i++){ lmm_constraint_t constraint = lmm_get_cnst_from_var(p_maxminSystem, action->p_variable, diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index d667710c46..1d6035e8fb 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2009, 2010, 2011. The SimGrid Team. +/* Copyright (c) 2009, 2010, 2011, 2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -132,7 +132,7 @@ static void parse_S_host_link(sg_platf_host_link_cbarg_t host) current_routing->p_linkUpDownList = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL); // If dynar is is greater than edge id and if the host_link is already defined - if(xbt_dynar_length(current_routing->p_linkUpDownList) > info->m_id && + if((int)xbt_dynar_length(current_routing->p_linkUpDownList) > info->m_id && xbt_dynar_get_as(current_routing->p_linkUpDownList, info->m_id, void*)) xbt_die("Host_link for '%s' is already defined!",host->id); diff --git a/src/surf/surf_routing_dijkstra.cpp b/src/surf/surf_routing_dijkstra.cpp index d3ae3358d5..417e3c9df6 100644 --- a/src/surf/surf_routing_dijkstra.cpp +++ b/src/surf/surf_routing_dijkstra.cpp @@ -184,7 +184,7 @@ xbt_dynar_t AsDijkstra::getOnelinkRoutes() int src,dst; RoutingEdgePtr src_elm, dst_elm; - size_t table_size = xbt_dynar_length(p_indexNetworkElm); + int table_size = (int)xbt_dynar_length(p_indexNetworkElm); for(src=0; src < table_size; src++) { for(dst=0; dst< table_size; dst++) { xbt_dynar_reset(route->link_list); diff --git a/src/surf/surf_routing_floyd.cpp b/src/surf/surf_routing_floyd.cpp index 17472ea80a..6bd1969333 100644 --- a/src/surf/surf_routing_floyd.cpp +++ b/src/surf/surf_routing_floyd.cpp @@ -30,8 +30,8 @@ AsFloyd::AsFloyd(): AsGeneric() { AsFloyd::~AsFloyd(){ int i, j; - size_t table_size; - table_size = xbt_dynar_length(p_indexNetworkElm); + int table_size; + table_size = (int)xbt_dynar_length(p_indexNetworkElm); /* Delete link_table */ for (i = 0; i < table_size; i++) for (j = 0; j < table_size; j++) @@ -144,7 +144,7 @@ void AsFloyd::parseRoute(sg_platf_route_cbarg_t route) int as_route = 0; /* set the size of table routing */ - size_t table_size = xbt_dynar_length(p_indexNetworkElm); + int table_size = (int)xbt_dynar_length(p_indexNetworkElm); RoutingEdgePtr src_net_elm, dst_net_elm; src_net_elm = sg_routing_edge_by_name_or_null(src); diff --git a/src/surf/surf_routing_full.cpp b/src/surf/surf_routing_full.cpp index 9c74b224dd..814aba7a9b 100644 --- a/src/surf/surf_routing_full.cpp +++ b/src/surf/surf_routing_full.cpp @@ -24,12 +24,12 @@ AS_t model_full_create(void) void model_full_end(AS_t _routing) { - unsigned int i; + int i; sg_platf_route_cbarg_t e_route; /* set utils vars */ AsFullPtr routing = ((AsFullPtr) _routing); - size_t table_size = xbt_dynar_length(routing->p_indexNetworkElm); + int table_size = (int)xbt_dynar_length(routing->p_indexNetworkElm); /* Create table if necessary */ if (!routing->p_routingTable) @@ -56,7 +56,7 @@ AsFull::AsFull(){ } AsFull::~AsFull(){ - size_t table_size = xbt_dynar_length(p_indexNetworkElm); + int table_size = (int)xbt_dynar_length(p_indexNetworkElm); int i, j; /* Delete routing table */ for (i = 0; i < table_size; i++) diff --git a/src/surf/vm_workstation.cpp b/src/surf/vm_workstation.cpp index 072942ca83..fe17e16c95 100644 --- a/src/surf/vm_workstation.cpp +++ b/src/surf/vm_workstation.cpp @@ -273,17 +273,14 @@ WorkstationVM2013Lmm::~WorkstationVM2013Lmm() /* Free the cpu resource of the VM. If using power_trace, we will have to * free other objects than lmm_constraint. */ lmm_constraint_free(cpu->p_model->p_maxminSystem, cpu->p_constraint); - { - unsigned long i; - for (i = 0; i < cpu->m_core; i++) { - void *cnst_id = cpu->p_constraintCore[i]->id; - lmm_constraint_free(cpu->p_model->p_maxminSystem, cpu->p_constraintCore[i]); - xbt_free(cnst_id); - } - - xbt_free(cpu->p_constraintCore); + for (int i = 0; i < cpu->m_core; i++) { + void *cnst_id = cpu->p_constraintCore[i]->id; + lmm_constraint_free(cpu->p_model->p_maxminSystem, cpu->p_constraintCore[i]); + xbt_free(cnst_id); } + xbt_free(cpu->p_constraintCore); + delete cpu; /* Free the network resource of the VM. */ -- 2.20.1