Skip to content
This repository was archived by the owner on Jul 14, 2019. It is now read-only.

Commit efcdafc

Browse files
erezarnonLior Amram
authored andcommitted
remove redundant close()
1 parent 5547030 commit efcdafc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/file_mapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ int file_mapper_init_with_fd(struct file_mapper *fm, int fd, size_t size, int mm
4141
}
4242
fm->size = size;
4343
fm->mem = size ? (char *)mmap(NULL, RIBS_VM_ALIGN(size), mmap_prot, mmap_flags, fd, 0) : NULL;
44-
close(fd);
4544
if (MAP_FAILED == fm->mem)
4645
return LOGGER_PERROR_FUNC("mmap %d", fd), fm->mem = NULL, -1;
4746
return 0;
@@ -60,6 +59,7 @@ int file_mapper_init2(struct file_mapper *fm, const char *filename, size_t size,
6059
if (0 > file_mapper_init_with_fd(fm, fd, size, mmap_prot, mmap_flags)){
6160
return LOGGER_PERROR_FUNC("file_mapper_init_with_fd: %s", filename), fm->mem = NULL, close(fd), -1;
6261
}
62+
close(fd);
6363
return 0;
6464
}
6565

0 commit comments

Comments
 (0)