Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use more std::string.
[simgrid.git] / src / mc / remote / RemoteSimulation.cpp
index ceb818df3c3f338c3a149ad70a54074aa27c1a16..ff36950e1de09e5e2166f6886eaa7148a3f86d86 100644 (file)
@@ -17,6 +17,7 @@
 #include <sys/mman.h> // PROT_*
 
 #include <memory>
+#include <string>
 
 using simgrid::mc::remote;
 
@@ -214,14 +215,8 @@ static void zero_buffer_init()
 
 int open_vm(pid_t pid, int flags)
 {
-  const size_t buffer_size = 30;
-  char buffer[buffer_size];
-  int res = snprintf(buffer, buffer_size, "/proc/%lli/mem", (long long)pid);
-  if (res < 0 || (size_t)res >= buffer_size) {
-    errno = ENAMETOOLONG;
-    return -1;
-  }
-  return open(buffer, flags);
+  std::string buffer = "/proc/" + std::to_string(pid) + "/mem";
+  return open(buffer.c_str(), flags);
 }
 
 // ***** RemoteSimulation