diff --git a/src/devices.rs b/src/devices.rs index 1cd1ea8..75c2c5c 100644 --- a/src/devices.rs +++ b/src/devices.rs @@ -49,6 +49,7 @@ impl Default for DeviceType { impl DeviceType { /// Convert a DeviceType into the character that the kernel recognizes. + #[allow(clippy::should_implement_trait, clippy::wrong_self_convention)] pub fn to_char(&self) -> char { match self { DeviceType::All => 'a', @@ -82,6 +83,7 @@ pub enum DevicePermissions { impl DevicePermissions { /// Convert a DevicePermissions into the character that the kernel recognizes. + #[allow(clippy::should_implement_trait, clippy::wrong_self_convention)] pub fn to_char(&self) -> char { match self { DevicePermissions::Read => 'r', diff --git a/src/lib.rs b/src/lib.rs index b8b2385..880e9cf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -738,6 +738,7 @@ impl Default for MaxValue { } impl MaxValue { + #[allow(clippy::should_implement_trait, clippy::wrong_self_convention)] fn to_i64(&self) -> i64 { match self { MaxValue::Max => -1, diff --git a/tests/cpuset.rs b/tests/cpuset.rs index 44e525e..76e5308 100644 --- a/tests/cpuset.rs +++ b/tests/cpuset.rs @@ -36,12 +36,12 @@ fn test_cpuset_set_cpus() { assert_eq!(0, set.cpus.len()); } else { // for cgroup v1, cpuset is copied from parent. - assert_eq!(true, !set.cpus.is_empty()); + assert!(!set.cpus.is_empty()); } // 0 let r = cpuset.set_cpus("0"); - assert_eq!(true, r.is_ok()); + assert!(r.is_ok()); let set = cpuset.cpuset(); assert_eq!(1, set.cpus.len()); @@ -52,7 +52,7 @@ fn test_cpuset_set_cpus() { let cpus = cpus.trim(); if !cpus.is_empty() { let r = cpuset.set_cpus(&cpus); - assert_eq!(true, r.is_ok()); + assert!(r.is_ok()); let set = cpuset.cpuset(); assert_eq!(1, set.cpus.len()); assert_eq!(format!("{}-{}", set.cpus[0].0, set.cpus[0].1), cpus); @@ -72,14 +72,14 @@ fn test_cpuset_set_cpus_add_task() { assert_eq!(0, set.cpus.len()); } else { // for cgroup v1, cpuset is copied from parent. - assert_eq!(true, !set.cpus.is_empty()); + assert!(!set.cpus.is_empty()); } // Add a task to the control group. let pid_i = libc::pid_t::from(nix::unistd::getpid()) as u64; let _ = cg.add_task(CgroupPid::from(pid_i)); let tasks = cg.tasks(); - assert_eq!(true, !tasks.is_empty()); + assert!(!tasks.is_empty()); println!("tasks after added: {:?}", tasks); // remove task diff --git a/tests/hugetlb.rs b/tests/hugetlb.rs index cc33e28..1301435 100644 --- a/tests/hugetlb.rs +++ b/tests/hugetlb.rs @@ -29,7 +29,7 @@ fn test_hugetlb_sizes() { for size in sizes { let supported = hugetlb_controller.size_supported(&size); - assert_eq!(supported, true); + assert!(supported); assert_no_error(hugetlb_controller.failcnt(&size)); assert_no_error(hugetlb_controller.limit_in_bytes(&size)); assert_no_error(hugetlb_controller.usage_in_bytes(&size)); @@ -40,5 +40,5 @@ fn test_hugetlb_sizes() { } fn assert_no_error(r: Result) { - assert_eq!(!r.is_err(), true) + assert!(!r.is_err()) } diff --git a/tests/memory.rs b/tests/memory.rs index 9ab2e01..a2951aa 100644 --- a/tests/memory.rs +++ b/tests/memory.rs @@ -17,17 +17,17 @@ fn test_disable_oom_killer() { // before disable let m = mem_controller.memory_stat(); - assert_eq!(m.oom_control.oom_kill_disable, false); + assert!(!m.oom_control.oom_kill_disable); // now only v1 if !mem_controller.v2() { // disable oom killer let r = mem_controller.disable_oom_killer(); - assert_eq!(r.is_err(), false); + assert!(!r.is_err()); // after disable let m = mem_controller.memory_stat(); - assert_eq!(m.oom_control.oom_kill_disable, true); + assert!(m.oom_control.oom_kill_disable); } } cg.delete().unwrap(); @@ -60,7 +60,7 @@ fn set_mem_v2() { max: None, }; let r = mem_controller.set_mem(m); - assert_eq!(true, r.is_ok()); + assert!(r.is_ok()); let m = mem_controller.get_mem().unwrap(); // get @@ -77,7 +77,7 @@ fn set_mem_v2() { low: None, }; let r = mem_controller.set_mem(m); - assert_eq!(true, r.is_ok()); + assert!(r.is_ok()); let m = mem_controller.get_mem().unwrap(); // get diff --git a/tests/resources.rs b/tests/resources.rs index 056349e..801890a 100644 --- a/tests/resources.rs +++ b/tests/resources.rs @@ -24,7 +24,7 @@ fn pid_resources() { // verify let pidcontroller: &PidController = cg.controller_of().unwrap(); let pid_max = pidcontroller.get_pid_max(); - assert_eq!(pid_max.is_ok(), true); + assert!(pid_max.is_ok()); assert_eq!(pid_max.unwrap(), MaxValue::Value(512)); } cg.delete().unwrap();