fd: mmap: Don't use null span
We aren't allowed to use a null span with positive size, change the
internal interfaces to avoid it.
Change-Id: I6687d45a535c20b72f42a99e1ecdbd89f3796f99
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/fd/impl.cpp b/src/fd/impl.cpp
index 3147e64..5f9fe7f 100644
--- a/src/fd/impl.cpp
+++ b/src/fd/impl.cpp
@@ -188,16 +188,16 @@
return FileFlags(CHECK_ERRNO(::fcntl(get(), F_GETFL), "fcntl getfl"));
}
-std::span<std::byte> FdImpl::mmap(std::span<std::byte> window, ProtFlags prot,
- MMapFlags flags, off_t offset)
+std::span<std::byte> FdImpl::mmap(std::byte* window, std::size_t size,
+ ProtFlags prot, MMapFlags flags, off_t offset)
{
- auto ret = ::mmap(window.data(), window.size(), static_cast<int>(prot),
+ auto ret = ::mmap(window, size, static_cast<int>(prot),
static_cast<int>(flags), get(), offset);
if (ret == MAP_FAILED)
{
util::doError(errno, "mmap");
}
- return {reinterpret_cast<std::byte*>(ret), window.size()};
+ return {reinterpret_cast<std::byte*>(ret), size};
}
void FdImpl::munmap(std::span<std::byte> window)