From 094fa900a3ebf9abfc3a5d4eb5017783987b1b6f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 23 Nov 2021 11:51:46 +0100 Subject: [PATCH] LibCore: Use mmap() and munmap() wrappers in Core::MappedFile --- Userland/Libraries/LibCore/MappedFile.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Userland/Libraries/LibCore/MappedFile.cpp b/Userland/Libraries/LibCore/MappedFile.cpp index 4851e35206..1fc28c7530 100644 --- a/Userland/Libraries/LibCore/MappedFile.cpp +++ b/Userland/Libraries/LibCore/MappedFile.cpp @@ -36,16 +36,7 @@ ErrorOr> MappedFile::map_from_fd_and_close(int fd, [[m auto stat = TRY(Core::System::fstat(fd)); auto size = stat.st_size; - auto* ptr = mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0); - - if (ptr == MAP_FAILED) - return Error::from_errno(errno); - -#ifdef __serenity__ - if (set_mmap_name(ptr, size, path.characters()) < 0) { - perror("set_mmap_name"); - } -#endif + auto* ptr = TRY(Core::System::mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0, 0, path)); return adopt_ref(*new MappedFile(ptr, size)); } @@ -58,8 +49,7 @@ MappedFile::MappedFile(void* ptr, size_t size) MappedFile::~MappedFile() { - auto rc = munmap(m_data, m_size); - VERIFY(rc == 0); + MUST(Core::System::munmap(m_data, m_size)); } }