From 5d1b1a8b91a35f465e5af146bcfd5d7b4346854c Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Wed, 14 Sep 2016 12:47:02 -0700 Subject: [PATCH] base: rename unique_fd::clear() to unique_fd::reset(). unique_fd is modeled on unique_ptr, so make this consistent. Test: m checkbuild Change-Id: Ia6a77095dc18746fbb432e96bb8dccfc049c57f6 --- adb/shell_service.cpp | 6 +++--- base/include/android-base/unique_fd.h | 8 ++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/adb/shell_service.cpp b/adb/shell_service.cpp index 01e206a58..b0b31f1b8 100644 --- a/adb/shell_service.cpp +++ b/adb/shell_service.cpp @@ -493,10 +493,10 @@ void Subprocess::PassDataStreams() { // We also need to close the pipes connected to the child process // so that if it ignores SIGHUP and continues to write data it // won't fill up the pipe and block. - stdinout_sfd_.clear(); - stderr_sfd_.clear(); + stdinout_sfd_.reset(); + stderr_sfd_.reset(); } - dead_sfd->clear(); + dead_sfd->reset(); } } } diff --git a/base/include/android-base/unique_fd.h b/base/include/android-base/unique_fd.h index c32331180..6cfcfcd37 100644 --- a/base/include/android-base/unique_fd.h +++ b/base/include/android-base/unique_fd.h @@ -55,7 +55,7 @@ class unique_fd_impl final { unique_fd_impl() : value_(-1) {} explicit unique_fd_impl(int value) : value_(value) {} - ~unique_fd_impl() { clear(); } + ~unique_fd_impl() { reset(); } unique_fd_impl(unique_fd_impl&& other) : value_(other.release()) {} unique_fd_impl& operator=(unique_fd_impl&& s) { @@ -63,17 +63,13 @@ class unique_fd_impl final { return *this; } - void reset(int new_value) { + void reset(int new_value = -1) { if (value_ != -1) { Closer::Close(value_); } value_ = new_value; } - void clear() { - reset(-1); - } - int get() const { return value_; } operator int() const { return get(); }