mmap: set 'fd' to -1
authorJens Axboe <axboe@fb.com>
Thu, 30 Oct 2014 14:40:47 +0000 (08:40 -0600)
committerJens Axboe <axboe@fb.com>
Thu, 30 Oct 2014 14:40:47 +0000 (08:40 -0600)
This looks like a typo, using '1' makes no sense. This fixes Solaris
anon allocs.

Reported-by: Sébastien Bouchex Bellomié <sbouchex@infovista.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
memory.c

index 8c06d94d85e7a48ecfb5d8681a8780658f567f6c..76da8a86269e859889366c283281815e9ffac1dc 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -119,7 +119,7 @@ static int alloc_mem_mmap(struct thread_data *td, size_t total_mem)
 {
        int flags = 0;
 
-       td->mmapfd = 1;
+       td->mmapfd = -1;
 
        if (td->o.mem_type == MEM_MMAPHUGE) {
                unsigned long mask = td->o.hugepage_size - 1;
@@ -176,7 +176,8 @@ static void free_mem_mmap(struct thread_data *td, size_t total_mem)
                                                td->orig_buffer);
        munmap(td->orig_buffer, td->orig_buffer_size);
        if (td->o.mmapfile) {
-               close(td->mmapfd);
+               if (td->mmapfd != -1)
+                       close(td->mmapfd);
                unlink(td->o.mmapfile);
                free(td->o.mmapfile);
        }