diff options
author | Josh Gao <jmgao@google.com> | 2019-04-18 16:39:30 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2019-04-24 12:59:42 -0700 |
commit | 6bc77009177ba2de4c25a2c8f17bee826c0540a3 (patch) | |
tree | 97b63d6b7c86394ab0a1dc40eedca8f7ce305378 /adb_unique_fd.h | |
parent | 4c0c9c90e1ae4fb8ef7312833a825bc3c3bee62b (diff) | |
download | adb-6bc77009177ba2de4c25a2c8f17bee826c0540a3.tar.gz |
Add a way to turn off unique_fd's operator int.
unique_fd's implicit conversion to int has led to tons of problems (see
all of the overloads for close, fdopen, fdopendir, etc.). Add a switch
that can turn it off, and reduce the ridiculous amount of work to fix up
callers by introducing a borrowed_fd type that can be constructed from
either int or unique_fd.
Test: treehugger
Change-Id: If77cf5cbcaddacdaec5919a15b3520fb68f51a62
Diffstat (limited to 'adb_unique_fd.h')
-rw-r--r-- | adb_unique_fd.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/adb_unique_fd.h b/adb_unique_fd.h index d47213d7..b6c910a9 100644 --- a/adb_unique_fd.h +++ b/adb_unique_fd.h @@ -32,6 +32,8 @@ using unique_fd = android::base::unique_fd_impl<AdbCloser>; using unique_fd = android::base::unique_fd; #endif +using android::base::borrowed_fd; + template <typename T> int adb_close(const android::base::unique_fd_impl<T>&) __attribute__((__unavailable__("adb_close called on unique_fd"))); |