1
0
Fork 0
forked from wry/wry

Merge pull request #304 from mahkoh/jorth/edition-2024

it: handle new warnings
This commit is contained in:
mahkoh 2024-10-20 18:52:01 +02:00 committed by GitHub
commit cc426a0a4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 45 additions and 35 deletions

View file

@ -59,6 +59,7 @@ unsafe extern "C" fn init(
) -> *const u8 {
let tc = CONFIG.get();
assert!(tc.is_not_null());
unsafe {
Rc::increment_strong_count(tc);
{
let tc = &*tc;
@ -70,14 +71,17 @@ unsafe extern "C" fn init(
}
tc.cast()
}
}
unsafe extern "C" fn unref(data: *const u8) {
unsafe {
Rc::decrement_strong_count(data.cast::<TestConfig>());
}
}
unsafe extern "C" fn handle_msg(data: *const u8, msg: *const u8, size: usize) {
let tc = &*data.cast::<TestConfig>();
let msg = std::slice::from_raw_parts(msg, size);
let tc = unsafe { &*data.cast::<TestConfig>() };
let msg = unsafe { std::slice::from_raw_parts(msg, size) };
let res = bincode_ops().deserialize::<ServerMessage>(msg);
let msg = match res {
Ok(msg) => msg,

View file

@ -270,6 +270,7 @@ mod leaks {
unsafe impl GlobalAlloc for TracingAllocator {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
unsafe {
let res = c::calloc(layout.size(), 1) as *mut u8;
if IN_ALLOCATOR.get() == 0 {
IN_ALLOCATOR.set(1);
@ -286,8 +287,10 @@ mod leaks {
}
res
}
}
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
unsafe {
if INITIALIZED.get() {
ALLOCATIONS.get().deref_mut().remove(&ptr);
}
@ -295,6 +298,7 @@ mod leaks {
c::free(ptr as _);
}
}
}
fn find_allocations_pointing_to(addr: *mut u8) -> Vec<(Allocation, usize)> {
unsafe {

View file

@ -183,17 +183,19 @@ unsafe extern "C" fn ___tracy_demangle(
if mangled.is_null() {
return ptr::null();
}
let Ok(mangled) = CStr::from_ptr(mangled).to_str() else {
let Ok(mangled) = unsafe { CStr::from_ptr(mangled) }.to_str() else {
return ptr::null();
};
let demangled = rustc_demangle::demangle(mangled);
static mut BUF: Vec<u8> = Vec::new();
unsafe {
BUF.clear();
if write!(BUF, "{demangled:#}\0").is_err() {
return ptr::null();
}
BUF.as_ptr().cast()
}
}
static ENABLED: AtomicBool = AtomicBool::new(false);