Skip to content

Commit

Permalink
xen: fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Wenzel committed Feb 21, 2024
1 parent 97e36fa commit 24e2bf1
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions src/driver/xen.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::convert::Infallible;
use std::convert::TryInto;
use std::error::Error;
use std::io::Error as IoError;
use std::io::ErrorKind;
Expand Down Expand Up @@ -212,9 +211,7 @@ impl Introspectable for Xen {
.xc
.domain_getinfo(self.domid)
.map_err(XenDriverError::from)?;
Ok((domain_info.max_vcpu_id + 1)
.try_into()
.map_err(XenDriverError::from)?)
Ok((domain_info.unwrap().max_vcpu_id + 1).map_err(XenDriverError::from)?)

Check failure on line 214 in src/driver/xen.rs

View workflow job for this annotation

GitHub Actions / xen

no method named `map_err` found for type `u32` in the current scope
}

fn read_registers(&self, vcpu: u16) -> Result<Registers, Box<dyn Error>> {
Expand Down Expand Up @@ -255,37 +252,37 @@ impl Introspectable for Xen {
cs: SegmentReg {
base: hvm_cpu.cs_base,
limit: hvm_cpu.cs_limit,
selector: hvm_cpu.cs_sel.try_into().map_err(XenDriverError::from)?,
selector: hvm_cpu.cs_sel.into().map_err(XenDriverError::from)?,

Check failure on line 255 in src/driver/xen.rs

View workflow job for this annotation

GitHub Actions / xen

type annotations needed
},
ds: SegmentReg {
base: hvm_cpu.ds_base,
limit: hvm_cpu.ds_limit,
selector: hvm_cpu.ds_sel.try_into().map_err(XenDriverError::from)?,
selector: hvm_cpu.ds_sel.into().map_err(XenDriverError::from)?,
},
es: SegmentReg {
base: hvm_cpu.es_base,
limit: hvm_cpu.es_limit,
selector: hvm_cpu.es_sel.try_into().map_err(XenDriverError::from)?,
selector: hvm_cpu.es_sel.into().map_err(XenDriverError::from)?,
},
fs: SegmentReg {
base: hvm_cpu.fs_base,
limit: hvm_cpu.fs_limit,
selector: hvm_cpu.fs_sel.try_into().map_err(XenDriverError::from)?,
selector: hvm_cpu.fs_sel.into().map_err(XenDriverError::from)?,
},
gs: SegmentReg {
base: hvm_cpu.gs_base,
limit: hvm_cpu.gs_limit,
selector: hvm_cpu.gs_sel.try_into().map_err(XenDriverError::from)?,
selector: hvm_cpu.gs_sel.into().map_err(XenDriverError::from)?,
},
ss: SegmentReg {
base: hvm_cpu.ss_base,
limit: hvm_cpu.ss_limit,
selector: hvm_cpu.ss_sel.try_into().map_err(XenDriverError::from)?,
selector: hvm_cpu.ss_sel.into().map_err(XenDriverError::from)?,
},
tr: SegmentReg {
base: hvm_cpu.tr_base,
limit: hvm_cpu.tr_limit,
selector: hvm_cpu.tr_sel.try_into().map_err(XenDriverError::from)?,
selector: hvm_cpu.tr_sel.into().map_err(XenDriverError::from)?,
},
idt: SystemTableReg {
base: hvm_cpu.idtr_base,
Expand Down Expand Up @@ -348,44 +345,44 @@ impl Introspectable for Xen {
cpu.cs_sel = x86_registers
.cs
.selector
.try_into()
.into()

Check failure on line 348 in src/driver/xen.rs

View workflow job for this annotation

GitHub Actions / xen

type annotations needed
.map_err(XenDriverError::from)?;
cpu.ds_sel = x86_registers
.ds
.selector
.try_into()
.into()
.map_err(XenDriverError::from)?;
cpu.es_sel = x86_registers
.es
.selector
.try_into()
.into()
.map_err(XenDriverError::from)?;
cpu.fs_sel = x86_registers
.fs
.selector
.try_into()
.into()
.map_err(XenDriverError::from)?;
cpu.gs_sel = x86_registers
.gs
.selector
.try_into()
.into()
.map_err(XenDriverError::from)?;
cpu.ss_sel = x86_registers
.ss
.selector
.try_into()
.into()
.map_err(XenDriverError::from)?;
cpu.tr_sel = x86_registers
.tr
.selector
.try_into()
.into()
.map_err(XenDriverError::from)?;
}
}
self.xc.domain_hvm_setcontext(
self.domid,
buffer,
size.try_into().map_err(XenDriverError::from)?,
size.into().map_err(XenDriverError::from)?,
)?;
Ok(())
}
Expand All @@ -396,17 +393,13 @@ impl Introspectable for Xen {
let mut fds = [fd_struct];
let mut vcpu: u16 = 0;
let mut event_type = unsafe { mem::MaybeUninit::<EventType>::zeroed().assume_init() };
let poll_result = poll(&mut fds, timeout.try_into().map_err(XenDriverError::from)?)?;
let poll_result = poll(&mut fds, timeout.into().map_err(XenDriverError::from)?)?;

Check failure on line 396 in src/driver/xen.rs

View workflow job for this annotation

GitHub Actions / xen

type annotations needed
let mut pending_event_port = -1;
if poll_result == 1 {
pending_event_port = self.xev.xenevtchn_pending().map_err(XenDriverError::from)?;
if pending_event_port != -1 {
self.xev
.xenevtchn_unmask(
pending_event_port
.try_into()
.map_err(XenDriverError::from)?,
)
.xenevtchn_unmask(pending_event_port.into().map_err(XenDriverError::from)?)
.map_err(XenDriverError::from)?;
}
}
Expand Down Expand Up @@ -441,7 +434,7 @@ impl Introspectable for Xen {
}
_ => unimplemented!(),
};
vcpu = req.vcpu_id.try_into().map_err(XenDriverError::from)?;
vcpu = req.vcpu_id.into().map_err(XenDriverError::from)?;
let mut rsp =
unsafe { mem::MaybeUninit::<vm_event_response_t>::zeroed().assume_init() };
rsp.reason = req.reason;
Expand Down

0 comments on commit 24e2bf1

Please sign in to comment.