Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/fs/cgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ impl Cgroup {
if self.hier.v2() {
create_v2_cgroup(self.hier.root(), &self.path, &self.specified_controllers)
} else {
for subsystem in &self.subsystems {
subsystem.to_controller().create();
}
self.subsystems
.iter()
.try_for_each(|subsystem| subsystem.to_controller().create())?;
Ok(())
}
}
Expand Down
13 changes: 6 additions & 7 deletions src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//

#![allow(clippy::unnecessary_unwrap)]
use log::*;

use std::collections::HashMap;
use std::fmt;
Expand Down Expand Up @@ -265,7 +264,7 @@ pub trait Controller {
fn apply(&self, res: &Resources) -> Result<()>;

/// Create this controller
fn create(&self);
fn create(&self) -> Result<()>;

/// Does this controller already exist?
fn exists(&self) -> bool;
Expand Down Expand Up @@ -323,14 +322,14 @@ where
}

/// Create this controller
fn create(&self) {
fn create(&self) -> Result<()> {
self.verify_path()
.unwrap_or_else(|_| panic!("path should be valid: {:?}", self.path()));

match ::std::fs::create_dir_all(self.get_path()) {
Ok(_) => self.post_create(),
Err(e) => warn!("error create_dir: {:?} error: {:?}", self.get_path(), e),
}
std::fs::create_dir_all(self.get_path())
.map_err(|err| Error::with_cause(ErrorKind::FsError, err))?;
self.post_create();
Ok(())
}

/// Set notify_on_release
Expand Down
2 changes: 1 addition & 1 deletion src/systemd/dbus/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ pub mod tests {
String::from_utf8_lossy(&output.stdout).to_string()
}

fn start_default_cgroup(pid: CgroupPid, unit: &str) -> SystemdClient {
fn start_default_cgroup(pid: CgroupPid, unit: &'_ str) -> SystemdClient<'_> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add a <'_> here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when I usemake check rustc 1.90 clippy put out this warning.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error: could not compile cgroups-rs (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: hiding a lifetime that's elided elsewhere is confusing
--> src/systemd/dbus/client.rs:251:51
|
251 | fn start_default_cgroup(pid: CgroupPid, unit: &str) -> SystemdClient {
| ^^^^ ------------- the same lifetime is hidden here
| |
| the lifetime is elided here
|
= help: the same lifetime is referred to in inconsistent ways, making the signature confusing
= note: -D mismatched-lifetime-syntaxes implied by -D warnings
= help: to override -D warnings add #[allow(mismatched_lifetime_syntaxes)]
help: use '_ for type paths
|
251 | fn start_default_cgroup(pid: CgroupPid, unit: &str) -> SystemdClient<'_> {

let mut props = PropertiesBuilder::default_cgroup(TEST_SLICE, unit).build();
props.push((PIDS, Value::Array(vec![pid.pid as u32].into())));
let cgroup = SystemdClient::new(unit, props).unwrap();
Expand Down
Loading