1
Fork 0

unnecessary_cast

casting to the same type is unnecessary
This commit is contained in:
Chris Denton 2023-11-21 23:40:46 +00:00
parent 24542639aa
commit 9e42456a0d
No known key found for this signature in database
GPG key ID: 713472F2F45627DE
4 changed files with 9 additions and 9 deletions

View file

@ -81,7 +81,7 @@ impl Handle {
let res = unsafe { self.synchronous_read(buf.as_mut_ptr().cast(), buf.len(), None) };
match res {
Ok(read) => Ok(read as usize),
Ok(read) => Ok(read),
// The special treatment of BrokenPipe is to deal with Windows
// pipe semantics, which yields this error when *reading* from
@ -107,7 +107,7 @@ impl Handle {
unsafe { self.synchronous_read(buf.as_mut_ptr().cast(), buf.len(), Some(offset)) };
match res {
Ok(read) => Ok(read as usize),
Ok(read) => Ok(read),
Err(ref e) if e.raw_os_error() == Some(c::ERROR_HANDLE_EOF as i32) => Ok(0),
Err(e) => Err(e),
}
@ -121,7 +121,7 @@ impl Handle {
Ok(read) => {
// Safety: `read` bytes were written to the initialized portion of the buffer
unsafe {
cursor.advance(read as usize);
cursor.advance(read);
}
Ok(())
}

View file

@ -36,7 +36,7 @@ impl<'a> IoSlice<'a> {
#[inline]
pub fn as_slice(&self) -> &[u8] {
unsafe { slice::from_raw_parts(self.vec.buf as *mut u8, self.vec.len as usize) }
unsafe { slice::from_raw_parts(self.vec.buf, self.vec.len as usize) }
}
}
@ -70,12 +70,12 @@ impl<'a> IoSliceMut<'a> {
#[inline]
pub fn as_slice(&self) -> &[u8] {
unsafe { slice::from_raw_parts(self.vec.buf as *mut u8, self.vec.len as usize) }
unsafe { slice::from_raw_parts(self.vec.buf, self.vec.len as usize) }
}
#[inline]
pub fn as_mut_slice(&mut self) -> &mut [u8] {
unsafe { slice::from_raw_parts_mut(self.vec.buf as *mut u8, self.vec.len as usize) }
unsafe { slice::from_raw_parts_mut(self.vec.buf, self.vec.len as usize) }
}
}

View file

@ -364,5 +364,5 @@ pub fn exit(code: i32) -> ! {
}
pub fn getpid() -> u32 {
unsafe { c::GetCurrentProcessId() as u32 }
unsafe { c::GetCurrentProcessId() }
}

View file

@ -657,7 +657,7 @@ impl Process {
}
pub fn id(&self) -> u32 {
unsafe { c::GetProcessId(self.handle.as_raw_handle()) as u32 }
unsafe { c::GetProcessId(self.handle.as_raw_handle()) }
}
pub fn main_thread_handle(&self) -> BorrowedHandle<'_> {
@ -918,7 +918,7 @@ fn make_proc_thread_attribute_list(
};
let mut proc_thread_attribute_list = ProcThreadAttributeList(
vec![MaybeUninit::uninit(); required_size as usize].into_boxed_slice(),
vec![MaybeUninit::uninit(); required_size].into_boxed_slice(),
);
// Once we've allocated the necessary memory, it's safe to invoke