From 2f27f73e580f5ce9bd04de45c17ffd4fd4955040 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Tue, 11 Oct 2022 16:09:20 +0530 Subject: [PATCH] Use std::io::Result instead of defining new type Directly use std::io::Result instead of redefining it. Signed-off-by: Viresh Kumar --- gpio/src/vhu_gpio.rs | 13 ++++++------- i2c/src/vhu_i2c.rs | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/gpio/src/vhu_gpio.rs b/gpio/src/vhu_gpio.rs index f9f206b..b3984d9 100644 --- a/gpio/src/vhu_gpio.rs +++ b/gpio/src/vhu_gpio.rs @@ -10,7 +10,10 @@ use std::mem::size_of; use std::slice::from_raw_parts; use std::sync::{Arc, RwLock}; use std::thread::{spawn, JoinHandle}; -use std::{convert, io}; +use std::{ + convert, + io::{self, Result as IoResult}, +}; use thiserror::Error as ThisError; use vhost::vhost_user::message::{VhostUserProtocolFeatures, VhostUserVirtioFeatures}; @@ -44,7 +47,6 @@ const REQUEST_QUEUE: u16 = 0; const EVENT_QUEUE: u16 = 1; type Result = std::result::Result; -type VhostUserBackendResult = std::result::Result; #[derive(Copy, Clone, Debug, PartialEq, ThisError)] /// Errors related to vhost-device-gpio-daemon. @@ -416,10 +418,7 @@ impl VhostUserBackendMut dbg!(self.event_idx = enabled); } - fn update_memory( - &mut self, - mem: GuestMemoryAtomic, - ) -> VhostUserBackendResult<()> { + fn update_memory(&mut self, mem: GuestMemoryAtomic) -> IoResult<()> { self.mem = Some(mem); Ok(()) } @@ -430,7 +429,7 @@ impl VhostUserBackendMut evset: EventSet, vrings: &[VringRwLock], _thread_id: usize, - ) -> VhostUserBackendResult { + ) -> IoResult { if evset != EventSet::IN { return Err(Error::HandleEventNotEpollIn.into()); } diff --git a/i2c/src/vhu_i2c.rs b/i2c/src/vhu_i2c.rs index 2d0a472..db45ace 100644 --- a/i2c/src/vhu_i2c.rs +++ b/i2c/src/vhu_i2c.rs @@ -8,7 +8,10 @@ use log::warn; use std::mem::size_of; use std::sync::Arc; -use std::{convert, io}; +use std::{ + convert, + io::{self, Result as IoResult}, +}; use thiserror::Error as ThisError; use vhost::vhost_user::message::{VhostUserProtocolFeatures, VhostUserVirtioFeatures}; @@ -34,7 +37,6 @@ const QUEUE_SIZE: usize = 1024; const NUM_QUEUES: usize = 1; type Result = std::result::Result; -type VhostUserBackendResult = std::result::Result; #[derive(Copy, Clone, Debug, Eq, PartialEq, ThisError)] /// Errors related to vhost-device-i2c daemon. @@ -300,10 +302,7 @@ impl VhostUserBackendMut dbg!(self.event_idx = enabled); } - fn update_memory( - &mut self, - mem: GuestMemoryAtomic, - ) -> VhostUserBackendResult<()> { + fn update_memory(&mut self, mem: GuestMemoryAtomic) -> IoResult<()> { self.mem = Some(mem); Ok(()) } @@ -314,7 +313,7 @@ impl VhostUserBackendMut evset: EventSet, vrings: &[VringRwLock], _thread_id: usize, - ) -> VhostUserBackendResult { + ) -> IoResult { if evset != EventSet::IN { return Err(Error::HandleEventNotEpollIn.into()); }