Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[SMPI] Use std::string::compare instead of strncmp
[simgrid.git] / src / smpi / internals / smpi_memory.cpp
index a3d9b14..4fce186 100644 (file)
@@ -108,7 +108,8 @@ void smpi_really_switch_data_segment(int dest)
 
 int smpi_is_privatization_file(char* file)
 {
-  return strncmp("/dev/shm/my-buffer-", file, std::strlen("/dev/shm/my-buffer-")) == 0;
+  const std::string buffer_path {"/dev/shm/my-buffer-"};
+  return buffer_path.compare(file) == 0;
 }
 
 void smpi_initialize_global_memory_segments()
@@ -135,7 +136,7 @@ void smpi_initialize_global_memory_segments()
     int status;
 
     do {
-      snprintf(path, sizeof(path), "/smpi-buffer-%06x", rand() % 0xffffff);
+      snprintf(path, sizeof(path), "/smpi-buffer-%06x", rand() % 0xffffffU);
       file_descriptor = shm_open(path, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
     } while (file_descriptor == -1 && errno == EEXIST);
     if (file_descriptor < 0) {