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

Commit f7dc94f6 authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder_ndk: nice dup operator

Common operations for ScopedFileDescriptor. Not clear to need to do
ScopedFileDescriptor(::dup(foo.get())) b/c 'get' method is inherited
here, and justifying duplicated API surface because this method does the
right thing wrt ownership.

Bug: email thread
Test: CtsNdkBinderTestCases
Change-Id: I60a281a1e2ddb42bc0768a0114a5e9e7b22aaed2
parent 7926d52f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -365,6 +365,8 @@ class ScopedFileDescriptor : public impl::ScopedAResource<int, internal::closeWi
    ScopedFileDescriptor(ScopedFileDescriptor&&) = default;
    ScopedFileDescriptor& operator=(ScopedFileDescriptor&&) = default;

    ScopedFileDescriptor dup() const { return ScopedFileDescriptor(::dup(get())); }

    bool operator!=(const ScopedFileDescriptor& rhs) const { return get() != rhs.get(); }
    bool operator<(const ScopedFileDescriptor& rhs) const { return get() < rhs.get(); }
    bool operator<=(const ScopedFileDescriptor& rhs) const { return get() <= rhs.get(); }