mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 18:38:01 +00:00
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 <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/940562 Reviewed-by: Zach Reizner <zachr@chromium.org>
This commit is contained in:
parent
9c7508593d
commit
8b32d55ae2
1 changed files with 2 additions and 2 deletions
|
@ -154,7 +154,7 @@ impl Scm {
|
||||||
};
|
};
|
||||||
|
|
||||||
if write_count < 0 {
|
if write_count < 0 {
|
||||||
Err(Error::new(write_count as i32))
|
Err(Error::new(-write_count as i32))
|
||||||
} else {
|
} else {
|
||||||
Ok(write_count as usize)
|
Ok(write_count as usize)
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ impl Scm {
|
||||||
};
|
};
|
||||||
|
|
||||||
if read_count < 0 {
|
if read_count < 0 {
|
||||||
Err(Error::new(read_count as i32))
|
Err(Error::new(-read_count as i32))
|
||||||
} else {
|
} else {
|
||||||
// Safe because we have unqiue ownership of each fd we wrap with File.
|
// Safe because we have unqiue ownership of each fd we wrap with File.
|
||||||
for &fd in &self.fds[0..fd_count] {
|
for &fd in &self.fds[0..fd_count] {
|
||||||
|
|
Loading…
Reference in a new issue