Loading base/include/android-base/unique_fd.h +1 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ class unique_fd final { } int get() const { return value_; } operator int() const { return get(); } int release() __attribute__((warn_unused_result)) { int ret = value_; Loading bootstat/boot_event_record_store_test.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ namespace { // the value of the record. bool CreateEmptyBootEventRecord(const std::string& record_path, int32_t value) { android::base::unique_fd record_fd(creat(record_path.c_str(), S_IRUSR | S_IWUSR)); if (record_fd.get() == -1) { if (record_fd == -1) { return false; } Loading @@ -49,7 +49,7 @@ bool CreateEmptyBootEventRecord(const std::string& record_path, int32_t value) { // ensure the validity of the file mtime value, i.e., to check that the record // file mtime values are not changed once set. // TODO(jhawkins): Remove this block. if (!android::base::WriteStringToFd(std::to_string(value), record_fd.get())) { if (!android::base::WriteStringToFd(std::to_string(value), record_fd)) { return false; } Loading libmemunreachable/ProcessMappings.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -30,11 +30,10 @@ bool ProcessMappings(pid_t pid, allocator::vector<Mapping>& mappings) { char map_buffer[1024]; snprintf(map_buffer, sizeof(map_buffer), "/proc/%d/maps", pid); int fd = open(map_buffer, O_RDONLY); if (fd < 0) { android::base::unique_fd fd(open(map_buffer, O_RDONLY)); if (fd == -1) { return false; } android::base::unique_fd fd_guard{fd}; LineBuffer line_buf(fd, map_buffer, sizeof(map_buffer)); char* line; Loading libmemunreachable/ThreadCapture.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -108,12 +108,11 @@ bool ThreadCaptureImpl::ListThreads(TidList& tids) { strlcat(path, pid_str, sizeof(path)); strlcat(path, "/task", sizeof(path)); int fd = open(path, O_CLOEXEC | O_DIRECTORY | O_RDONLY); if (fd < 0) { android::base::unique_fd fd(open(path, O_CLOEXEC | O_DIRECTORY | O_RDONLY)); if (fd == -1) { ALOGE("failed to open %s: %s", path, strerror(errno)); return false; } android::base::unique_fd fd_guard{fd}; struct linux_dirent64 { uint64_t d_ino; Loading @@ -125,7 +124,7 @@ bool ThreadCaptureImpl::ListThreads(TidList& tids) { char dirent_buf[4096]; ssize_t nread; do { nread = syscall(SYS_getdents64, fd, dirent_buf, sizeof(dirent_buf)); nread = syscall(SYS_getdents64, fd.get(), dirent_buf, sizeof(dirent_buf)); if (nread < 0) { ALOGE("failed to get directory entries from %s: %s", path, strerror(errno)); return false; Loading libmemunreachable/tests/ThreadCapture_test.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -28,8 +28,6 @@ #include <gtest/gtest.h> #include <android-base/unique_fd.h> #include "Allocator.h" #include "ScopedDisableMalloc.h" #include "ScopedPipe.h" Loading Loading
base/include/android-base/unique_fd.h +1 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ class unique_fd final { } int get() const { return value_; } operator int() const { return get(); } int release() __attribute__((warn_unused_result)) { int ret = value_; Loading
bootstat/boot_event_record_store_test.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ namespace { // the value of the record. bool CreateEmptyBootEventRecord(const std::string& record_path, int32_t value) { android::base::unique_fd record_fd(creat(record_path.c_str(), S_IRUSR | S_IWUSR)); if (record_fd.get() == -1) { if (record_fd == -1) { return false; } Loading @@ -49,7 +49,7 @@ bool CreateEmptyBootEventRecord(const std::string& record_path, int32_t value) { // ensure the validity of the file mtime value, i.e., to check that the record // file mtime values are not changed once set. // TODO(jhawkins): Remove this block. if (!android::base::WriteStringToFd(std::to_string(value), record_fd.get())) { if (!android::base::WriteStringToFd(std::to_string(value), record_fd)) { return false; } Loading
libmemunreachable/ProcessMappings.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -30,11 +30,10 @@ bool ProcessMappings(pid_t pid, allocator::vector<Mapping>& mappings) { char map_buffer[1024]; snprintf(map_buffer, sizeof(map_buffer), "/proc/%d/maps", pid); int fd = open(map_buffer, O_RDONLY); if (fd < 0) { android::base::unique_fd fd(open(map_buffer, O_RDONLY)); if (fd == -1) { return false; } android::base::unique_fd fd_guard{fd}; LineBuffer line_buf(fd, map_buffer, sizeof(map_buffer)); char* line; Loading
libmemunreachable/ThreadCapture.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -108,12 +108,11 @@ bool ThreadCaptureImpl::ListThreads(TidList& tids) { strlcat(path, pid_str, sizeof(path)); strlcat(path, "/task", sizeof(path)); int fd = open(path, O_CLOEXEC | O_DIRECTORY | O_RDONLY); if (fd < 0) { android::base::unique_fd fd(open(path, O_CLOEXEC | O_DIRECTORY | O_RDONLY)); if (fd == -1) { ALOGE("failed to open %s: %s", path, strerror(errno)); return false; } android::base::unique_fd fd_guard{fd}; struct linux_dirent64 { uint64_t d_ino; Loading @@ -125,7 +124,7 @@ bool ThreadCaptureImpl::ListThreads(TidList& tids) { char dirent_buf[4096]; ssize_t nread; do { nread = syscall(SYS_getdents64, fd, dirent_buf, sizeof(dirent_buf)); nread = syscall(SYS_getdents64, fd.get(), dirent_buf, sizeof(dirent_buf)); if (nread < 0) { ALOGE("failed to get directory entries from %s: %s", path, strerror(errno)); return false; Loading
libmemunreachable/tests/ThreadCapture_test.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -28,8 +28,6 @@ #include <gtest/gtest.h> #include <android-base/unique_fd.h> #include "Allocator.h" #include "ScopedDisableMalloc.h" #include "ScopedPipe.h" Loading