#include "simgrid/jedule/jedule_output.h"
-#ifdef HAVE_JEDULE
+#if HAVE_JEDULE
+
+#define STR_BUF_SIZE 1024
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jed_out, jedule, "Logging specific to Jedule output");
}
}
-static void get_hierarchy_string(jed_simgrid_container_t container, char *outbuf) {
- char buf[1024];
+static void get_hierarchy_string(jed_simgrid_container_t container, char *outbuf, int bufsize) {
+ char buf[STR_BUF_SIZE];
xbt_dynar_t hier_list;
unsigned int iter;
int number;
xbt_dynar_foreach(hier_list, iter, number) {
if( iter != length-1 ) {
- sprintf(buf, "%d.", number);
+ snprintf(buf, STR_BUF_SIZE, "%d.", number);
} else {
- sprintf(buf, "%d", number);
+ snprintf(buf, STR_BUF_SIZE, "%d", number);
}
- strcat(outbuf, buf);
+ strncat(outbuf, buf, bufsize-strlen(outbuf));
}
xbt_dynar_free(&hier_list);
}
}
-static void print_container(jed_simgrid_container_t container) {
- unsigned int i;
- jed_simgrid_container_t child_container;
-
- xbt_assert( container != NULL );
-
- fprintf(jed_file, " <res name=\"%s\">\n", container->name);
- if( container->container_children != NULL ) {
- xbt_dynar_foreach(container->container_children, i, child_container) {
- print_container(child_container);
- }
- } else {
- print_resources(container);
- }
- fprintf(jed_file, " </res>\n");
-}
-
static void print_resources(jed_simgrid_container_t resource_parent) {
unsigned int res_nb;
unsigned int i;
char *res_name;
- char resid[1024];
+ char resid[STR_BUF_SIZE];
xbt_assert( resource_parent->resource_list != NULL );
res_nb = xbt_dynar_length(resource_parent->resource_list);
- get_hierarchy_string(resource_parent, resid);
+ get_hierarchy_string(resource_parent, resid, STR_BUF_SIZE);
fprintf(jed_file, " <rset id=\"%s\" nb=\"%d\" names=\"", resid, res_nb);
xbt_dynar_foreach(resource_parent->resource_list, i, res_name) {
fprintf(jed_file, "\" />\n");
}
+static void print_container(jed_simgrid_container_t container) {
+ unsigned int i;
+ jed_simgrid_container_t child_container;
+
+ xbt_assert( container != NULL );
+
+ fprintf(jed_file, " <res name=\"%s\">\n", container->name);
+ if( container->container_children != NULL ) {
+ xbt_dynar_foreach(container->container_children, i, child_container) {
+ print_container(child_container);
+ }
+ } else {
+ print_resources(container);
+ }
+ fprintf(jed_file, " </res>\n");
+}
+
static void print_platform(jed_simgrid_container_t root_container) {
fprintf(jed_file, " <platform>\n");
print_container(root_container);
xbt_dynar_foreach(event->resource_subsets, i, subset) {
int start = subset->start_idx;
int end = subset->start_idx + subset->nres - 1;
- char resid[1024];
+ char resid[STR_BUF_SIZE];
- get_hierarchy_string(subset->parent, resid);
+ get_hierarchy_string(subset->parent, resid, STR_BUF_SIZE);
fprintf(jed_file, " <select resources=\"");
fprintf(jed_file, "%s", resid);
fprintf(jed_file, ".[%d-%d]", start, end);