chore: fix clippy warnings

The new version of clippy in the CI suggested several improvements.
Some fixed with `clippy --fix`, some by hand.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
This commit is contained in:
Stefano Garzarella 2024-09-25 08:58:02 +02:00 committed by Manos Pitsidianakis
parent 9801d71dee
commit ef98372646
10 changed files with 16 additions and 16 deletions

View File

@ -104,6 +104,7 @@ fn main() -> Result<()> {
#[cfg(test)]
mod tests {
use assert_matches::assert_matches;
#[cfg(feature = "v4l2-decoder")]
use rstest::*;
use tempfile::tempdir;
@ -125,6 +126,7 @@ mod tests {
backend: BackendType::Null,
})]
// Selecting different decoder
#[cfg(feature = "v4l2-decoder")]
#[case::set_v4l2_decoder(vec![" ", "--socket-path", "long-video.sock", "-b", "v4l2-decoder"],
VideoArgs {
socket_path: "long-video.sock".into(),
@ -137,6 +139,7 @@ mod tests {
assert_eq!(VuVideoConfig::from(command_line), VuVideoConfig::from(args));
}
#[cfg(feature = "v4l2-decoder")]
#[test]
fn test_fail_create_backend() {
use vhu_video::VuVideoError;

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0 or BSD-3-Clause
// Null Backend does not use all stream capabilities
#![cfg_attr(not(any(feature)), allow(dead_code))]
#![cfg_attr(not(any(feature = "default")), allow(dead_code))]
use std::{
collections::HashMap,

View File

@ -372,7 +372,7 @@ mod tests {
// Prepares a single chain of descriptors
fn prepare_desc_chain(
start_addr: GuestAddress,
buf: &mut Vec<u8>,
buf: &mut [u8],
flag: u32,
client_addr: u16,
) -> I2cDescriptorChain {

View File

@ -734,7 +734,7 @@ mod tests {
let path = make_directory("_test");
let directory = IIODirectory { path };
for (file, content) in files.iter() {
fs::write(&directory.path.join(file), content).unwrap();
fs::write(directory.path.join(file), content).unwrap();
}
directory
}

View File

@ -58,7 +58,7 @@ impl EmulatedTarget {
self.luns.push(logical_unit);
}
pub(crate) fn luns(&self) -> impl Iterator<Item = u16> + ExactSizeIterator + '_ {
pub(crate) fn luns(&self) -> impl ExactSizeIterator<Item = u16> + '_ {
// unwrap is safe: we limit LUNs at 256
self.luns
.iter()

View File

@ -1,7 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 or BSD-3-Clause
#![cfg(test)]
mod bad_lun;
mod generic;
mod report_supported_operation_codes;

View File

@ -53,9 +53,9 @@ impl Drop for DbusSession {
/// `PipewireTestHarness::new()`.
#[non_exhaustive]
pub struct PipewireTestHarness {
pub dbus: DbusSession,
pub _dbus: DbusSession,
pub pipewire_child: Child,
pub tempdir: TempDir,
pub _tempdir: TempDir,
}
pub fn launch_pipewire(
@ -92,9 +92,9 @@ impl PipewireTestHarness {
std::env::set_var("XDG_RUNTIME_DIR", tempdir.path());
Self {
dbus: dbus_session,
_dbus: dbus_session,
pipewire_child,
tempdir,
_tempdir: tempdir,
}
}
}

View File

@ -42,7 +42,7 @@ type Result<T> = std::result::Result<T, Error>;
/// - `SET PARAMETERS`
///
/// The driver negotiates the stream parameters (format, transport, etc) with
/// the device.
/// the device.
///
/// Possible valid transitions: `SET PARAMETERS`, `PREPARE`.
///
@ -51,7 +51,7 @@ type Result<T> = std::result::Result<T, Error>;
/// The device prepares the stream (allocates resources, etc).
///
/// Possible valid transitions: `SET PARAMETERS`, `PREPARE`, `START`,
/// `RELEASE`. Output only: the driver transfers data for pre-buffing.
/// `RELEASE`. Output only: the driver transfers data for pre-buffing.
///
/// - `START`
///

View File

@ -266,7 +266,7 @@ mod tests {
fn prepare_descriptors(
mut next_addr: u64,
mem: &GuestMemoryLoadGuard<GuestMemoryMmap<()>>,
buf: &mut Vec<u8>,
buf: &mut [u8],
) -> Vec<Descriptor> {
let mut descriptors = Vec::new();
let mut index = 0;
@ -317,7 +317,7 @@ mod tests {
}
// Prepares a single chain of descriptors
fn prepare_desc_chain(buf: &mut Vec<u8>) -> (VhostUserFooBackend, VringRwLock) {
fn prepare_desc_chain(buf: &mut [u8]) -> (VhostUserFooBackend, VringRwLock) {
let (mut backend, mem, vring) = init();
let mem_handle = mem.memory();
let vq = MockSplitQueue::new(&*mem_handle, 16);
@ -351,7 +351,7 @@ mod tests {
// Prepares a chain of descriptors
fn prepare_desc_chains(
mem: &GuestMemoryAtomic<GuestMemoryMmap>,
buf: &mut Vec<u8>,
buf: &mut [u8],
) -> FooDescriptorChain {
let mem_handle = mem.memory();
let vq = MockSplitQueue::new(&*mem_handle, 16);

View File

@ -4,7 +4,6 @@ use std::{
collections::{HashMap, HashSet},
io::{self, Result as IoResult},
sync::{Arc, Mutex, RwLock},
u16, u32, u64, u8,
};
use log::warn;