clippy:ptr_as_ptr

This commit is contained in:
gwenn
2022-01-05 19:50:25 +01:00
parent 5be363e4cc
commit 43591154b2
13 changed files with 62 additions and 63 deletions

View File

@@ -10,7 +10,7 @@ use crate::{str_to_cstring, Connection, InnerConnection, Result};
// FIXME copy/paste from function.rs
unsafe extern "C" fn free_boxed_value<T>(p: *mut c_void) {
drop(Box::from_raw(p as *mut T));
drop(Box::from_raw(p.cast::<T>()));
}
impl Connection {
@@ -57,14 +57,14 @@ impl InnerConnection {
C: Fn(&str, &str) -> Ordering,
{
let r = catch_unwind(|| {
let boxed_f: *mut C = arg1 as *mut C;
let boxed_f: *mut C = arg1.cast::<C>();
assert!(!boxed_f.is_null(), "Internal error - null function pointer");
let s1 = {
let c_slice = slice::from_raw_parts(arg3 as *const u8, arg2 as usize);
let c_slice = slice::from_raw_parts(arg3.cast::<u8>(), arg2 as usize);
String::from_utf8_lossy(c_slice)
};
let s2 = {
let c_slice = slice::from_raw_parts(arg5 as *const u8, arg4 as usize);
let c_slice = slice::from_raw_parts(arg5.cast::<u8>(), arg4 as usize);
String::from_utf8_lossy(c_slice)
};
(*boxed_f)(s1.as_ref(), s2.as_ref())
@@ -91,7 +91,7 @@ impl InnerConnection {
self.db(),
c_name.as_ptr(),
flags,
boxed_f as *mut c_void,
boxed_f.cast::<c_void>(),
Some(call_boxed_closure::<C>),
Some(free_boxed_value::<C>),
)