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 <heruoqing@iscas.ac.cn>
This commit is contained in:
Ruoqing He 2025-05-26 03:49:00 +00:00
parent 5a95a65604
commit 95dca31ecc

View File

@ -560,11 +560,7 @@ fn build_blk_io_device_throttle_resource(
}
fn linux_device_cgroup_to_device_resource(d: &LinuxDeviceCgroup) -> Option<DeviceResource> {
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<DevicePermissions> = vec![];
for p in d
@ -1324,10 +1320,7 @@ fn default_allowed_devices() -> Vec<DeviceResource> {
/// Convert LinuxDevice to DeviceResource.
fn linux_device_to_device_resource(d: &LinuxDevice) -> Option<DeviceResource> {
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,