libshmem: don't depend on unique_fd cast to int
Bug: 302723053
Test: m libshmemcompat
Change-Id: I862e726ca3fa22b1f16a3d718a80d3a035fe129c
diff --git a/media/libshmem/ShmemCompat.cpp b/media/libshmem/ShmemCompat.cpp
index 246cb24..4200c2e 100644
--- a/media/libshmem/ShmemCompat.cpp
+++ b/media/libshmem/ShmemCompat.cpp
@@ -84,11 +84,11 @@
return false;
}
- const int fd = fcntl(heap->getHeapID(), F_DUPFD_CLOEXEC, 0);
- if (fd < 0) {
+ base::unique_fd fd(fcntl(heap->getHeapID(), F_DUPFD_CLOEXEC, 0));
+ if (!fd.ok()) {
return false;
}
- result->fd.reset(base::unique_fd(fd));
+ result->fd.reset(std::move(fd));
result->size = size;
result->offset = heap->getOffset() + offset;
result->writeable = (heap->getFlags() & IMemoryHeap::READ_ONLY) == 0;