From afbfe603fc1c288a0cff63b3b1cad43902a66e9b Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 15 Jul 2020 08:14:55 +0000 Subject: [PATCH] Remove combine function Comparing two array directly helps generate better assert message --- src/libstd/sys/unix/process/process_unix.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index de35fe0521d..a8499070e15 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -84,12 +84,12 @@ pub fn spawn( 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)); } @@ -105,10 +105,6 @@ pub fn spawn( } } } - - fn combine(arr: [u8; 4]) -> i32 { - i32::from_be_bytes(arr) - } } pub fn exec(&mut self, default: Stdio) -> io::Error { -- 2.44.0