diff --git a/vhost-device-sound/src/audio_backends/alsa.rs b/vhost-device-sound/src/audio_backends/alsa.rs index b61b786..7a6bd95 100644 --- a/vhost-device-sound/src/audio_backends/alsa.rs +++ b/vhost-device-sound/src/audio_backends/alsa.rs @@ -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() { diff --git a/vhost-device-sound/src/audio_backends/null.rs b/vhost-device-sound/src/audio_backends/null.rs index 0eedbf1..97078ff 100644 --- a/vhost-device-sound/src/audio_backends/null.rs +++ b/vhost-device-sound/src/audio_backends/null.rs @@ -10,7 +10,7 @@ pub struct NullBackend { } impl NullBackend { - pub fn new(streams: Arc>>) -> Self { + pub const fn new(streams: Arc>>) -> Self { Self { streams } } } diff --git a/vhost-device-sound/src/audio_backends/pipewire.rs b/vhost-device-sound/src/audio_backends/pipewire.rs index dedcf5b..32f989d 100644 --- a/vhost-device-sound/src/audio_backends/pipewire.rs +++ b/vhost-device-sound/src/audio_backends/pipewire.rs @@ -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 { diff --git a/vhost-device-sound/src/device.rs b/vhost-device-sound/src/device.rs index 5fea9ea..3d7db21 100644 --- a/vhost-device-sound/src/device.rs +++ b/vhost-device-sound/src/device.rs @@ -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 diff --git a/vhost-device-sound/src/stream.rs b/vhost-device-sound/src/stream.rs index d33f066..53d2140 100644 --- a/vhost-device-sound/src/stream.rs +++ b/vhost-device-sound/src/stream.rs @@ -266,7 +266,7 @@ impl std::fmt::Debug for Request { } impl Request { - pub fn new(len: usize, message: Arc, direction: Direction) -> Self { + pub const fn new(len: usize, message: Arc, direction: Direction) -> Self { Self { pos: 0, len,