From 6a09e6076188e3de9637c24d4ae74839fb03b33f Mon Sep 17 00:00:00 2001 From: navarrop Date: Mon, 14 Jun 2010 09:30:59 +0000 Subject: [PATCH 1/1] Do not declare variables in the middle of nowhere. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7847 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/gras/Msg/sg_msg.c | 12 +++++++----- src/simdag/sd_daxloader.c | 10 ++++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/gras/Msg/sg_msg.c b/src/gras/Msg/sg_msg.c index b89a657f1b..711fc83c49 100644 --- a/src/gras/Msg/sg_msg.c +++ b/src/gras/Msg/sg_msg.c @@ -27,6 +27,8 @@ gras_msg_t gras_msg_recv_any(void) { /* Build a dynar of all communications I could get something from */ xbt_dynar_t comms = xbt_dynar_new(sizeof(smx_comm_t),NULL); unsigned int cursor; + int got = 0; + smx_comm_t comm; gras_socket_t sock; gras_trp_sg_sock_data_t *sock_data; xbt_dynar_foreach(trp_proc->sockets,cursor,sock) { @@ -38,8 +40,7 @@ gras_msg_t gras_msg_recv_any(void) { } VERB1("Wait on %ld 'sockets'",xbt_dynar_length(comms)); /* Wait for the end of any of these communications */ - int got = SIMIX_network_waitany(comms); - smx_comm_t comm; + got = SIMIX_network_waitany(comms); /* retrieve the message sent in that communication */ xbt_dynar_get_cpy(comms,got,&(comm)); @@ -71,7 +72,8 @@ void gras_msg_send_ext(gras_socket_t sock, int whole_payload_size = 0; /* msg->payload_size is used to memcpy the payload. This is used to report the load onto the simulator. It also counts the size of pointed stuff */ gras_msg_t msg; /* message to send */ - + smx_comm_t comm; + gras_trp_sg_sock_data_t *sock_data = NULL; /*initialize gras message */ msg = xbt_new(s_gras_msg_t, 1); msg->expe = sock; @@ -101,8 +103,8 @@ void gras_msg_send_ext(gras_socket_t sock, whole_payload_size = gras_datadesc_memcpy(msgtype->ctn_type, payload, msg->payl); } - gras_trp_sg_sock_data_t *sock_data = (gras_trp_sg_sock_data_t *) sock->data; - smx_comm_t comm; + sock_data = (gras_trp_sg_sock_data_t *) sock->data; + SIMIX_network_send(sock_data->im_server ? sock_data->rdv_client : sock_data->rdv_client, whole_payload_size,-1,-1,&msg,sizeof(void*),&comm,msg); diff --git a/src/simdag/sd_daxloader.c b/src/simdag/sd_daxloader.c index 92d3ff96ad..6d6c0d9d7e 100644 --- a/src/simdag/sd_daxloader.c +++ b/src/simdag/sd_daxloader.c @@ -68,6 +68,9 @@ static void dax_task_free(void*task){ * for more details. */ xbt_dynar_t SD_daxload(const char*filename) { + xbt_dict_cursor_t cursor; + SD_task_t file; + char *name; FILE* in_file = fopen(filename,"r"); xbt_assert1(in_file, "Unable to open \"%s\"\n", filename); input_buffer = dax__create_buffer(in_file, 10); @@ -91,11 +94,10 @@ xbt_dynar_t SD_daxload(const char*filename) { * Files not produced in the system are said to be produced by root task (top of DAG). * Files not consumed in the system are said to be consumed by end task (bottom of DAG). */ - xbt_dict_cursor_t cursor; - SD_task_t file; - char *name; + xbt_dict_foreach(files,cursor,name,file) { unsigned int cpt1,cpt2; + SD_task_t newfile = NULL; SD_dependency_t depbefore,depafter; if (xbt_dynar_length(file->tasks_before) == 0) { xbt_dynar_foreach(file->tasks_after,cpt2,depafter) { @@ -118,7 +120,7 @@ xbt_dynar_t SD_daxload(const char*filename) { WARN2("File %s is produced and consumed by task %s. This loop dependency will prevent the execution of the task.", file->name,depbefore->src->name); } - SD_task_t newfile = SD_task_create_comm_e2e(file->name,NULL,file->amount); + newfile = SD_task_create_comm_e2e(file->name,NULL,file->amount); SD_task_dependency_add(NULL,NULL,depbefore->src,newfile); SD_task_dependency_add(NULL,NULL,newfile,depafter->dst); xbt_dynar_push(result,&newfile); -- 2.20.1