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

Commit cbdc47ae authored by Tianyu Jiang's avatar Tianyu Jiang
Browse files

Change the sequence between moving a struct and accessing a field inside the struct.

Accessing to a field of size_t in a move()d struct works but not so
reasonable because fields of a move()d object is considered as invalid.

Test: buffer_hub_queue-test still pass
Bug: None
Change-Id: I799ba61e6535c021b9061fa299167cba0c630cde
parent c467ceef
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -337,8 +337,6 @@ Status<void> BufferHubQueue::RemoveBuffer(size_t slot) {

Status<void> BufferHubQueue::Enqueue(Entry entry) {
  if (!is_full()) {
    available_buffers_.push(std::move(entry));

    // Find and remove the enqueued buffer from unavailable_buffers_slot if
    // exist.
    auto enqueued_buffer_iter = std::find_if(
@@ -348,6 +346,8 @@ Status<void> BufferHubQueue::Enqueue(Entry entry) {
      unavailable_buffers_slot_.erase(enqueued_buffer_iter);
    }

    available_buffers_.push(std::move(entry));

    // Trigger OnBufferAvailable callback if registered.
    if (on_buffer_available_)
      on_buffer_available_();