misc: Automatic beta clippy fixes

e.g. cargo clippy --all --tests --all-targets --fix --features=..

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2022-09-20 09:46:19 +01:00
parent ab0b3f1b7b
commit f32487f8e8
11 changed files with 575 additions and 575 deletions

View File

@ -231,7 +231,7 @@ impl CpuidPatch {
) {
let mut entry_found = false;
for entry in cpuid.iter_mut() {
if entry.function == function && (index == None || index.unwrap() == entry.index) {
if entry.function == function && (index.is_none() || index.unwrap() == entry.index) {
entry_found = true;
match reg {
CpuidReg::EAX => {

View File

@ -11,7 +11,7 @@ use std::process::Command;
fn main() {
let mut version = "v".to_owned() + crate_version!();
if let Ok(git_out) = Command::new("git").args(&["describe", "--dirty"]).output() {
if let Ok(git_out) = Command::new("git").args(["describe", "--dirty"]).output() {
if git_out.status.success() {
if let Ok(git_out_str) = String::from_utf8(git_out.stdout) {
version = git_out_str;

View File

@ -10,7 +10,7 @@ use std::process::Command;
fn main() {
let mut git_human_readable = "v".to_owned() + crate_version!();
if let Ok(git_out) = Command::new("git").args(&["describe", "--dirty"]).output() {
if let Ok(git_out) = Command::new("git").args(["describe", "--dirty"]).output() {
if git_out.status.success() {
if let Ok(git_out_str) = String::from_utf8(git_out.stdout) {
git_human_readable = git_out_str;

View File

@ -52,7 +52,7 @@ pub struct MetricsReport {
impl Default for MetricsReport {
fn default() -> Self {
let mut git_human_readable = "".to_string();
if let Ok(git_out) = Command::new("git").args(&["describe", "--dirty"]).output() {
if let Ok(git_out) = Command::new("git").args(["describe", "--dirty"]).output() {
if git_out.status.success() {
git_human_readable = String::from_utf8(git_out.stdout)
.unwrap()
@ -67,7 +67,7 @@ impl Default for MetricsReport {
}
let mut git_revision = "".to_string();
if let Ok(git_out) = Command::new("git").args(&["rev-parse", "HEAD"]).output() {
if let Ok(git_out) = Command::new("git").args(["rev-parse", "HEAD"]).output() {
if git_out.status.success() {
git_revision = String::from_utf8(git_out.stdout)
.unwrap()
@ -83,7 +83,7 @@ impl Default for MetricsReport {
let mut git_commit_date = "".to_string();
if let Ok(git_out) = Command::new("git")
.args(&["show", "-s", "--format=%cd"])
.args(["show", "-s", "--format=%cd"])
.output()
{
if git_out.status.success() {

View File

@ -92,12 +92,12 @@ pub fn performance_net_throughput(control: &PerformanceTestControl) -> f64 {
);
let mut child = GuestCommand::new(&guest)
.args(&["--cpus", &format!("boot={}", num_queues)])
.args(&["--memory", "size=4G"])
.args(&["--kernel", direct_kernel_boot_path().to_str().unwrap()])
.args(&["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
.args(["--cpus", &format!("boot={}", num_queues)])
.args(["--memory", "size=4G"])
.args(["--kernel", direct_kernel_boot_path().to_str().unwrap()])
.args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
.default_disks()
.args(&["--net", net_params.as_str()])
.args(["--net", net_params.as_str()])
.capture_output()
.verbosity(VerbosityLevel::Warn)
.set_print_cmd(false)
@ -133,12 +133,12 @@ pub fn performance_net_latency(control: &PerformanceTestControl) -> f64 {
);
let mut child = GuestCommand::new(&guest)
.args(&["--cpus", &format!("boot={}", num_queues)])
.args(&["--memory", "size=4G"])
.args(&["--kernel", direct_kernel_boot_path().to_str().unwrap()])
.args(&["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
.args(["--cpus", &format!("boot={}", num_queues)])
.args(["--memory", "size=4G"])
.args(["--kernel", direct_kernel_boot_path().to_str().unwrap()])
.args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
.default_disks()
.args(&["--net", net_params.as_str()])
.args(["--net", net_params.as_str()])
.capture_output()
.verbosity(VerbosityLevel::Warn)
.set_print_cmd(false)
@ -278,14 +278,14 @@ pub fn performance_boot_time(control: &PerformanceTestControl) -> f64 {
let mut cmd = GuestCommand::new(&guest);
let c = cmd
.args(&[
.args([
"--cpus",
&format!("boot={}", control.num_boot_vcpus.unwrap_or(1)),
])
.args(&["--memory", "size=1G"])
.args(&["--kernel", direct_kernel_boot_path().to_str().unwrap()])
.args(&["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
.args(&["--console", "off"])
.args(["--memory", "size=1G"])
.args(["--kernel", direct_kernel_boot_path().to_str().unwrap()])
.args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
.args(["--console", "off"])
.default_disks();
measure_boot_time(c, control.test_timeout).unwrap()
@ -305,15 +305,15 @@ pub fn performance_boot_time_pmem(control: &PerformanceTestControl) -> f64 {
let guest = performance_test_new_guest(Box::new(focal));
let mut cmd = GuestCommand::new(&guest);
let c = cmd
.args(&[
.args([
"--cpus",
&format!("boot={}", control.num_boot_vcpus.unwrap_or(1)),
])
.args(&["--memory", "size=1G,hugepages=on"])
.args(&["--kernel", direct_kernel_boot_path().to_str().unwrap()])
.args(&["--cmdline", "root=/dev/pmem0p1 console=ttyS0 quiet rw"])
.args(&["--console", "off"])
.args(&[
.args(["--memory", "size=1G,hugepages=on"])
.args(["--kernel", direct_kernel_boot_path().to_str().unwrap()])
.args(["--cmdline", "root=/dev/pmem0p1 console=ttyS0 quiet rw"])
.args(["--console", "off"])
.args([
"--pmem",
format!(
"file={}",
@ -349,11 +349,11 @@ pub fn performance_block_io(control: &PerformanceTestControl) -> f64 {
.to_string();
let mut child = GuestCommand::new(&guest)
.args(&["--cpus", &format!("boot={}", num_queues)])
.args(&["--memory", "size=4G"])
.args(&["--kernel", direct_kernel_boot_path().to_str().unwrap()])
.args(&["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
.args(&[
.args(["--cpus", &format!("boot={}", num_queues)])
.args(["--memory", "size=4G"])
.args(["--kernel", direct_kernel_boot_path().to_str().unwrap()])
.args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
.args([
"--disk",
format!(
"path={}",
@ -368,7 +368,7 @@ pub fn performance_block_io(control: &PerformanceTestControl) -> f64 {
format!("path={}", BLK_IO_TEST_IMG).as_str(),
])
.default_net()
.args(&["--api-socket", &api_socket])
.args(["--api-socket", &api_socket])
.capture_output()
.verbosity(VerbosityLevel::Warn)
.set_print_cmd(false)

View File

@ -377,7 +377,7 @@ fn create_app<'a>(
Arg::new("seccomp")
.long("seccomp")
.takes_value(true)
.possible_values(&["true", "false", "log"])
.possible_values(["true", "false", "log"])
.default_value("true"),
);

View File

@ -90,7 +90,7 @@ impl GuestNetworkConfig {
match (|| -> Result<(), WaitForBootError> {
let listener =
TcpListener::bind(&listen_addr.as_str()).map_err(WaitForBootError::Listen)?;
TcpListener::bind(listen_addr.as_str()).map_err(WaitForBootError::Listen)?;
listener
.set_nonblocking(true)
.expect("Cannot set non-blocking for tcp listener");
@ -228,7 +228,7 @@ impl Drop for WindowsDiskConfig {
// losetup -d <loopback_device>
std::process::Command::new("losetup")
.args(&["-d", self.loopback_device.as_str()])
.args(["-d", self.loopback_device.as_str()])
.output()
.expect("Expect removing loopback device to succeed");
}
@ -300,8 +300,8 @@ impl DiskConfig for UbuntuDiskConfig {
.expect("Expected writing out network-config to succeed");
std::process::Command::new("mkdosfs")
.args(&["-n", "cidata"])
.args(&["-C", cloudinit_file_path.as_str()])
.args(["-n", "cidata"])
.args(["-C", cloudinit_file_path.as_str()])
.arg("8192")
.output()
.expect("Expect creating disk image to succeed");
@ -311,8 +311,8 @@ impl DiskConfig for UbuntuDiskConfig {
.for_each(|x| {
std::process::Command::new("mcopy")
.arg("-o")
.args(&["-i", cloudinit_file_path.as_str()])
.args(&["-s", cloud_init_directory.join(x).to_str().unwrap(), "::"])
.args(["-i", cloudinit_file_path.as_str()])
.args(["-s", cloud_init_directory.join(x).to_str().unwrap(), "::"])
.output()
.expect("Expect copying files to disk image to succeed");
});
@ -396,7 +396,7 @@ impl DiskConfig for WindowsDiskConfig {
std::process::Command::new("dmsetup")
.arg("create")
.arg(windows_snapshot_cow.as_str())
.args(&[
.args([
"--table",
format!("0 {} linear {} 0", cow_file_blk_size, self.loopback_device).as_str(),
])
@ -415,7 +415,7 @@ impl DiskConfig for WindowsDiskConfig {
std::process::Command::new("dmsetup")
.arg("create")
.arg(windows_snapshot.as_str())
.args(&[
.args([
"--table",
format!(
"0 {} snapshot /dev/mapper/windows-base /dev/mapper/{} P 8",
@ -723,14 +723,14 @@ pub fn ssh_command_ip(
pub fn exec_host_command_status(command: &str) -> ExitStatus {
std::process::Command::new("bash")
.args(&["-c", command])
.args(["-c", command])
.status()
.unwrap_or_else(|_| panic!("Expected '{}' to run", command))
}
pub fn exec_host_command_output(command: &str) -> Output {
std::process::Command::new("bash")
.args(&["-c", command])
.args(["-c", command])
.output()
.unwrap_or_else(|_| panic!("Expected '{}' to run", command))
}
@ -1293,7 +1293,7 @@ impl<'a> GuestCommand<'a> {
pub fn default_disks(&mut self) -> &mut Self {
if self.guest.disk_config.disk(DiskType::CloudInit).is_some() {
self.args(&[
self.args([
"--disk",
format!(
"path={}",
@ -1310,7 +1310,7 @@ impl<'a> GuestCommand<'a> {
.as_str(),
])
} else {
self.args(&[
self.args([
"--disk",
format!(
"path={}",
@ -1325,7 +1325,7 @@ impl<'a> GuestCommand<'a> {
}
pub fn default_net(&mut self) -> &mut Self {
self.args(&["--net", self.guest.default_net_string().as_str()])
self.args(["--net", self.guest.default_net_string().as_str()])
}
}
@ -1536,7 +1536,7 @@ pub fn measure_virtio_net_throughput(
let mut clients = Vec::new();
for n in 0..queue_pairs {
let mut cmd = Command::new("iperf3");
cmd.args(&[
cmd.args([
"-J", // Output in JSON format
"-c",
&guest.network.guest_ip,
@ -1548,7 +1548,7 @@ pub fn measure_virtio_net_throughput(
// For measuring the guest transmit throughput (as a sender),
// use reverse mode of the iperf3 client on the host
if !receive {
cmd.args(&["-R"]);
cmd.args(["-R"]);
}
let client = cmd
.stderr(Stdio::piped())
@ -1650,7 +1650,7 @@ pub fn measure_virtio_net_latency(guest: &Guest, test_timeout: u32) -> Result<Ve
.unwrap()
.to_string();
let mut c = Command::new(ethr_path)
.args(&[
.args([
"-c",
&guest.network.guest_ip,
"-t",

File diff suppressed because it is too large Load Diff

View File

@ -415,7 +415,7 @@ impl Vmm {
}
fn setup_signal_handler(&mut self) -> Result<()> {
let signals = Signals::new(&Self::HANDLED_SIGNALS);
let signals = Signals::new(Self::HANDLED_SIGNALS);
match signals {
Ok(signals) => {
self.signals = Some(signals.handle());

View File

@ -282,9 +282,9 @@ impl Aml for PciDsmMethod {
let uuid = Uuid::parse_str("E5C937D0-3553-4D7A-9117-EA4D19C3434D").unwrap();
let (uuid_d1, uuid_d2, uuid_d3, uuid_d4) = uuid.as_fields();
let mut uuid_buf = vec![];
uuid_buf.extend(&uuid_d1.to_le_bytes());
uuid_buf.extend(&uuid_d2.to_le_bytes());
uuid_buf.extend(&uuid_d3.to_le_bytes());
uuid_buf.extend(uuid_d1.to_le_bytes());
uuid_buf.extend(uuid_d2.to_le_bytes());
uuid_buf.extend(uuid_d3.to_le_bytes());
uuid_buf.extend(uuid_d4);
aml::Method::new(
"_DSM".into(),

View File

@ -2078,7 +2078,7 @@ impl Vm {
fn setup_signal_handler(&mut self) -> Result<()> {
let console = self.device_manager.lock().unwrap().console().clone();
let signals = Signals::new(&Vm::HANDLED_SIGNALS);
let signals = Signals::new(Vm::HANDLED_SIGNALS);
match signals {
Ok(signals) => {
self.signals = Some(signals.handle());
@ -2938,7 +2938,7 @@ impl Transportable for Vm {
self.memory_manager
.lock()
.unwrap()
.send(&*memory_manager_snapshot.clone(), destination_url)?;
.send(&memory_manager_snapshot.clone(), destination_url)?;
} else {
return Err(MigratableError::Restore(anyhow!(
"Missing memory manager snapshot"