Fix clippy::transmute_ptr_to_ptr

This commit is contained in:
Zhiming Wang 2020-07-26 01:01:32 +08:00
parent c9c6031a53
commit e947bc5606
No known key found for this signature in database
GPG Key ID: 5B58F95EC95965D8
3 changed files with 7 additions and 13 deletions

View File

@ -1,5 +1,4 @@
use std::ffi::{CStr, CString}; use std::ffi::{CStr, CString};
use std::mem;
use std::ops::Index; use std::ops::Index;
use std::ptr; use std::ptr;
use std::slice; use std::slice;
@ -7,7 +6,7 @@ use std::str::from_utf8_unchecked;
use ffi::AVSampleFormat::*; use ffi::AVSampleFormat::*;
use ffi::*; use ffi::*;
use libc::c_int; use libc::{c_int, c_void};
#[derive(Eq, PartialEq, Copy, Clone, Debug)] #[derive(Eq, PartialEq, Copy, Clone, Debug)]
pub enum Sample { pub enum Sample {
@ -203,7 +202,7 @@ impl Clone for Buffer {
unsafe { unsafe {
av_samples_copy( av_samples_copy(
self.buffer, self.buffer,
mem::transmute(source.buffer), source.buffer as *const *mut u8,
0, 0,
0, 0,
source.samples as c_int, source.samples as c_int,
@ -218,7 +217,7 @@ impl Drop for Buffer {
#[inline] #[inline]
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
av_freep(mem::transmute(self.buffer)); av_freep(self.buffer as *mut c_void);
} }
} }
} }

View File

@ -148,9 +148,7 @@ impl Audio {
panic!("unsupported type"); panic!("unsupported type");
} }
unsafe { unsafe { slice::from_raw_parts((*self.as_ptr()).data[index] as *const T, self.samples()) }
slice::from_raw_parts(mem::transmute((*self.as_ptr()).data[index]), self.samples())
}
} }
#[inline] #[inline]
@ -164,10 +162,7 @@ impl Audio {
} }
unsafe { unsafe {
slice::from_raw_parts_mut( slice::from_raw_parts_mut((*self.as_mut_ptr()).data[index] as *mut T, self.samples())
mem::transmute((*self.as_mut_ptr()).data[index]),
self.samples(),
)
} }
} }

View File

@ -260,7 +260,7 @@ impl Video {
unsafe { unsafe {
slice::from_raw_parts( slice::from_raw_parts(
mem::transmute((*self.as_ptr()).data[index]), (*self.as_ptr()).data[index] as *const T,
self.stride(index) * self.plane_height(index) as usize / mem::size_of::<T>(), self.stride(index) * self.plane_height(index) as usize / mem::size_of::<T>(),
) )
} }
@ -278,7 +278,7 @@ impl Video {
unsafe { unsafe {
slice::from_raw_parts_mut( slice::from_raw_parts_mut(
mem::transmute((*self.as_mut_ptr()).data[index]), (*self.as_mut_ptr()).data[index] as *mut T,
self.stride(index) * self.plane_height(index) as usize / mem::size_of::<T>(), self.stride(index) * self.plane_height(index) as usize / mem::size_of::<T>(),
) )
} }