Skip to content

Commit

Permalink
Fix clippy errors
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Fanelli <tfanelli@redhat.com>
  • Loading branch information
tylerfanelli committed Nov 19, 2023
1 parent 5285813 commit 72f987c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/devices/src/bus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl Ord for BusRange {

impl PartialOrd for BusRange {
fn partial_cmp(&self, other: &BusRange) -> Option<Ordering> {
self.0.partial_cmp(&other.0)
Some(self.cmp(other))
}
}

Expand Down
15 changes: 9 additions & 6 deletions src/libkrun/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::env;
use std::ffi::CStr;
#[cfg(target_os = "linux")]
use std::ffi::CString;
use std::fmt::Write;
#[cfg(feature = "net")]
use std::os::fd::RawFd;
#[cfg(not(feature = "tee"))]
Expand Down Expand Up @@ -677,9 +678,10 @@ pub unsafe extern "C" fn krun_set_exec(
}
}
} else {
env::vars()
.map(|(key, value)| format!(" {key}=\"{value}\""))
.collect()
env::vars().fold(String::new(), |mut output, (key, value)| {
let _ = write!(output, " {key}=\"{value}\"");
key
})
};

match CTX_MAP.lock().unwrap().entry(ctx_id) {
Expand Down Expand Up @@ -708,9 +710,10 @@ pub unsafe extern "C" fn krun_set_env(ctx_id: u32, c_envp: *const *const c_char)
}
}
} else {
env::vars()
.map(|(key, value)| format!(" {key}=\"{value}\""))
.collect()
env::vars().fold(String::new(), |mut output, (key, value)| {
let _ = write!(output, " {key}=\"{value}\"");
key
})
};

match CTX_MAP.lock().unwrap().entry(ctx_id) {
Expand Down
6 changes: 3 additions & 3 deletions src/vmm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ pub fn build_microvm(
};

#[cfg(not(feature = "tee"))]
let mut vm = setup_vm(&guest_memory)?;
let vm = setup_vm(&guest_memory)?;

#[cfg(feature = "tee")]
let (kvm, mut vm) = {
Expand Down Expand Up @@ -482,7 +482,7 @@ pub fn build_microvm(
// while on aarch64 we need to do it the other way around.
#[cfg(target_arch = "x86_64")]
{
setup_interrupt_controller(&mut vm)?;
setup_interrupt_controller(&vm)?;
attach_legacy_devices(&vm, &mut pio_device_manager)?;

vcpus = create_vcpus_x86_64(
Expand Down Expand Up @@ -795,7 +795,7 @@ pub(crate) fn setup_vm(

/// Sets up the irqchip for a x86_64 microVM.
#[cfg(target_arch = "x86_64")]
pub fn setup_interrupt_controller(vm: &mut Vm) -> std::result::Result<(), StartMicrovmError> {
pub fn setup_interrupt_controller(vm: &Vm) -> std::result::Result<(), StartMicrovmError> {
vm.setup_irqchip()
.map_err(Error::Vm)
.map_err(StartMicrovmError::Internal)
Expand Down

0 comments on commit 72f987c

Please sign in to comment.