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

Commit f3fd7ca8 authored by Jiwen 'Steve' Cai's avatar Jiwen 'Steve' Cai Committed by Fan Xu
Browse files

NativeHandleWrapper shouldn't return native_handle_t* in const

DuplicateHandle() and TakeHandle() are returning the native_handle_t*
as passing ownership out of the wrapper. Thus the returned pointer
shouldn't be in const.

Bug: 111976433
Test: buffer_hub-test
Change-Id: Ie353046f5b59beab674a81f4490d5de1d4beaa2e
parent f53ae7ed
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -40,7 +40,7 @@ class NativeHandleWrapper {
  bool IsValid() const { return ints_.size() != 0 || fds_.size() != 0; }
  bool IsValid() const { return ints_.size() != 0 || fds_.size() != 0; }


  // Duplicate a native handle from the wrapper.
  // Duplicate a native handle from the wrapper.
  const native_handle_t* DuplicateHandle() const {
  native_handle_t* DuplicateHandle() const {
    if (!IsValid()) {
    if (!IsValid()) {
      return nullptr;
      return nullptr;
    }
    }
@@ -58,7 +58,7 @@ class NativeHandleWrapper {
  }
  }


  // Takes the native handle out of the wrapper.
  // Takes the native handle out of the wrapper.
  const native_handle_t* TakeHandle() {
  native_handle_t* TakeHandle() {
    if (!IsValid()) {
    if (!IsValid()) {
      return nullptr;
      return nullptr;
    }
    }
@@ -70,7 +70,7 @@ class NativeHandleWrapper {
  NativeHandleWrapper(const NativeHandleWrapper&) = delete;
  NativeHandleWrapper(const NativeHandleWrapper&) = delete;
  void operator=(const NativeHandleWrapper&) = delete;
  void operator=(const NativeHandleWrapper&) = delete;


  static const native_handle_t* FromFdsAndInts(std::vector<FileHandleType> fds,
  static native_handle_t* FromFdsAndInts(std::vector<FileHandleType> fds,
                                         std::vector<int> ints) {
                                         std::vector<int> ints) {
    native_handle_t* handle = native_handle_create(fds.size(), ints.size());
    native_handle_t* handle = native_handle_create(fds.size(), ints.size());
    if (!handle) {
    if (!handle) {