Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Replace redundant type with "auto" (src/smpi/).
[simgrid.git] / src / smpi / internals / smpi_shared.cpp
index b2653ab..c984b99 100644 (file)
@@ -239,7 +239,7 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
     size_t stop_block_offset = ALIGN_DOWN(stop_offset, smpi_shared_malloc_blocksize);
     for (size_t offset = start_block_offset; offset < stop_block_offset; offset += smpi_shared_malloc_blocksize) {
       XBT_DEBUG("\t\tglobal shared allocation, mmap block offset %zx", offset);
-      void* pos = (void*)((unsigned long)mem + offset);
+      void* pos       = static_cast<char*>(mem) + offset;
       const void* res = mmap(pos, smpi_shared_malloc_blocksize, PROT_READ | PROT_WRITE, mmap_flag, huge_fd, 0);
       xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
                              "size of the mapped file using --cfg=smpi/shared-malloc-blocksize:newvalue (default 1048576) ? "
@@ -252,7 +252,7 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
     size_t low_page_stop_offset = (int64_t)start_block_offset < ALIGN_DOWN(stop_offset, PAGE_SIZE) ? start_block_offset : ALIGN_DOWN(stop_offset, PAGE_SIZE);
     if(low_page_start_offset < low_page_stop_offset) {
       XBT_DEBUG("\t\tglobal shared allocation, mmap block start");
-      void* pos = (void*)((unsigned long)mem + low_page_start_offset);
+      void* pos       = static_cast<char*>(mem) + low_page_start_offset;
       const void* res = mmap(pos, low_page_stop_offset - low_page_start_offset, PROT_READ | PROT_WRITE,
                              mmap_base_flag, // not a full huge page
                              smpi_shared_malloc_bogusfile, 0);
@@ -265,7 +265,7 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
       XBT_DEBUG("\t\tglobal shared allocation, mmap block stop");
       size_t high_page_stop_offset = stop_offset == size ? size : ALIGN_DOWN(stop_offset, PAGE_SIZE);
       if(high_page_stop_offset > stop_block_offset) {
-        void* pos = (void*)((unsigned long)mem + stop_block_offset);
+        void* pos       = static_cast<char*>(mem) + stop_block_offset;
         const void* res = mmap(pos, high_page_stop_offset - stop_block_offset, PROT_READ | PROT_WRITE,
                                mmap_base_flag, // not a full huge page
                                smpi_shared_malloc_bogusfile, 0);
@@ -279,7 +279,7 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
 
   shared_metadata_t newmeta;
   //register metadata for memcpy avoidance
-  shared_data_key_type* data = new shared_data_key_type;
+  auto* data             = new shared_data_key_type;
   data->second.fd = -1;
   data->second.count = 1;
   newmeta.size = size;