RPS data extraction: Format written files
authorJulius Bünger <buenger@mytum.de>
Mon, 8 Apr 2019 14:03:42 +0000 (16:03 +0200)
committerJulius Bünger <buenger@mytum.de>
Mon, 8 Apr 2019 14:03:42 +0000 (16:03 +0200)
src/rps/gnunet-rps-profiler.c
src/rps/rps-test_util.h

index ffc9d6f7eff69ce306ae2cdb69605a2353ab506c..a13ee40781e8d91e2b70d32c596f2fb7f1cdc376 100644 (file)
@@ -2222,7 +2222,7 @@ static void compute_probabilities (uint32_t peer_idx)
 {
   //double probs[num_peers] = { 0 };
   double probs[num_peers];
-  size_t probs_as_str_size = (num_peers * 10 + 1) * sizeof (char);
+  size_t probs_as_str_size = (num_peers * 10 + 2) * sizeof (char);
   char *probs_as_str = GNUNET_malloc (probs_as_str_size);
   char *probs_as_str_cpy;
   uint32_t i;
index 6b5f568d7edc9f519c179f64f573551c1fa18a4b..3094b9bead3f676e5286c0b9cdf9b701138e4421 100644 (file)
@@ -68,12 +68,21 @@ close_all_files ();
     if (NULL == file_name) break; \
     size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\
     if (0 > size)\
+    {\
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\
            "Failed to create tmp_buf\n");\
-    else\
-      GNUNET_DISK_file_write (get_file_handle (file_name),\
-                              tmp_buf,\
-                              strnlen (tmp_buf, 512));\
+      break;\
+    }\
+    size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),"%s \n", tmp_buf);\
+    if (0 > size)\
+    {\
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\
+           "Failed to create tmp_buf\n");\
+      break;\
+    }\
+    GNUNET_DISK_file_write (get_file_handle (file_name),\
+                            tmp_buf,\
+                            strnlen (tmp_buf, 512));\
   } while (0);
 
 
@@ -82,12 +91,21 @@ close_all_files ();
     memset (tmp_buf, 0, len);\
     size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\
     if (0 > size)\
+    {\
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\
+           "Failed to create tmp_buf\n");\
+      break;\
+    }\
+    size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),"%s\n", tmp_buf);\
+    if (0 > size)\
+    {\
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\
            "Failed to create tmp_buf\n");\
-    else\
-      GNUNET_DISK_file_write (get_file_handle (file_name),\
-                              tmp_buf,\
-                              strnlen (tmp_buf, 512));\
+      break;\
+    }\
+    GNUNET_DISK_file_write (get_file_handle (file_name),\
+                            tmp_buf,\
+                            strnlen (tmp_buf, len));\
   } while (0);
 #else /* TO_FILE */
 #  define to_file(file_name, ...)