From 5fa53bc27a4ffae24a984657421cf0164bb0c76d Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 26 May 2022 14:45:20 -0700 Subject: [PATCH] devices: vvu: wl: do not hold RefCell borrow across await Change the comparison from an `if let` into a regular `if ... ==` by implementing `PartialEq` for the relevant types. This makes the lifetime of the `wl_state.borrow_mut()` end before calling `kick_evt.next_val().await()`. Fixes a new clippy warning from Rust 1.61.0: BUG=None TEST=tools/clippy # with Rust 1.61.0 Change-Id: I067c2ab532d753306cd5334df5bb4f2c7c2e6584 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671130 Reviewed-by: Alexandre Courbot Reviewed-by: Anton Romanov Commit-Queue: Daniel Verkamp Tested-by: kokoro --- devices/src/virtio/vhost/user/device/wl.rs | 4 ++-- devices/src/virtio/wl.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/devices/src/virtio/vhost/user/device/wl.rs b/devices/src/virtio/vhost/user/device/wl.rs index 56afdd15a9..630510ce50 100644 --- a/devices/src/virtio/vhost/user/device/wl.rs +++ b/devices/src/virtio/vhost/user/device/wl.rs @@ -62,8 +62,8 @@ async fn run_in_queue( break; } - if let Err(wl::DescriptorsExhausted) = - wl::process_in_queue(&doorbell, &mut queue, &mem, &mut wlstate.borrow_mut()) + if wl::process_in_queue(&doorbell, &mut queue, &mem, &mut wlstate.borrow_mut()) + == Err(wl::DescriptorsExhausted) { if let Err(e) = kick_evt.next_val().await { error!("Failed to read kick event for in queue: {}", e); diff --git a/devices/src/virtio/wl.rs b/devices/src/virtio/wl.rs index fa7de516ed..8e1f3e13dc 100644 --- a/devices/src/virtio/wl.rs +++ b/devices/src/virtio/wl.rs @@ -1492,7 +1492,7 @@ impl WlState { } } -#[derive(ThisError, Debug)] +#[derive(ThisError, Debug, PartialEq)] #[error("no descriptors available in queue")] pub struct DescriptorsExhausted;