Skip to content

Commit

Permalink
Rollup merge of #74356 - lzutao:rm_combine, r=LukasKalbertodt
Browse files Browse the repository at this point in the history
Remove combine function

Comparing two array directly helps generate better assert message.
Resolve https://github.com/rust-lang/rust/pull/74271/files#r454538514
  • Loading branch information
Manishearth authored Jul 19, 2020
2 parents 2f3d64f + afbfe60 commit cc4e880
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/libstd/sys/unix/process/process_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ impl Command {
Ok(0) => return Ok((p, ours)),
Ok(8) => {
let (errno, footer) = bytes.split_at(4);
assert!(
combine(CLOEXEC_MSG_FOOTER) == combine(footer.try_into().unwrap()),
assert_eq!(
CLOEXEC_MSG_FOOTER, footer,
"Validation on the CLOEXEC pipe failed: {:?}",
bytes
);
let errno = combine(errno.try_into().unwrap());
let errno = i32::from_be_bytes(errno.try_into().unwrap());
assert!(p.wait().is_ok(), "wait() should either return Ok or panic");
return Err(Error::from_raw_os_error(errno));
}
Expand All @@ -105,10 +105,6 @@ impl Command {
}
}
}

fn combine(arr: [u8; 4]) -> i32 {
i32::from_be_bytes(arr)
}
}

pub fn exec(&mut self, default: Stdio) -> io::Error {
Expand Down

0 comments on commit cc4e880

Please sign in to comment.