mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 12:34:31 +00:00
devices: vfio: fix clippy warnings
Fix boxed_local, const_static_lifetime, useless_format, and redundant_closure clippy warnings in the VFIO code. This fixes all clippy warnings except a single instance of let_and_return in VfioPciDevice::keep_fds(), since that code is modified in an upcoming patch. BUG=None TEST=./build_test.py TEST=bin/clippy Change-Id: I548adbc6b92448fc0db82ed72214d73b0eabaf5c Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1822697 Reviewed-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
a7b75c8a21
commit
04a82c7be1
4 changed files with 11 additions and 11 deletions
|
@ -100,8 +100,8 @@ pub struct VfioPciDevice {
|
|||
|
||||
impl VfioPciDevice {
|
||||
/// Constructs a new Vfio Pci device for the give Vfio device
|
||||
pub fn new(device: Box<VfioDevice>) -> Self {
|
||||
let dev = Arc::new(*device);
|
||||
pub fn new(device: VfioDevice) -> Self {
|
||||
let dev = Arc::new(device);
|
||||
let config = VfioPciConfig::new(Arc::clone(&dev));
|
||||
VfioPciDevice {
|
||||
device: dev,
|
||||
|
@ -131,7 +131,7 @@ impl VfioPciDevice {
|
|||
|
||||
impl PciDevice for VfioPciDevice {
|
||||
fn debug_label(&self) -> String {
|
||||
format!("vfio pci device")
|
||||
"vfio pci device".to_string()
|
||||
}
|
||||
|
||||
fn assign_bus_dev(&mut self, bus: u8, device: u8) {
|
||||
|
|
|
@ -78,7 +78,7 @@ impl VfioContainer {
|
|||
.read(true)
|
||||
.write(true)
|
||||
.open("/dev/vfio/vfio")
|
||||
.map_err(|e| VfioError::OpenContainer(e))?;
|
||||
.map_err(VfioError::OpenContainer)?;
|
||||
|
||||
Ok(VfioContainer { container })
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ impl VfioGroup {
|
|||
.read(true)
|
||||
.write(true)
|
||||
.open(Path::new(&group_path))
|
||||
.map_err(|e| VfioError::OpenGroup(e))?;
|
||||
.map_err(VfioError::OpenGroup)?;
|
||||
|
||||
let mut group_status = vfio_group_status {
|
||||
argsz: mem::size_of::<vfio_group_status>() as u32,
|
||||
|
@ -217,7 +217,7 @@ impl VfioGroup {
|
|||
flags: 0,
|
||||
};
|
||||
vm.create_device(&mut vfio_dev)
|
||||
.map_err(|e| VfioError::CreateVfioKvmDevice(e))?;
|
||||
.map_err(VfioError::CreateVfioKvmDevice)?;
|
||||
|
||||
// Safe as we are the owner of vfio_dev.fd which is valid value.
|
||||
let vfio_dev_fd = unsafe { File::from_raw_fd(vfio_dev.fd as i32) };
|
||||
|
|
|
@ -990,7 +990,7 @@ fn create_devices(
|
|||
if cfg.vfio.is_some() {
|
||||
let vfio_path = cfg.vfio.as_ref().unwrap().as_path();
|
||||
let vfiodevice =
|
||||
Box::new(VfioDevice::new(vfio_path, vm, mem.clone()).map_err(Error::CreateVfioDevice)?);
|
||||
VfioDevice::new(vfio_path, vm, mem.clone()).map_err(Error::CreateVfioDevice)?;
|
||||
let vfiopcidevice = Box::new(VfioPciDevice::new(vfiodevice));
|
||||
pci_devices.push((vfiopcidevice, simple_jail(&cfg, "vfio_device.policy")?));
|
||||
}
|
||||
|
|
|
@ -81,10 +81,10 @@ pub const VFIO_DEVICE_FLAGS_PCI: u32 = 2;
|
|||
pub const VFIO_DEVICE_FLAGS_PLATFORM: u32 = 4;
|
||||
pub const VFIO_DEVICE_FLAGS_AMBA: u32 = 8;
|
||||
pub const VFIO_DEVICE_FLAGS_CCW: u32 = 16;
|
||||
pub const VFIO_DEVICE_API_PCI_STRING: &'static [u8; 9usize] = b"vfio-pci\0";
|
||||
pub const VFIO_DEVICE_API_PLATFORM_STRING: &'static [u8; 14usize] = b"vfio-platform\0";
|
||||
pub const VFIO_DEVICE_API_AMBA_STRING: &'static [u8; 10usize] = b"vfio-amba\0";
|
||||
pub const VFIO_DEVICE_API_CCW_STRING: &'static [u8; 9usize] = b"vfio-ccw\0";
|
||||
pub const VFIO_DEVICE_API_PCI_STRING: &[u8; 9usize] = b"vfio-pci\0";
|
||||
pub const VFIO_DEVICE_API_PLATFORM_STRING: &[u8; 14usize] = b"vfio-platform\0";
|
||||
pub const VFIO_DEVICE_API_AMBA_STRING: &[u8; 10usize] = b"vfio-amba\0";
|
||||
pub const VFIO_DEVICE_API_CCW_STRING: &[u8; 9usize] = b"vfio-ccw\0";
|
||||
pub const VFIO_REGION_INFO_FLAG_READ: u32 = 1;
|
||||
pub const VFIO_REGION_INFO_FLAG_WRITE: u32 = 2;
|
||||
pub const VFIO_REGION_INFO_FLAG_MMAP: u32 = 4;
|
||||
|
|
Loading…
Reference in a new issue