diff options
| author | Josh Gao <jmgao@google.com> | 2018-11-01 12:32:52 -0700 |
|---|---|---|
| committer | Josh Gao <jmgao@google.com> | 2018-11-02 10:54:42 -0700 |
| commit | 1390e81d1c09f0e8c8c67b0ad5a425f8dda051f7 (patch) | |
| tree | 08d2780c17ee1816ba994a22672af35bb15bb02c /base | |
| parent | 2141f9a6c49f78ed5ca51fa68a65df3a0c45ccbc (diff) | |
| download | system_core-1390e81d1c09f0e8c8c67b0ad5a425f8dda051f7.tar.gz system_core-1390e81d1c09f0e8c8c67b0ad5a425f8dda051f7.tar.bz2 system_core-1390e81d1c09f0e8c8c67b0ad5a425f8dda051f7.zip | |
base: add more error-checking overloads for unique_fd.
unique_fd::operator int was a mistake...
Bug: http://b/118818285
Test: treehugger
Change-Id: I3775dd7b4666abec8b5ce2a43092d9601eb1128f
Diffstat (limited to 'base')
| -rw-r--r-- | base/include/android-base/unique_fd.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/base/include/android-base/unique_fd.h b/base/include/android-base/unique_fd.h index cd2dc0416..b92b71122 100644 --- a/base/include/android-base/unique_fd.h +++ b/base/include/android-base/unique_fd.h @@ -16,6 +16,7 @@ #pragma once +#include <dirent.h> #include <fcntl.h> #if !defined(_WIN32) @@ -219,3 +220,13 @@ inline FILE* Fdopen(unique_fd&& ufd, const char* mode) { template <typename T> int close(const android::base::unique_fd_impl<T>&) __attribute__((__unavailable__("close called on unique_fd"))); + +template <typename T> +FILE* fdopen(const android::base::unique_fd_impl<T>&, const char* mode) + __attribute__((__unavailable__("fdopen takes ownership of the fd passed in; either dup the " + "unique_fd, or use android::base::Fdopen to pass ownership"))); + +template <typename T> +DIR* fdopendir(const android::base::unique_fd_impl<T>&) __attribute__(( + __unavailable__("fdopendir takes ownership of the fd passed in; either dup the " + "unique_fd, or use android::base::Fdopendir to pass ownership"))); |
