Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport bug fixes to 0.34.x. #331

Merged
merged 3 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/imp/linux_raw/io/io_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use super::c;
use core::marker::PhantomData;
use core::slice;
use linux_raw_sys::general::__kernel_size_t;

/// <https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html>
#[derive(Copy, Clone)]
Expand All @@ -23,7 +24,7 @@ impl<'a> IoSlice<'a> {
IoSlice {
vec: c::iovec {
iov_base: buf.as_ptr() as *mut u8 as *mut c::c_void,
iov_len: buf.len() as u64,
iov_len: buf.len() as _,
},
_p: PhantomData,
}
Expand All @@ -32,12 +33,12 @@ impl<'a> IoSlice<'a> {
/// <https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html#method.advance>
#[inline]
pub fn advance(&mut self, n: usize) {
if self.vec.iov_len < n as u64 {
if self.vec.iov_len < n as _ {
panic!("advancing IoSlice beyond its length");
}

unsafe {
self.vec.iov_len -= n as u64;
self.vec.iov_len -= n as __kernel_size_t;
self.vec.iov_base = self.vec.iov_base.add(n);
}
}
Expand All @@ -63,7 +64,7 @@ impl<'a> IoSliceMut<'a> {
IoSliceMut {
vec: c::iovec {
iov_base: buf.as_mut_ptr() as *mut c::c_void,
iov_len: buf.len() as u64,
iov_len: buf.len() as _,
},
_p: PhantomData,
}
Expand All @@ -72,12 +73,12 @@ impl<'a> IoSliceMut<'a> {
/// <https://doc.rust-lang.org/nightly/std/io/struct.IoSliceMut.html#method.advance>
#[inline]
pub fn advance(&mut self, n: usize) {
if self.vec.iov_len < n as u64 {
if self.vec.iov_len < n as _ {
panic!("advancing IoSliceMut beyond its length");
}

unsafe {
self.vec.iov_len -= n as u64;
self.vec.iov_len -= n as __kernel_size_t;
self.vec.iov_base = self.vec.iov_base.add(n);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/imp/linux_raw/io/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ pub(crate) fn dup2(fd: BorrowedFd<'_>, new: &OwnedFd) -> io::Result<()> {
{
// `dup3` fails if the old and new file descriptors have the same
// value, so emulate the `dup2` behvior.
use std::os::unix::io::AsRawFd;
use crate::fd::AsRawFd;
if fd.as_raw_fd() == new.as_raw_fd() {
return Ok(());
}
Expand Down
7 changes: 5 additions & 2 deletions src/imp/linux_raw/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ use linux_raw_sys::general::{
__kernel_pid_t, PR_SET_NAME, SIGCHLD,
};
#[cfg(target_arch = "x86")]
use {super::conv::by_mut, linux_raw_sys::general::__NR_set_thread_area};
use {
super::arch::choose::syscall1, super::conv::by_mut,
linux_raw_sys::general::__NR_set_thread_area,
};
#[cfg(target_arch = "x86_64")]
use {
super::conv::ret_infallible,
Expand Down Expand Up @@ -92,7 +95,7 @@ pub(crate) mod tls {
#[cfg(target_arch = "x86")]
#[inline]
pub(crate) unsafe fn set_thread_area(u_info: &mut UserDesc) -> io::Result<()> {
ret(syscall1_readonly(nr(__NR_set_thread_area), by_mut(u_info)))
ret(syscall1(nr(__NR_set_thread_area), by_mut(u_info)))
}

#[cfg(target_arch = "arm")]
Expand Down