From 8b32d55ae2b8c3a199856759ef16ab7c4435024e Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Tue, 27 Feb 2018 10:26:34 -0800 Subject: sys_util: properly convert errors in sock_ctrl_msg scm_sendmsg() and scm_recvmsg() return negative errors derived from errnos that are normally positive. When constructing errno::Error from these error codes we should convert them back into positive values for error codes to make proper sense. TEST=cargo test --features plugin; cargo test -p sys_util BUG=None Change-Id: Ibf9065b72602e43cb6badd06f85044329d714276 Signed-off-by: Dmitry Torokhov Reviewed-on: https://chromium-review.googlesource.com/940562 Reviewed-by: Zach Reizner --- sys_util/src/sock_ctrl_msg.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sys_util/src/sock_ctrl_msg.rs') diff --git a/sys_util/src/sock_ctrl_msg.rs b/sys_util/src/sock_ctrl_msg.rs index 545e1f2..8a3ce39 100644 --- a/sys_util/src/sock_ctrl_msg.rs +++ b/sys_util/src/sock_ctrl_msg.rs @@ -154,7 +154,7 @@ impl Scm { }; if write_count < 0 { - Err(Error::new(write_count as i32)) + Err(Error::new(-write_count as i32)) } else { Ok(write_count as usize) } @@ -201,7 +201,7 @@ impl Scm { }; if read_count < 0 { - Err(Error::new(read_count as i32)) + Err(Error::new(-read_count as i32)) } else { // Safe because we have unqiue ownership of each fd we wrap with File. for &fd in &self.fds[0..fd_count] { -- cgit 1.4.1