69 lines
2.2 KiB
Diff
69 lines
2.2 KiB
Diff
|
|
From a01bde892736601aa57a2780e45b00cdb842dc16 Mon Sep 17 00:00:00 2001
|
||
|
|
From: chenjiayi <chenjiayi22@huawei.com>
|
||
|
|
Date: Thu, 16 Nov 2023 10:05:37 +0800
|
||
|
|
Subject: [PATCH 065/103] refactor(devmaster): compress unnecessary code
|
||
|
|
|
||
|
|
Eliminate unnecessary code for error handling.
|
||
|
|
---
|
||
|
|
.../src/lib/framework/uevent_monitor.rs | 32 ++++---------------
|
||
|
|
1 file changed, 6 insertions(+), 26 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/exts/devmaster/src/lib/framework/uevent_monitor.rs b/exts/devmaster/src/lib/framework/uevent_monitor.rs
|
||
|
|
index 809071d1..30bbd570 100644
|
||
|
|
--- a/exts/devmaster/src/lib/framework/uevent_monitor.rs
|
||
|
|
+++ b/exts/devmaster/src/lib/framework/uevent_monitor.rs
|
||
|
|
@@ -12,12 +12,9 @@
|
||
|
|
|
||
|
|
//! uevent_monitor
|
||
|
|
//!
|
||
|
|
-use crate::error::*;
|
||
|
|
use crate::framework::job_queue::JobQueue;
|
||
|
|
use device::device_monitor::{DeviceMonitor, MonitorNetlinkGroup};
|
||
|
|
use event::{EventType, Events, Source};
|
||
|
|
-use nix::errno::Errno;
|
||
|
|
-use snafu::ResultExt;
|
||
|
|
use std::os::unix::io::RawFd;
|
||
|
|
use std::rc::Rc;
|
||
|
|
|
||
|
|
@@ -71,31 +68,14 @@ impl Source for UeventMonitor {
|
||
|
|
fn dispatch(&self, _: &Events) -> i32 {
|
||
|
|
let device = match self.device_monitor.receive_device() {
|
||
|
|
Ok(ret) => ret,
|
||
|
|
- Err(e) => match e {
|
||
|
|
- device::error::Error::Nix {
|
||
|
|
- msg: _,
|
||
|
|
- source: Errno::EAGAIN,
|
||
|
|
- } => {
|
||
|
|
- return 0;
|
||
|
|
- }
|
||
|
|
- device::error::Error::Nix { msg: _, source: _ } => {
|
||
|
|
- log::error!("{}", e);
|
||
|
|
- return 0;
|
||
|
|
- }
|
||
|
|
- _ => {
|
||
|
|
- return 0;
|
||
|
|
- }
|
||
|
|
- },
|
||
|
|
+ Err(e) => {
|
||
|
|
+ log::error!("Monitor Error: {}", e);
|
||
|
|
+ return 0;
|
||
|
|
+ }
|
||
|
|
};
|
||
|
|
|
||
|
|
- log::debug!(
|
||
|
|
- "Monitor: received device {}",
|
||
|
|
- device
|
||
|
|
- .get_devpath()
|
||
|
|
- .context(DeviceSnafu)
|
||
|
|
- .log_error("uevent has no devpath")
|
||
|
|
- .unwrap_or_default()
|
||
|
|
- );
|
||
|
|
+ /* The devpath is guaranteed to be valid. */
|
||
|
|
+ log::debug!("Monitor: received device {}", device.get_devpath().unwrap());
|
||
|
|
|
||
|
|
self.job_queue.job_queue_insert(device);
|
||
|
|
0
|
||
|
|
--
|
||
|
|
2.33.0
|
||
|
|
|