Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Check return value of (v)asprintf.
authoragiersch <agiersch@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 22 Oct 2010 09:29:15 +0000 (09:29 +0000)
committeragiersch <agiersch@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 22 Oct 2010 09:29:15 +0000 (09:29 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8444 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/amok/bandwidth/bandwidth.c
examples/gras/p2p/chord/chord.c
src/gras/DataDesc/ddt_create.c
src/simix/smx_global.c
src/xbt/xbt_log_layout_simple.c

index e5d5de9..28de73d 100644 (file)
@@ -92,11 +92,10 @@ int maestro(int argc, char *argv[])
   gras_msg_handleall(5);        /* friends, we're ready. Come and play */
 
   if (xbt_dynar_length(group) < 2) {
   gras_msg_handleall(5);        /* friends, we're ready. Come and play */
 
   if (xbt_dynar_length(group) < 2) {
-    char *msg;
-    asprintf(&msg, "Not enough peers arrived. Expected 2 got %ld",
-             xbt_dynar_length(group));
+    CRITICAL1("Not enough peers arrived. Expected 2 got %ld",
+              xbt_dynar_length(group));
     amok_pm_group_shutdown("bandwidth");
     amok_pm_group_shutdown("bandwidth");
-    xbt_die(msg);
+    xbt_abort();
   }
   h1 = *(xbt_peer_t *) xbt_dynar_get_ptr(group, 0);
   h2 = *(xbt_peer_t *) xbt_dynar_get_ptr(group, 1);
   }
   h1 = *(xbt_peer_t *) xbt_dynar_get_ptr(group, 0);
   h2 = *(xbt_peer_t *) xbt_dynar_get_ptr(group, 1);
index debf98f..f70b5ce 100644 (file)
@@ -312,7 +312,7 @@ int node(int argc, char **argv)
   if (argc == 3) {
     create = 1;
   } else {
   if (argc == 3) {
     create = 1;
   } else {
-    asprintf(&other_host, "%s", argv[3]);
+    other_host = xbt_strdup(argv[3]);
     other_port = atoi(argv[4]);
   }
 
     other_port = atoi(argv[4]);
   }
 
index 77c19a5..4c8e3e2 100644 (file)
@@ -694,7 +694,8 @@ gras_datadesc_dynar(gras_datadesc_type_t elm_t, void_f_pvoid_t free_func)
   char *buffname;
   gras_datadesc_type_t res;
 
   char *buffname;
   gras_datadesc_type_t res;
 
-  asprintf(&buffname, "s_xbt_dynar_of_%s", elm_t->name);
+  if (asprintf(&buffname, "s_xbt_dynar_of_%s", elm_t->name) == -1)
+    xbt_die("asprintf failed");
 
   res = gras_datadesc_struct(buffname);
 
 
   res = gras_datadesc_struct(buffname);
 
@@ -724,7 +725,8 @@ gras_datadesc_dynar(gras_datadesc_type_t elm_t, void_f_pvoid_t free_func)
 
   /* build a ref to it */
   free(buffname);
 
   /* build a ref to it */
   free(buffname);
-  asprintf(&buffname, "xbt_dynar_of_%s", elm_t->name);
+  if (asprintf(&buffname, "xbt_dynar_of_%s", elm_t->name) == -1)
+    xbt_die("asprintf failed");
   res = gras_datadesc_ref(buffname, res);
   free(buffname);
   return res;
   res = gras_datadesc_ref(buffname, res);
   free(buffname);
   return res;
@@ -758,7 +760,8 @@ gras_datadesc_matrix(gras_datadesc_type_t elm_t,
   char *buffname;
   gras_datadesc_type_t res;
 
   char *buffname;
   gras_datadesc_type_t res;
 
-  asprintf(&buffname, "s_xbt_matrix_t(%s)", elm_t->name);
+  if (asprintf(&buffname, "s_xbt_matrix_t(%s)", elm_t->name) == -1)
+    xbt_die("asprintf failed");
   res = gras_datadesc_struct(buffname);
 
   gras_datadesc_struct_append(res, "lines",
   res = gras_datadesc_struct(buffname);
 
   gras_datadesc_struct_append(res, "lines",
@@ -783,7 +786,8 @@ gras_datadesc_matrix(gras_datadesc_type_t elm_t,
 
   /* build a ref to it */
   free(buffname);
 
   /* build a ref to it */
   free(buffname);
-  asprintf(&buffname, "xbt_matrix_t(%s)", elm_t->name);
+  if (asprintf(&buffname, "xbt_matrix_t(%s)", elm_t->name) == -1)
+    xbt_die("asprintf failed");
   res = gras_datadesc_ref(buffname, res);
   free(buffname);
   return res;
   res = gras_datadesc_ref(buffname, res);
   free(buffname);
   return res;
index a920360..9be6131 100644 (file)
@@ -104,11 +104,12 @@ void SIMIX_display_process_status(void)
   xbt_swag_foreach(process, simix_global->process_list) {
     char *who, *who2;
 
   xbt_swag_foreach(process, simix_global->process_list) {
     char *who, *who2;
 
-    asprintf(&who, "%s on %s: %s",
-             process->name,
-             process->smx_host->name,
-             (process->blocked) ? "[BLOCKED] "
-             : ((process->suspended) ? "[SUSPENDED] " : ""));
+    if (asprintf(&who, "%s on %s: %s",
+                 process->name,
+                 process->smx_host->name,
+                 (process->blocked) ? "[BLOCKED] "
+                 : ((process->suspended) ? "[SUSPENDED] " : "")) == -1)
+      xbt_die("asprintf failed");
 
     if (process->mutex) {
       who2 =
 
     if (process->mutex) {
       who2 =
index 030a17b..ddb77e9 100644 (file)
@@ -46,7 +46,8 @@ static void xbt_log_layout_simple_dynamic(xbt_log_layout_t l,
 
   xbt_strbuff_append(buff, loc_buff);
 
 
   xbt_strbuff_append(buff, loc_buff);
 
-  vasprintf(&p, fmt, ev->ap_copy);
+  if (vasprintf(&p, fmt, ev->ap_copy) == -1)
+    xbt_die("vasprintf failed");
   xbt_strbuff_append(buff, p);
   free(p);
 
   xbt_strbuff_append(buff, p);
   free(p);