From: Frederic Suter Date: Tue, 14 Feb 2017 12:21:33 +0000 (+0100) Subject: steal a bunch of easy commits and please sonar X-Git-Tag: v3_15~385 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/056d48c9fa3d5fa5afd2be695f54edbc5fd5434d?hp=--cc steal a bunch of easy commits and please sonar --- 056d48c9fa3d5fa5afd2be695f54edbc5fd5434d diff --git a/examples/msg/dht-pastry/dht-pastry.c b/examples/msg/dht-pastry/dht-pastry.c index f60180c02b..d912875ebd 100644 --- a/examples/msg/dht-pastry/dht-pastry.c +++ b/examples/msg/dht-pastry/dht-pastry.c @@ -235,6 +235,7 @@ static void handle_task(node_t node, msg_task_t task) { int min; int max; int d; + int next; msg_task_t task_sent; task_data_t req_data; task_data_t task_data = (task_data_t) MSG_task_get_data(task); @@ -247,8 +248,8 @@ static void handle_task(node_t node, msg_task_t task) { } switch (type) { /* Try to join the ring */ - case TASK_JOIN: { - int next = routing_next(node, task_data->answer_id); + case TASK_JOIN: + next = routing_next(node, task_data->answer_id); XBT_DEBUG("Join request from %08x forwarding to %08x", task_data->answer_id, next); type = TASK_JOIN_LAST_REPLY; @@ -280,11 +281,10 @@ static void handle_task(node_t node, msg_task_t task) { task_free(task_sent); } break; - } /* Join reply from all the node touched by the join */ case TASK_JOIN_LAST_REPLY: // if last node touched reply, copy its namespace set - // TODO: it's work only if the two nodes are side to side (is it really the case ?) + // TODO: it works only if the two nodes are side to side (is it really the case ?) j = (task_data->sender_id < node->id) ? -1 : 0; for (i=0; inamespace_set[i] = task_data->state->namespace_set[i-j]; diff --git a/examples/msg/io-remote/io-remote.c b/examples/msg/io-remote/io-remote.c index 4be05a2f8d..85dc770aa2 100644 --- a/examples/msg/io-remote/io-remote.c +++ b/examples/msg/io-remote/io-remote.c @@ -32,9 +32,8 @@ static int host(int argc, char *argv[]){ sg_size_t write = MSG_file_write(file, MSG_file_get_size(file)*1024); XBT_INFO("Have written %llu bytes to '%s'.",write,filename); - msg_host_t src, dest; - src= MSG_host_self(); - dest = MSG_host_by_name(argv[3]); + msg_host_t src= MSG_host_self(); + msg_host_t dest = MSG_host_by_name(argv[3]); if (xbt_str_parse_int(argv[5], "Argument 5 (move or copy) must be an int, not '%s'")) { XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename,MSG_file_get_size(file), MSG_host_get_name(src), argv[3]); diff --git a/examples/msg/io-storage/io-storage.c b/examples/msg/io-storage/io-storage.c index e63f69a902..4094c93bca 100644 --- a/examples/msg/io-storage/io-storage.c +++ b/examples/msg/io-storage/io-storage.c @@ -39,12 +39,10 @@ static int host(int argc, char *argv[]){ /* - Create a 200,000 bytes file named './tmp/data.txt' on /sd1 */ char* file_name = xbt_strdup("/home/tmp/data.txt"); - msg_file_t file = NULL; - sg_size_t write, read, file_size; /* - Open an non-existing file which amounts to create it. */ - file = MSG_file_open(file_name, NULL); - write = MSG_file_write(file, 200000); // Write 200,000 bytes + msg_file_t file = MSG_file_open(file_name, NULL); + sg_size_t write = MSG_file_write(file, 200000); // Write 200,000 bytes XBT_INFO("Create a %llu bytes file named '%s' on /sd1", write, file_name); MSG_file_dump(file); @@ -53,9 +51,9 @@ static int host(int argc, char *argv[]){ XBT_INFO("Used size: %llu bytes", MSG_storage_get_used_size(storage)); /* - Retrieve the size of created file and read it completely */ - file_size = MSG_file_get_size(file); + sg_size_t file_size = MSG_file_get_size(file); MSG_file_seek(file, 0, SEEK_SET); - read = MSG_file_read(file, file_size); + sg_size_t read = MSG_file_read(file, file_size); XBT_INFO("Read %llu bytes on %s", read, file_name); /* - Then write 100,000 bytes in tmp/data.txt */ @@ -96,7 +94,8 @@ static int host(int argc, char *argv[]){ XBT_INFO("*** Dump content of %s ***",MSG_host_get_name(MSG_host_self())); xbt_dict_t contents = NULL; contents = MSG_host_get_storage_content(MSG_host_self()); // contents is a dict of dicts - xbt_dict_cursor_t curs, curs2 = NULL; + xbt_dict_cursor_t curs; + xbt_dict_cursor_t curs2 = NULL; char* mountname; xbt_dict_t content; char* path; @@ -106,7 +105,7 @@ static int host(int argc, char *argv[]){ xbt_dict_foreach(content,curs2,path,size){ XBT_INFO("%s size: %llu bytes", path,*((sg_size_t*)size)); } - xbt_dict_free(&content); + xbt_dict_free(&content); } xbt_dict_free(&contents); return 1; diff --git a/examples/msg/platform-properties/platform-properties.c b/examples/msg/platform-properties/platform-properties.c index 06db78b6ee..dfc751f0e3 100644 --- a/examples/msg/platform-properties/platform-properties.c +++ b/examples/msg/platform-properties/platform-properties.c @@ -12,7 +12,8 @@ static void test_host(const char*hostname) msg_host_t thehost = MSG_host_by_name(hostname); xbt_dict_t props = MSG_host_get_properties(thehost); xbt_dict_cursor_t cursor = NULL; - char *key, *data; + char *key; + char *data; const char *noexist = "Unknown"; const char *value; char exist[] = "Hdd"; @@ -66,7 +67,8 @@ static int bob(int argc, char *argv[]) /* Get the property list of current bob process */ xbt_dict_t props = MSG_process_get_properties(MSG_process_self()); xbt_dict_cursor_t cursor = NULL; - char *key, *data; + char *key; + char *data; const char *noexist = "UnknownProcessProp"; XBT_ATTRIB_UNUSED const char *value; diff --git a/examples/simdag/goal/goal_test.c b/examples/simdag/goal/goal_test.c index 368f551f5b..a44b6ec05c 100644 --- a/examples/simdag/goal/goal_test.c +++ b/examples/simdag/goal/goal_test.c @@ -18,16 +18,17 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(goal, "The GOAL loader into SimDag"); typedef struct { - int i, j, k; -} s_bcast_task_t,*bcast_task_t; - + int i; + int j; + int k; +} s_bcast_task_t; +typedef s_bcast_task_t *bcast_task_t; const sg_host_t* ws_list; int count = 0; xbt_dynar_t reclaimed; static void send_one(int from, int to) { - //XBT_DEBUG("send_one(%d, %d)",from,to); if (count %100000 == 0) XBT_INFO("Sending task #%d",count); diff --git a/examples/simdag/properties/sd_properties.c b/examples/simdag/properties/sd_properties.c index 827145921e..94186bd93a 100644 --- a/examples/simdag/properties/sd_properties.c +++ b/examples/simdag/properties/sd_properties.c @@ -11,7 +11,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Property test"); int main(int argc, char **argv) { xbt_dict_cursor_t cursor = NULL; - char *key, *data; + char *key; + char *data; char noexist[] = "NoProp"; const char *value; char exist[] = "Hdd"; diff --git a/examples/simdag/scheduling/sd_scheduling.c b/examples/simdag/scheduling/sd_scheduling.c index a95be21c20..726c701d33 100644 --- a/examples/simdag/scheduling/sd_scheduling.c +++ b/examples/simdag/scheduling/sd_scheduling.c @@ -134,7 +134,8 @@ int main(int argc, char **argv) { unsigned int cursor; double min_finish_time = -1.0; - SD_task_t task, selected_task = NULL; + SD_task_t task; + SD_task_t selected_task = NULL; xbt_dynar_t ready_tasks; sg_host_t selected_host = NULL; char * tracefilename = NULL; diff --git a/examples/smpi/energy/energy.c b/examples/smpi/energy/energy.c index be95ba91ad..26b50863b5 100644 --- a/examples/smpi/energy/energy.c +++ b/examples/smpi/energy/energy.c @@ -11,14 +11,11 @@ int main(int argc, char *argv[]) { - int rank, pstates; + int rank; int i; char buf[1024]; - char *s; - size_t sz, x; - int err; - err = MPI_Init(&argc, &argv); + int err = MPI_Init(&argc, &argv); if (err != MPI_SUCCESS) { fprintf(stderr, "MPI_init failed: %d\n", err); exit(EXIT_FAILURE); @@ -31,11 +28,11 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - pstates = smpi_get_host_nb_pstates(); + int pstates = smpi_get_host_nb_pstates(); - s = buf; - sz = sizeof buf; - x = snprintf(s, sz, + char *s = buf; + size_t sz = sizeof buf; + size_t x = snprintf(s, sz, "[%.6f] [rank %d] Pstates: %d; Powers: %.0f", MPI_Wtime(), rank, pstates, smpi_get_host_power_peak_at(0)); if (x < sz) { diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index e691b00a04..00718591d7 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -394,14 +394,12 @@ L07Action::~L07Action(){ void L07Action::updateBound() { double lat_current = 0.0; - double lat_bound = -1.0; - int i, j; int hostNb = hostList_->size(); if (communicationAmount_ != nullptr) { - for (i = 0; i < hostNb; i++) { - for (j = 0; j < hostNb; j++) { + for (int i = 0; i < hostNb; i++) { + for (int j = 0; j < hostNb; j++) { if (communicationAmount_[i * hostNb + j] > 0) { double lat = 0.0; @@ -413,7 +411,7 @@ void L07Action::updateBound() } } } - lat_bound = sg_tcp_gamma / (2.0 * lat_current); + double lat_bound = sg_tcp_gamma / (2.0 * lat_current); XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound); if ((latency_ == 0.0) && (suspended_ == 0)) { if (rate_ < 0) diff --git a/src/xbt/fifo.c b/src/xbt/fifo.c index fc747c3e70..55a6ab02fd 100644 --- a/src/xbt/fifo.c +++ b/src/xbt/fifo.c @@ -23,8 +23,7 @@ static xbt_mallocator_t item_mallocator = NULL; */ xbt_fifo_t xbt_fifo_new(void) { - xbt_fifo_t fifo; - fifo = xbt_new0(struct xbt_fifo, 1); + xbt_fifo_t fifo = xbt_new0(struct xbt_fifo, 1); return fifo; } @@ -68,9 +67,7 @@ void xbt_fifo_reset(xbt_fifo_t l) */ xbt_fifo_item_t xbt_fifo_push(xbt_fifo_t l, void *t) { - xbt_fifo_item_t new; - - new = xbt_fifo_new_item(); + xbt_fifo_item_t new = xbt_fifo_new_item(); new->content = t; xbt_fifo_push_item(l, new); @@ -86,15 +83,13 @@ xbt_fifo_item_t xbt_fifo_push(xbt_fifo_t l, void *t) */ void *xbt_fifo_pop(xbt_fifo_t l) { - void *content; - if (l == NULL) return NULL; xbt_fifo_item_t item = xbt_fifo_pop_item(l); if (!item) return NULL; - content = item->content; + void *content = item->content; xbt_fifo_free_item(item); return content; } @@ -108,9 +103,7 @@ void *xbt_fifo_pop(xbt_fifo_t l) */ xbt_fifo_item_t xbt_fifo_unshift(xbt_fifo_t l, void *t) { - xbt_fifo_item_t new; - - new = xbt_fifo_new_item(); + xbt_fifo_item_t new = xbt_fifo_new_item(); new->content = t; xbt_fifo_unshift_item(l, new); return new; @@ -125,15 +118,13 @@ xbt_fifo_item_t xbt_fifo_unshift(xbt_fifo_t l, void *t) */ void *xbt_fifo_shift(xbt_fifo_t l) { - void *content; - if (l == NULL) return NULL; xbt_fifo_item_t item = xbt_fifo_shift_item(l); if (!item) return NULL; - content = item->content; + void *content = item->content; xbt_fifo_free_item(item); return content; } @@ -166,12 +157,10 @@ void xbt_fifo_push_item(xbt_fifo_t l, xbt_fifo_item_t new) */ xbt_fifo_item_t xbt_fifo_pop_item(xbt_fifo_t l) { - xbt_fifo_item_t item; - if (l->tail == NULL) return NULL; - item = l->tail; + xbt_fifo_item_t item = l->tail; l->tail = item->prev; if (l->tail == NULL) @@ -214,12 +203,10 @@ void xbt_fifo_unshift_item(xbt_fifo_t l, xbt_fifo_item_t new) */ xbt_fifo_item_t xbt_fifo_shift_item(xbt_fifo_t l) { - xbt_fifo_item_t item; - if (l->head == NULL) return NULL; - item = l->head; + xbt_fifo_item_t item = l->head; l->head = item->next; if (l->head == NULL) @@ -244,7 +231,8 @@ xbt_fifo_item_t xbt_fifo_shift_item(xbt_fifo_t l) */ int xbt_fifo_remove(xbt_fifo_t l, void *t) { - xbt_fifo_item_t current, current_next; + xbt_fifo_item_t current; + xbt_fifo_item_t current_next; for (current = l->head; current; current = current_next) { current_next = current->next; @@ -268,7 +256,8 @@ int xbt_fifo_remove(xbt_fifo_t l, void *t) */ int xbt_fifo_remove_all(xbt_fifo_t l, void *t) { - xbt_fifo_item_t current, current_next; + xbt_fifo_item_t current; + xbt_fifo_item_t current_next; int res = 0; for (current = l->head; current; current = current_next) { @@ -393,11 +382,9 @@ void **xbt_fifo_to_array(xbt_fifo_t f) */ xbt_fifo_t xbt_fifo_copy(xbt_fifo_t f) { - xbt_fifo_t copy = NULL; + xbt_fifo_t copy = xbt_fifo_new(); xbt_fifo_item_t b; - copy = xbt_fifo_new(); - for (b = xbt_fifo_get_first_item(f); b; b = b->next) { xbt_fifo_push(copy, b->content); } diff --git a/src/xbt/graph.c b/src/xbt/graph.c index 56cf62e194..35f3d4b82c 100644 --- a/src/xbt/graph.c +++ b/src/xbt/graph.c @@ -25,8 +25,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_graph, xbt, "Graph"); */ xbt_graph_t xbt_graph_new_graph(unsigned short int directed, void *data) { - xbt_graph_t graph = NULL; - graph = xbt_new0(struct xbt_graph, 1); + xbt_graph_t graph = xbt_new0(struct xbt_graph, 1); graph->directed = directed; graph->data = data; graph->nodes = xbt_dynar_new(sizeof(xbt_node_t), NULL); @@ -38,8 +37,7 @@ xbt_graph_t xbt_graph_new_graph(unsigned short int directed, void *data) /** @brief add a node to the given graph */ xbt_node_t xbt_graph_new_node(xbt_graph_t g, void *data) { - xbt_node_t node = NULL; - node = xbt_new0(struct xbt_node, 1); + xbt_node_t node= xbt_new0(struct xbt_node, 1); node->data = data; if (g->directed) /* only the "out" field is used */ @@ -57,9 +55,7 @@ xbt_node_t xbt_graph_new_node(xbt_graph_t g, void *data) /** @brief add an edge to the given graph */ xbt_edge_t xbt_graph_new_edge(xbt_graph_t g, xbt_node_t src, xbt_node_t dst, void *data) { - xbt_edge_t edge = NULL; - - edge = xbt_new0(struct xbt_edge, 1); + xbt_edge_t edge = xbt_new0(struct xbt_edge, 1); xbt_dynar_push(src->out, &edge); if (g->directed) xbt_dynar_push(dst->in, &edge); @@ -211,9 +207,10 @@ double xbt_graph_edge_get_length(xbt_edge_t edge) */ void xbt_floyd_algorithm(xbt_graph_t g, double *adj, double *d, xbt_node_t * p) { - unsigned long i, j, k; - unsigned long n; - n = xbt_dynar_length(g->nodes); + unsigned long i; + unsigned long j; + unsigned long k; + unsigned long n = xbt_dynar_length(g->nodes); # define D(u,v) d[(u)*n+(v)] # define P(u,v) p[(u)*n+(v)] @@ -253,10 +250,9 @@ void xbt_graph_export_graphviz(xbt_graph_t g, const char *filename, const char * unsigned int cursor = 0; xbt_node_t node = NULL; xbt_edge_t edge = NULL; - FILE *file = NULL; const char *name = NULL; - file = fopen(filename, "w"); + FILE *file = fopen(filename, "w"); xbt_assert(file, "Failed to open %s \n", filename); if (g->directed) @@ -285,10 +281,9 @@ void xbt_graph_export_graphviz(xbt_graph_t g, const char *filename, const char * }else{ c = c_ndir; } - const char *src_name, *dst_name; if (node_name){ - src_name = node_name(edge->src); - dst_name = node_name(edge->dst); + const char *src_name = node_name(edge->src); + const char *dst_name = node_name(edge->dst); fprintf(file, " \"%s\" %s \"%s\"", src_name, c, dst_name); }else{ fprintf(file, " \"%p\" %s \"%p\"", edge->src, c, edge->dst); diff --git a/src/xbt/log.c b/src/xbt/log.c index 67c19a8a78..2d694dbcd0 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -277,7 +277,8 @@ static void xbt_log_help_categories(void); void xbt_log_init(int *argc, char **argv) { unsigned help_requested = 0; /* 1: logs; 2: categories */ - int i, j; + int i; + int j; char *opt; /* uncomment to set the LOG category to debug directly */ @@ -366,11 +367,10 @@ void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...) /* First, try with a static buffer */ if (XBT_LOG_STATIC_BUFFER_SIZE) { char buff[XBT_LOG_STATIC_BUFFER_SIZE]; - int done; ev->buffer = buff; ev->buffer_size = sizeof buff; va_start(ev->ap, fmt); - done = cat->layout->do_layout(cat->layout, ev, fmt); + int done = cat->layout->do_layout(cat->layout, ev, fmt); va_end(ev->ap); if (done) { appender->do_append(appender, buff); @@ -382,9 +382,8 @@ void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...) ev->buffer_size = XBT_LOG_DYNAMIC_BUFFER_SIZE; ev->buffer = xbt_malloc(ev->buffer_size); while (1) { - int done; va_start(ev->ap, fmt); - done = cat->layout->do_layout(cat->layout, ev, fmt); + int done = cat->layout->do_layout(cat->layout, ev, fmt); va_end(ev->ap); if (done) break; /* Got it */ @@ -588,7 +587,6 @@ static xbt_log_setting_t _xbt_log_parse_setting(const char *control_string) { const char *orig_control_string = control_string; xbt_log_setting_t set = xbt_new(s_xbt_log_setting_t, 1); - const char *name, *dot, *eq; set->catname = NULL; set->thresh = xbt_log_priority_uninitialized; @@ -601,11 +599,11 @@ static xbt_log_setting_t _xbt_log_parse_setting(const char *control_string) XBT_DEBUG("Parse log setting '%s'", control_string); control_string += strspn(control_string, " "); - name = control_string; + const char *name = control_string; control_string += strcspn(control_string, ".= "); - dot = control_string; + const char *dot = control_string; control_string += strcspn(control_string, ":= "); - eq = control_string; + const char *eq = control_string; if(*dot != '.' && (*eq == '=' || *eq == ':')) xbt_die ("Invalid control string '%s'", orig_control_string); @@ -666,9 +664,9 @@ static xbt_log_setting_t _xbt_log_parse_setting(const char *control_string) if (!strncmp(neweq, "file:", 5)) { set->appender = xbt_log_appender_file_new(neweq + 5); }else if (!strncmp(neweq, "rollfile:", 9)) { - set->appender = xbt_log_appender2_file_new(neweq + 9,1); + set->appender = xbt_log_appender2_file_new(neweq + 9,1); }else if (!strncmp(neweq, "splitfile:", 10)) { - set->appender = xbt_log_appender2_file_new(neweq + 10,0); + set->appender = xbt_log_appender2_file_new(neweq + 10,0); } else { THROWF(arg_error, 0, "Unknown appender log type: '%s'", neweq); } @@ -691,7 +689,8 @@ static xbt_log_setting_t _xbt_log_parse_setting(const char *control_string) static xbt_log_category_t _xbt_log_cat_searchsub(xbt_log_category_t cat, char *name) { - xbt_log_category_t child, res; + xbt_log_category_t child; + xbt_log_category_t res; XBT_DEBUG("Search '%s' into '%s' (firstChild='%s'; nextSibling='%s')", name, cat->name, (cat->firstChild ? cat->firstChild->name : "none"), @@ -874,7 +873,6 @@ static void xbt_log_help_categories_rec(xbt_log_category_t category, const char { char *this_prefix; char *child_prefix; - xbt_dynar_t dynar; unsigned i; xbt_log_category_t cat; @@ -889,7 +887,7 @@ static void xbt_log_help_categories_rec(xbt_log_category_t category, const char child_prefix = xbt_strdup(prefix); } - dynar = xbt_dynar_new(sizeof(xbt_log_category_t), NULL); + xbt_dynar_t dynar = xbt_dynar_new(sizeof(xbt_log_category_t), NULL); for (cat = category ; cat != NULL; cat = cat->nextSibling) xbt_dynar_push_as(dynar, xbt_log_category_t, cat); diff --git a/src/xbt/xbt_log_layout_format.c b/src/xbt/xbt_log_layout_format.c index 4dca16363e..1de4e72e6e 100644 --- a/src/xbt/xbt_log_layout_format.c +++ b/src/xbt/xbt_log_layout_format.c @@ -50,7 +50,8 @@ static double format_begin_of_time = -1; #define show_it(data, letter) \ if (1) { \ - int len, wd; \ + int len; \ + int wd; \ if (length == -1) { \ wd = 0; \ } else { \ @@ -80,9 +81,8 @@ static int xbt_log_layout_format_doit(xbt_log_layout_t l, xbt_log_event_t ev, co int rem_size = ev->buffer_size; int precision = -1; int length = -1; - char *q; - for (q = l->data ; *q != '\0' ; q++) { + for (char* q = l->data ; *q != '\0' ; q++) { if (*q == '%') { q++; handle_modifier: @@ -140,9 +140,9 @@ static int xbt_log_layout_format_doit(xbt_log_layout_t l, xbt_log_event_t ev, co show_string(ev->fileName); break; case 'l': { /* location; LOG4J compliant */ - int len, sz; + int sz; set_sz_from_precision(); - len = snprintf(p, sz, "%s:%d", ev->fileName, ev->lineNum); + int len = snprintf(p, sz, "%s:%d", ev->fileName, ev->lineNum); check_overflow(MIN(sz, len)); break; } @@ -187,9 +187,9 @@ static int xbt_log_layout_format_doit(xbt_log_layout_t l, xbt_log_event_t ev, co show_double(surf_get_clock() - format_begin_of_time); break; case 'm': { /* user-provided message; LOG4J compliant */ - int len, sz; + int sz; set_sz_from_precision(); - len = vsnprintf(p, sz, msg_fmt, ev->ap); + int len = vsnprintf(p, sz, msg_fmt, ev->ap); check_overflow(MIN(sz, len)); break; } diff --git a/src/xbt/xbt_strbuff.c b/src/xbt/xbt_strbuff.c index 9aead1ac34..4369aca483 100644 --- a/src/xbt/xbt_strbuff.c +++ b/src/xbt/xbt_strbuff.c @@ -38,7 +38,8 @@ inline xbt_strbuff_t xbt_strbuff_new_from(const char *ctn) { xbt_strbuff_t res = xbt_malloc(sizeof(s_xbt_strbuff_t)); res->data = xbt_strdup(ctn); - res->used = res->size = strlen(ctn); + res->size = strlen(ctn); + res->used = res->size; return res; } @@ -103,7 +104,8 @@ void xbt_strbuff_printf(xbt_strbuff_t b, const char *fmt, ...) void xbt_strbuff_varsubst(xbt_strbuff_t b, xbt_dict_t patterns) { char *end; /* pointers around the parsed chunk */ - int in_simple_quote = 0, in_double_quote = 0; + int in_simple_quote = 0; + int in_double_quote = 0; int done = 0; if (b->data[0] == '\0') @@ -132,11 +134,13 @@ void xbt_strbuff_varsubst(xbt_strbuff_t b, xbt_dict_t patterns) case '$': if (!in_simple_quote) { /* Go for the substitution. First search the variable name */ - char *beg_var, *end_var; /* variable name boundary */ - char *beg_subst, *end_subst = NULL; /* where value should be written to */ - char *value, *default_value = NULL; + char *beg_var; + char *end_var; /* variable name boundary */ + char *beg_subst = end; + char *end_subst = NULL; /* where value should be written to */ + char *value; + char *default_value = NULL; int val_len; - beg_subst = end; if (*(++end) == '{') { /* the variable name is enclosed in braces. */ diff --git a/teshsuite/msg/storage_client_server/storage_client_server.c b/teshsuite/msg/storage_client_server/storage_client_server.c index 7c7bea7741..901bc027b9 100644 --- a/teshsuite/msg/storage_client_server/storage_client_server.c +++ b/teshsuite/msg/storage_client_server/storage_client_server.c @@ -10,7 +10,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation"); static void display_storage_properties(msg_storage_t storage){ xbt_dict_cursor_t cursor = NULL; - char *key, *data; + char *key; + char *data; xbt_dict_t props = MSG_storage_get_properties(storage); if (xbt_dict_length(props) > 0){ XBT_INFO("\tProperties of mounted storage: %s", MSG_storage_get_name(storage)); @@ -23,9 +24,8 @@ static void display_storage_properties(msg_storage_t storage){ static sg_size_t write_local_file(const char *dest, sg_size_t file_size) { - sg_size_t written; msg_file_t file = MSG_file_open(dest, NULL); - written = MSG_file_write(file, file_size); + sg_size_t written = MSG_file_write(file, file_size); XBT_INFO("%llu bytes on %llu bytes have been written by %s on /sd1",written, file_size, MSG_host_get_name(MSG_host_self())); MSG_file_close(file); @@ -34,11 +34,10 @@ static sg_size_t write_local_file(const char *dest, sg_size_t file_size) static sg_size_t read_local_file(const char *src) { - sg_size_t read, file_size; msg_file_t file = MSG_file_open(src, NULL); - file_size = MSG_file_get_size(file); + sg_size_t file_size = MSG_file_get_size(file); - read = MSG_file_read(file, file_size); + sg_size_t read = MSG_file_read(file, file_size); XBT_INFO("%s has read %llu on %s",MSG_host_get_name(MSG_host_self()),read,src); MSG_file_close(file); diff --git a/teshsuite/simdag/evaluate-get-route-time/evaluate-get-route-time.c b/teshsuite/simdag/evaluate-get-route-time/evaluate-get-route-time.c index ea122f3869..c8bf42ad1f 100644 --- a/teshsuite/simdag/evaluate-get-route-time/evaluate-get-route-time.c +++ b/teshsuite/simdag/evaluate-get-route-time/evaluate-get-route-time.c @@ -15,7 +15,8 @@ int main(int argc, char **argv) { - int i, j; + int i; + int j; xbt_os_timer_t timer = xbt_os_timer_new(); SD_init(&argc, argv);