Skip to content

Commit a895c9d

Browse files
committed
Fix clippy
Signed-off-by: Maksym Pavlenko <[email protected]>
1 parent 76599aa commit a895c9d

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

hv/src/arm64/mod.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub enum InterruptType {
1515

1616
/// Events that can trigger a guest exit to the VMM.
1717
#[repr(u32)]
18-
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
18+
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq)]
1919
pub enum ExitReason {
2020
/// Asynchronous exit requested explicitly by `hv_vcpus_exit` call.
2121
Canceled = sys::hv_exit_reason_t_HV_EXIT_REASON_CANCELED,
@@ -31,15 +31,10 @@ pub enum ExitReason {
3131
/// the EOI for the guest's VTimer interrupt handler.
3232
VTimerActivated = sys::hv_exit_reason_t_HV_EXIT_REASON_VTIMER_ACTIVATED,
3333
/// Unable to determine exit reason: this should not happen under normal operation.
34+
#[default]
3435
Unknown = sys::hv_exit_reason_t_HV_EXIT_REASON_UNKNOWN,
3536
}
3637

37-
impl Default for ExitReason {
38-
fn default() -> Self {
39-
ExitReason::Unknown
40-
}
41-
}
42-
4338
impl From<sys::hv_exit_reason_t> for ExitReason {
4439
fn from(value: sys::hv_exit_reason_t) -> Self {
4540
match value {

hv/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl fmt::Display for Error {
7070
Error::NoResources => write!(f, "The operation was unsuccessful because the host had no resources available to complete the request"),
7171
Error::NoDevice => write!(f, "The operation was unsuccessful because no VM or vCPU was available"),
7272
Error::Unsupported => write!(f, "The operation requested isn’t supported by the hypervisor"),
73-
Error::Unknown(code) => write!(f, "Error code: {}", *code as i32),
73+
Error::Unknown(code) => write!(f, "Error code: {}", *code),
7474
}
7575
}
7676
}

hv/src/vm.rs

+6
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,16 @@ impl Vm {
3131
/// In order to create child objects (`Vcpu`, `Space`, etc), this object must be wrapped
3232
/// with [Arc].
3333
///
34+
#[allow(clippy::not_unsafe_ptr_arg_deref)]
3435
pub fn new(options: Options) -> Result<Vm, Error> {
3536
#[cfg(target_arch = "x86_64")]
3637
let options = options.bits();
3738

39+
#[cfg(not(target_arch = "x86_64"))]
40+
if options.is_null() {
41+
return Err(Error::BadArgument);
42+
}
43+
3844
call!(sys::hv_vm_create(options))?;
3945
Ok(Vm)
4046
}

0 commit comments

Comments
 (0)