Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplify loop.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 21 Nov 2017 09:34:32 +0000 (10:34 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 21 Nov 2017 09:34:32 +0000 (10:34 +0100)
src/smpi/internals/smpi_shared.cpp

index 8ed34e8..ce65e1b 100644 (file)
@@ -271,9 +271,9 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
               "stop_offset (%zu) should be lower than its successor start offset (%zu)", stop_offset, shared_block_offsets[2*i_block+2]);
     size_t start_block_offset = ALIGN_UP(start_offset, smpi_shared_malloc_blocksize);
     size_t stop_block_offset = ALIGN_DOWN(stop_offset, smpi_shared_malloc_blocksize);
-    for (unsigned block_id=0, i = start_block_offset / smpi_shared_malloc_blocksize; i < stop_block_offset / smpi_shared_malloc_blocksize; block_id++, i++) {
-      XBT_DEBUG("\t\tglobal shared allocation, mmap block offset %u", block_id);
-      void* pos = (void*)((unsigned long)mem + i * 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* 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 "