Skip to content

Commit 763f2f9

Browse files
committed
refactor: remove std::result::Result usage
We have a convention of not referring to Result type with full path since it is implicitly added to all namespaces. Additionally remove Result type redefinitions as we don't allow this. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent f335a0a commit 763f2f9

File tree

18 files changed

+19
-30
lines changed

18 files changed

+19
-30
lines changed

src/firecracker/src/api_server/parsed_request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl ParsedRequest {
157157
}
158158

159159
pub(crate) fn convert_to_response(
160-
request_outcome: &std::result::Result<VmmData, VmmActionError>,
160+
request_outcome: &Result<VmmData, VmmActionError>,
161161
) -> Response {
162162
match request_outcome {
163163
Ok(vmm_data) => match vmm_data {

src/jailer/src/cgroup.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ pub mod test_util {
522522
pub fn create_file_with_contents<P: AsRef<Path> + Debug>(
523523
filename: P,
524524
contents: &str,
525-
) -> std::result::Result<(), std::io::Error> {
525+
) -> Result<(), std::io::Error> {
526526
let mut file = OpenOptions::new()
527527
.read(true)
528528
.write(true)
@@ -534,7 +534,7 @@ pub mod test_util {
534534
Ok(())
535535
}
536536

537-
pub fn new() -> std::result::Result<MockCgroupFs, std::io::Error> {
537+
pub fn new() -> Result<MockCgroupFs, std::io::Error> {
538538
let mock_jailer_dir = TempDir::new().unwrap();
539539
let mock_proc_mounts = mock_jailer_dir.as_path().join("proc/mounts");
540540
let mock_sys_cgroups = mock_jailer_dir.as_path().join("sys_cgroup");
@@ -557,7 +557,7 @@ pub mod test_util {
557557

558558
// Populate the mocked proc/mounts file with cgroupv2 entries
559559
// Also create a directory structure that simulates cgroupsv2 layout
560-
pub fn add_v2_mounts(&mut self) -> std::result::Result<(), std::io::Error> {
560+
pub fn add_v2_mounts(&mut self) -> Result<(), std::io::Error> {
561561
writeln!(
562562
self.mounts_file,
563563
"cgroupv2 {}/unified cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelegate 0 0",
@@ -574,7 +574,7 @@ pub mod test_util {
574574
}
575575

576576
// Populate the mocked proc/mounts file with cgroupv1 entries
577-
pub fn add_v1_mounts(&mut self) -> std::result::Result<(), std::io::Error> {
577+
pub fn add_v1_mounts(&mut self) -> Result<(), std::io::Error> {
578578
let controllers = vec![
579579
"memory",
580580
"net_cls,net_prio",
@@ -610,7 +610,7 @@ mod tests {
610610
use crate::cgroup::test_util::MockCgroupFs;
611611

612612
// Utility function to read the first line in a file
613-
fn read_first_line<P>(filename: P) -> std::result::Result<String, std::io::Error>
613+
fn read_first_line<P>(filename: P) -> Result<String, std::io::Error>
614614
where
615615
P: AsRef<Path> + Debug,
616616
{

src/vmm/src/device_manager/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ impl<'a> Persist<'a> for DeviceManager {
471471
fn restore(
472472
constructor_args: Self::ConstructorArgs,
473473
state: &Self::State,
474-
) -> std::result::Result<Self, Self::Error> {
474+
) -> Result<Self, Self::Error> {
475475
// Setup legacy devices in case of x86
476476
#[cfg(target_arch = "x86_64")]
477477
let legacy_devices = Self::create_legacy_devices(

src/vmm/src/device_manager/pci_mngr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ impl<'a> Persist<'a> for PciDevices {
396396
fn restore(
397397
constructor_args: Self::ConstructorArgs,
398398
state: &Self::State,
399-
) -> std::result::Result<Self, Self::Error> {
399+
) -> Result<Self, Self::Error> {
400400
let mem = constructor_args.mem;
401401
let mut pci_devices = PciDevices::new();
402402
if !state.pci_enabled {

src/vmm/src/device_manager/persist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl<'a> Persist<'a> for ACPIDeviceManager {
193193
fn restore(
194194
constructor_args: Self::ConstructorArgs,
195195
state: &Self::State,
196-
) -> std::result::Result<Self, Self::Error> {
196+
) -> Result<Self, Self::Error> {
197197
let mut dev_manager = ACPIDeviceManager::new();
198198
if let Some(vmgenid_args) = &state.vmgenid {
199199
let vmgenid = VmGenId::restore(

src/vmm/src/devices/acpi/vmgenid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl<'a> Persist<'a> for VmGenId {
151151
fn restore(
152152
constructor_args: Self::ConstructorArgs,
153153
state: &Self::State,
154-
) -> std::result::Result<Self, Self::Error> {
154+
) -> Result<Self, Self::Error> {
155155
Self::from_parts(GuestAddress(state.addr), state.gsi, constructor_args.mem)
156156
}
157157
}

src/vmm/src/devices/virtio/transport/pci/device.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ pub enum VirtioPciDeviceError {
255255
/// Error creating MSI configuration: {0}
256256
Msi(#[from] InterruptError),
257257
}
258-
pub type Result<T> = std::result::Result<T, VirtioPciDeviceError>;
259258

260259
pub struct VirtioPciDevice {
261260
id: String,
@@ -370,7 +369,7 @@ impl VirtioPciDevice {
370369
device: Arc<Mutex<dyn VirtioDevice>>,
371370
msix_vectors: Arc<MsixVectorGroup>,
372371
pci_device_bdf: u32,
373-
) -> Result<Self> {
372+
) -> Result<Self, VirtioPciDeviceError> {
374373
let num_queues = device.lock().expect("Poisoned lock").queues().len();
375374

376375
let msix_config = Arc::new(Mutex::new(MsixConfig::new(
@@ -419,7 +418,7 @@ impl VirtioPciDevice {
419418
vm: &Arc<Vm>,
420419
device: Arc<Mutex<dyn VirtioDevice>>,
421420
state: VirtioPciDeviceState,
422-
) -> Result<Self> {
421+
) -> Result<Self, VirtioPciDeviceError> {
423422
let msix_config =
424423
MsixConfig::from_state(state.msix_state, vm.clone(), state.pci_device_bdf.into())?;
425424
let vectors = msix_config.vectors.clone();
@@ -603,7 +602,7 @@ impl VirtioPciDevice {
603602
}
604603

605604
/// Register the IoEvent notification for a VirtIO device
606-
pub fn register_notification_ioevent(&self, vm: &Vm) -> std::result::Result<(), errno::Error> {
605+
pub fn register_notification_ioevent(&self, vm: &Vm) -> Result<(), errno::Error> {
607606
let bar_addr = self.config_bar_addr();
608607
for (i, queue_evt) in self
609608
.device
@@ -676,7 +675,7 @@ impl VirtioInterruptMsix {
676675
}
677676

678677
impl VirtioInterrupt for VirtioInterruptMsix {
679-
fn trigger(&self, int_type: VirtioInterruptType) -> std::result::Result<(), InterruptError> {
678+
fn trigger(&self, int_type: VirtioInterruptType) -> Result<(), InterruptError> {
680679
let vector = match int_type {
681680
VirtioInterruptType::Config => self.config_vector.load(Ordering::Acquire),
682681
VirtioInterruptType::Queue(queue_index) => *self
@@ -783,7 +782,7 @@ impl PciDevice for VirtioPciDevice {
783782
self.configuration.detect_bar_reprogramming(reg_idx, data)
784783
}
785784

786-
fn move_bar(&mut self, old_base: u64, new_base: u64) -> std::result::Result<(), anyhow::Error> {
785+
fn move_bar(&mut self, old_base: u64, new_base: u64) -> Result<(), anyhow::Error> {
787786
// We only update our idea of the bar in order to support free_bars() above.
788787
// The majority of the reallocation is done inside DeviceManager.
789788
if self.bar_address == old_base {

src/vmm/src/dumbo/pdu/arp.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use std::convert::From;
1111
use std::fmt::Debug;
1212
use std::net::Ipv4Addr;
13-
use std::result::Result;
1413

1514
use super::bytes::{InnerBytes, NetworkBytes, NetworkBytesMut};
1615
use super::ethernet::{self, ETHERTYPE_IPV4};

src/vmm/src/dumbo/pdu/ethernet.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//! 802.1Q tags.
66
77
use std::fmt::Debug;
8-
use std::result::Result;
98

109
use super::Incomplete;
1110
use super::bytes::{InnerBytes, NetworkBytes, NetworkBytesMut};

src/vmm/src/dumbo/pdu/ipv4.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use std::convert::From;
1111
use std::fmt::Debug;
1212
use std::net::Ipv4Addr;
13-
use std::result::Result;
1413

1514
use crate::dumbo::pdu::bytes::{InnerBytes, NetworkBytes, NetworkBytesMut};
1615
use crate::dumbo::pdu::{Incomplete, ethernet};

0 commit comments

Comments
 (0)