mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2025-12-26 22:48:17 +00:00
sound: fix some minor clippy lints
Unnecessary lazy evaluation in Option::ok_or_else uses, constify some functions. Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
This commit is contained in:
parent
937d28daee
commit
9757042216
@ -654,7 +654,7 @@ impl AudioBackend for AlsaBackend {
|
||||
.write()
|
||||
.unwrap()
|
||||
.get_mut(id as usize)
|
||||
.ok_or_else(|| Error::StreamWithIdNotFound(id))?
|
||||
.ok_or(Error::StreamWithIdNotFound(id))?
|
||||
.state
|
||||
.stop()
|
||||
{
|
||||
|
||||
@ -10,7 +10,7 @@ pub struct NullBackend {
|
||||
}
|
||||
|
||||
impl NullBackend {
|
||||
pub fn new(streams: Arc<RwLock<Vec<Stream>>>) -> Self {
|
||||
pub const fn new(streams: Arc<RwLock<Vec<Stream>>>) -> Self {
|
||||
Self { streams }
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ impl AudioBackend for PwBackend {
|
||||
.write()
|
||||
.unwrap()
|
||||
.get_mut(stream_id as usize)
|
||||
.ok_or_else(|| Error::StreamWithIdNotFound(stream_id))?
|
||||
.ok_or(Error::StreamWithIdNotFound(stream_id))?
|
||||
.state
|
||||
.prepare();
|
||||
if let Err(err) = prepare_result {
|
||||
@ -500,7 +500,7 @@ impl AudioBackend for PwBackend {
|
||||
.write()
|
||||
.unwrap()
|
||||
.get_mut(stream_id as usize)
|
||||
.ok_or_else(|| Error::StreamWithIdNotFound(stream_id))?
|
||||
.ok_or(Error::StreamWithIdNotFound(stream_id))?
|
||||
.state
|
||||
.release();
|
||||
if let Err(err) = release_result {
|
||||
@ -529,7 +529,7 @@ impl AudioBackend for PwBackend {
|
||||
.write()
|
||||
.unwrap()
|
||||
.get_mut(stream_id as usize)
|
||||
.ok_or_else(|| Error::StreamWithIdNotFound(stream_id))?
|
||||
.ok_or(Error::StreamWithIdNotFound(stream_id))?
|
||||
.state
|
||||
.start();
|
||||
if let Err(err) = start_result {
|
||||
@ -554,7 +554,7 @@ impl AudioBackend for PwBackend {
|
||||
.write()
|
||||
.unwrap()
|
||||
.get_mut(stream_id as usize)
|
||||
.ok_or_else(|| Error::StreamWithIdNotFound(stream_id))?
|
||||
.ok_or(Error::StreamWithIdNotFound(stream_id))?
|
||||
.state
|
||||
.stop();
|
||||
if let Err(err) = stop_result {
|
||||
|
||||
@ -92,11 +92,11 @@ impl VhostUserSoundThread {
|
||||
) -> IoResult<()> {
|
||||
let vring = &vrings
|
||||
.get(device_event as usize)
|
||||
.ok_or_else(|| Error::HandleUnknownEvent(device_event))?;
|
||||
.ok_or(Error::HandleUnknownEvent(device_event))?;
|
||||
let queue_idx = self
|
||||
.queue_indexes
|
||||
.get(device_event as usize)
|
||||
.ok_or_else(|| Error::HandleUnknownEvent(device_event))?;
|
||||
.ok_or(Error::HandleUnknownEvent(device_event))?;
|
||||
if self.event_idx {
|
||||
// vm-virtio's Queue implementation only checks avail_index
|
||||
// once, so to properly support EVENT_IDX we need to keep
|
||||
|
||||
@ -266,7 +266,7 @@ impl std::fmt::Debug for Request {
|
||||
}
|
||||
|
||||
impl Request {
|
||||
pub fn new(len: usize, message: Arc<IOMessage>, direction: Direction) -> Self {
|
||||
pub const fn new(len: usize, message: Arc<IOMessage>, direction: Direction) -> Self {
|
||||
Self {
|
||||
pos: 0,
|
||||
len,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user