mirror of
https://github.com/kata-containers/cgroups-rs.git
synced 2026-08-05 02:13:23 +00:00
clippy: Fix clippy version 0.1.60
Fix clippy lints from clippy 0.1.60 (7737e0b 2022-04-04). Signed-off-by: Felix Obenhuber <felix@obenhuber.de>
This commit is contained in:
+1
-1
@@ -295,7 +295,7 @@ fn parse_cfs_quota_and_period(mut file: File) -> Result<CfsQuotaAndPeriod> {
|
|||||||
return Err(Error::from_string(format!("invaild format: {}", content)));
|
return Err(Error::from_string(format!("invaild format: {}", content)));
|
||||||
}
|
}
|
||||||
|
|
||||||
let quota = parse_max_value(&fields[0].to_string())?;
|
let quota = parse_max_value(fields[0])?;
|
||||||
let period = fields[1]
|
let period = fields[1]
|
||||||
.parse::<u64>()
|
.parse::<u64>()
|
||||||
.map_err(|e| Error::with_cause(ParseError, e))?;
|
.map_err(|e| Error::with_cause(ParseError, e))?;
|
||||||
|
|||||||
+4
-5
@@ -52,12 +52,11 @@ fn register_memory_event(
|
|||||||
eventfd(0, EfdFlags::EFD_CLOEXEC).map_err(|e| Error::with_cause(ReadFailed, e))?;
|
eventfd(0, EfdFlags::EFD_CLOEXEC).map_err(|e| Error::with_cause(ReadFailed, e))?;
|
||||||
|
|
||||||
let event_control_path = cg_dir.join("cgroup.event_control");
|
let event_control_path = cg_dir.join("cgroup.event_control");
|
||||||
let data;
|
let data = if arg.is_empty() {
|
||||||
if arg.is_empty() {
|
format!("{} {}", eventfd, event_file.as_raw_fd())
|
||||||
data = format!("{} {}", eventfd, event_file.as_raw_fd());
|
|
||||||
} else {
|
} else {
|
||||||
data = format!("{} {} {}", eventfd, event_file.as_raw_fd(), arg);
|
format!("{} {} {}", eventfd, event_file.as_raw_fd(), arg)
|
||||||
}
|
};
|
||||||
|
|
||||||
// write to file and set mode to 0700(FIXME)
|
// write to file and set mode to 0700(FIXME)
|
||||||
fs::write(&event_control_path, data).map_err(|e| Error::with_cause(WriteFailed, e))?;
|
fs::write(&event_control_path, data).map_err(|e| Error::with_cause(WriteFailed, e))?;
|
||||||
|
|||||||
+2
-2
@@ -170,7 +170,7 @@ impl Hierarchy for V1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn root_control_group(&self) -> Cgroup {
|
fn root_control_group(&self) -> Cgroup {
|
||||||
Cgroup::load(auto(), "".to_string())
|
Cgroup::load(auto(), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn root(&self) -> PathBuf {
|
fn root(&self) -> PathBuf {
|
||||||
@@ -246,7 +246,7 @@ impl Hierarchy for V2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn root_control_group(&self) -> Cgroup {
|
fn root_control_group(&self) -> Cgroup {
|
||||||
Cgroup::load(auto(), "".to_string())
|
Cgroup::load(auto(), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn root(&self) -> PathBuf {
|
fn root(&self) -> PathBuf {
|
||||||
|
|||||||
+1
-1
@@ -771,7 +771,7 @@ impl fmt::Display for MaxValue {
|
|||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
MaxValue::Max => write!(f, "max"),
|
MaxValue::Max => write!(f, "max"),
|
||||||
MaxValue::Value(num) => write!(f, "{}", num.to_string()),
|
MaxValue::Value(num) => write!(f, "{}", num),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -17,7 +17,7 @@ use crate::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subs
|
|||||||
pub struct SystemdController {
|
pub struct SystemdController {
|
||||||
base: PathBuf,
|
base: PathBuf,
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
v2: bool,
|
_v2: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ControllerInternal for SystemdController {
|
impl ControllerInternal for SystemdController {
|
||||||
@@ -66,7 +66,7 @@ impl SystemdController {
|
|||||||
Self {
|
Self {
|
||||||
base: root.clone(),
|
base: root.clone(),
|
||||||
path: root,
|
path: root,
|
||||||
v2,
|
_v2: v2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-5
@@ -137,11 +137,8 @@ pub fn test_hugepages_res_build() {
|
|||||||
|
|
||||||
{
|
{
|
||||||
let c: &HugeTlbController = cg.controller_of().unwrap();
|
let c: &HugeTlbController = cg.controller_of().unwrap();
|
||||||
assert!(c.limit_in_bytes(&"2MB".to_string()).is_ok());
|
assert!(c.limit_in_bytes("2MB").is_ok());
|
||||||
assert_eq!(
|
assert_eq!(c.limit_in_bytes("2MB").unwrap(), 4 * 2 * 1024 * 1024);
|
||||||
c.limit_in_bytes(&"2MB".to_string()).unwrap(),
|
|
||||||
4 * 2 * 1024 * 1024
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
cg.delete().unwrap();
|
cg.delete().unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -40,5 +40,5 @@ fn test_hugetlb_sizes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn assert_no_error(r: Result<u64>) {
|
fn assert_no_error(r: Result<u64>) {
|
||||||
assert!(!r.is_err())
|
assert!(r.is_ok())
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ fn test_disable_oom_killer() {
|
|||||||
if !mem_controller.v2() {
|
if !mem_controller.v2() {
|
||||||
// disable oom killer
|
// disable oom killer
|
||||||
let r = mem_controller.disable_oom_killer();
|
let r = mem_controller.disable_oom_killer();
|
||||||
assert!(!r.is_err());
|
assert!(r.is_ok());
|
||||||
|
|
||||||
// after disable
|
// after disable
|
||||||
let m = mem_controller.memory_stat();
|
let m = mem_controller.memory_stat();
|
||||||
|
|||||||
Reference in New Issue
Block a user