Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Furisto <24721048+Furisto@users.noreply.github.com>
  • Loading branch information
Furisto committed Mar 2, 2022
1 parent 39c93db commit 1d3c60f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 20 deletions.
4 changes: 2 additions & 2 deletions crates/integration_test/src/tests/cgroups/blkio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ fn supports_throttle_iops() -> bool {

fn parse_device_data<'a>(device_type: &'static str, line: &'a str) -> Result<(i64, i64, &'a str)> {
let (device_id, value) = line
.split_once(" ")
.split_once(' ')
.with_context(|| format!("invalid {} device format : found {}", device_type, line))?;
let (major_str, minor_str) = device_id.split_once(":").with_context(|| {
let (major_str, minor_str) = device_id.split_once(':').with_context(|| {
format!(
"invalid major-minor number format for {} device : found {}",
device_type, device_id
Expand Down
4 changes: 2 additions & 2 deletions crates/integration_test/src/utils/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub fn get_state<P: AsRef<Path>>(id: &str, dir: P) -> Result<(String, String)> {
sleep(SLEEP_TIME);
let output = runtime_command(dir)
.arg("state")
.arg(id.to_string())
.arg(id)
.spawn()
.context("could not get container state")?
.wait_with_output()
Expand All @@ -99,7 +99,7 @@ pub fn get_state<P: AsRef<Path>>(id: &str, dir: P) -> Result<(String, String)> {
pub fn start_container<P: AsRef<Path>>(id: &str, dir: P) -> Result<Child> {
let res = runtime_command(dir)
.arg("start")
.arg(id.to_string())
.arg(id)
.spawn()
.context("could not start container")?;
Ok(res)
Expand Down
2 changes: 1 addition & 1 deletion crates/libcgroups/src/v2/unified.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Unified {
common::write_cgroup_file_str(cgroup_path.join(cgroup_file), value).map_err(
|e| {
let (subsystem, _) = cgroup_file
.split_once(".")
.split_once('.')
.with_context(|| {
format!("failed to split {} with {}", cgroup_file, ".")
})
Expand Down
2 changes: 1 addition & 1 deletion crates/libcontainer/src/process/container_init_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::{
fn sysctl(kernel_params: &HashMap<String, String>) -> Result<()> {
let sys = PathBuf::from("/proc/sys");
for (kernel_param, value) in kernel_params {
let path = sys.join(kernel_param.replace(".", "/"));
let path = sys.join(kernel_param.replace('.', "/"));
log::debug!(
"apply value {} to kernel parameter {}.",
value,
Expand Down
13 changes: 4 additions & 9 deletions crates/libcontainer/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,10 @@ pub fn secure_join<P: Into<PathBuf>>(rootfs: P, unsafe_path: P) -> Result<PathBu
bail!("dereference too many symlinks, may be infinite loop");
}

let part_path;
match part.next() {
Some(part) => {
part_path = PathBuf::from(part);
}
None => {
break;
}
}
let part_path = match part.next() {
None => break,
Some(part) => PathBuf::from(part),
};

if !part_path.is_absolute() {
if part_path.starts_with("..") {
Expand Down
9 changes: 4 additions & 5 deletions crates/test_framework/src/test_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ impl<'a> TestManager<'a> {
let mut collector = Vec::with_capacity(tests.len());
for (test_group_name, tests) in &tests {
if let Some(tg) = self.test_groups.get(test_group_name) {
let r;
match tests {
None => r = s.spawn(move |_| tg.run_all()),
Some(tests) => r = s.spawn(move |_| tg.run_selected(tests)),
}
let r = match tests {
None => s.spawn(move |_| tg.run_all()),
Some(tests) => s.spawn(move |_| tg.run_selected(tests)),
};
collector.push((test_group_name, r));
} else {
eprintln!("Error : Test Group {} not found, skipping", test_group_name);
Expand Down

0 comments on commit 1d3c60f

Please sign in to comment.