Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1390e81d authored by Josh Gao's avatar Josh Gao
Browse files

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
parent 2141f9a6
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -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")));