Skip to content

Commit

Permalink
rust-agent: Remove 'mut' where not needed
Browse files Browse the repository at this point in the history
Addresses the following warning (and a few similar ones):
    warning: variable does not need to be mutable
       --> rustjail/src/container.rs:369:9
        |
    369 |     let mut oci_process: oci::Process = serde_json::from_str(process_str)?;
        |         ----^^^^^^^^^^^
        |         |
        |         help: remove this `mut`
        |
        = note: `#[warn(unused_mut)]` on by default

Fixes: #750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
  • Loading branch information
c3d committed Oct 7, 2020
1 parent c8f406d commit ec24f68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/agent/rustjail/src/cgroups/fs/mod.rs
Expand Up @@ -468,7 +468,7 @@ fn build_blk_io_device_throttle_resource(
fn linux_device_to_cgroup_device(d: &LinuxDevice) -> DeviceResource {
let dev_type = DeviceType::from_char(d.r#type.chars().next()).unwrap();

let mut permissions = vec![
let permissions = vec![
DevicePermissions::Read,
DevicePermissions::Write,
DevicePermissions::MkNod,
Expand Down Expand Up @@ -518,7 +518,7 @@ fn lines_to_map(content: &str) -> HashMap<String, u64> {
.lines()
.map(|x| x.split_whitespace().collect::<Vec<&str>>())
.filter(|x| x.len() == 2 && x[1].parse::<u64>().is_ok())
.fold(HashMap::new(), |mut hm, mut x| {
.fold(HashMap::new(), |mut hm, x| {
hm.insert(x[0].to_string(), x[1].parse::<u64>().unwrap());
hm
})
Expand Down
10 changes: 5 additions & 5 deletions src/agent/rustjail/src/container.rs
Expand Up @@ -364,7 +364,7 @@ fn do_init_child(cwfd: RawFd) -> Result<()> {

let buf = read_sync(crfd)?;
let process_str = std::str::from_utf8(&buf)?;
let mut oci_process: oci::Process = serde_json::from_str(process_str)?;
let oci_process: oci::Process = serde_json::from_str(process_str)?;
log_child!(cfd_log, "notify parent to send cgroup manager");
write_sync(cwfd, SYNC_SUCCESS, "")?;

Expand Down Expand Up @@ -799,9 +799,9 @@ impl BaseContainer for LinuxContainer {
unistd::close(pwfd);
});

let mut child_stdin: std::process::Stdio;
let mut child_stdout: std::process::Stdio;
let mut child_stderr: std::process::Stdio;
let child_stdin: std::process::Stdio;
let child_stdout: std::process::Stdio;
let child_stderr: std::process::Stdio;

if tty {
let pseudo = pty::openpty(None, None)?;
Expand Down Expand Up @@ -865,7 +865,7 @@ impl BaseContainer for LinuxContainer {
child = child.env(FIFO_FD, format!("{}", fifofd));
}

let mut child = child.spawn()?;
let child = child.spawn()?;

unistd::close(crfd)?;
unistd::close(cwfd)?;
Expand Down

0 comments on commit ec24f68

Please sign in to comment.