From 95dca31ecccb5e6d3b1b152bb8c4c5d88c743fac Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Mon, 26 May 2025 03:49:00 +0000 Subject: [PATCH] agent: Fix clippy `question_mark` Fix `question_mark` clippy warning as suggested by rust 1.85.1. ```console warning: this `match` expression can be replaced with `?` --> rustjail/src/cgroups/fs/mod.rs:1327:20 | 1327 | let dev_type = match DeviceType::from_char(d.typ().as_str().chars().next()) { | ____________________^ 1328 | | Some(t) => t, 1329 | | None => return None, 1330 | | }; | |_____^ help: try instead: `DeviceType::from_char(d.typ().as_str().chars().next())?` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark ``` Signed-off-by: Ruoqing He --- src/agent/rustjail/src/cgroups/fs/mod.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/agent/rustjail/src/cgroups/fs/mod.rs b/src/agent/rustjail/src/cgroups/fs/mod.rs index e43662ff70..cc7801f0d1 100644 --- a/src/agent/rustjail/src/cgroups/fs/mod.rs +++ b/src/agent/rustjail/src/cgroups/fs/mod.rs @@ -560,11 +560,7 @@ fn build_blk_io_device_throttle_resource( } fn linux_device_cgroup_to_device_resource(d: &LinuxDeviceCgroup) -> Option { - let dev_type = match DeviceType::from_char(d.typ().unwrap_or_default().as_str().chars().next()) - { - Some(t) => t, - None => return None, - }; + let dev_type = DeviceType::from_char(d.typ().unwrap_or_default().as_str().chars().next())?; let mut permissions: Vec = vec![]; for p in d @@ -1324,10 +1320,7 @@ fn default_allowed_devices() -> Vec { /// Convert LinuxDevice to DeviceResource. fn linux_device_to_device_resource(d: &LinuxDevice) -> Option { - let dev_type = match DeviceType::from_char(d.typ().as_str().chars().next()) { - Some(t) => t, - None => return None, - }; + let dev_type = DeviceType::from_char(d.typ().as_str().chars().next())?; let permissions = vec![ DevicePermissions::Read,