Merge pull request #304 from mahkoh/jorth/edition-2024
it: handle new warnings
This commit is contained in:
commit
cc426a0a4a
3 changed files with 45 additions and 35 deletions
|
|
@ -59,6 +59,7 @@ unsafe extern "C" fn init(
|
||||||
) -> *const u8 {
|
) -> *const u8 {
|
||||||
let tc = CONFIG.get();
|
let tc = CONFIG.get();
|
||||||
assert!(tc.is_not_null());
|
assert!(tc.is_not_null());
|
||||||
|
unsafe {
|
||||||
Rc::increment_strong_count(tc);
|
Rc::increment_strong_count(tc);
|
||||||
{
|
{
|
||||||
let tc = &*tc;
|
let tc = &*tc;
|
||||||
|
|
@ -69,15 +70,18 @@ unsafe extern "C" fn init(
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
tc.cast()
|
tc.cast()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn unref(data: *const u8) {
|
unsafe extern "C" fn unref(data: *const u8) {
|
||||||
|
unsafe {
|
||||||
Rc::decrement_strong_count(data.cast::<TestConfig>());
|
Rc::decrement_strong_count(data.cast::<TestConfig>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn handle_msg(data: *const u8, msg: *const u8, size: usize) {
|
unsafe extern "C" fn handle_msg(data: *const u8, msg: *const u8, size: usize) {
|
||||||
let tc = &*data.cast::<TestConfig>();
|
let tc = unsafe { &*data.cast::<TestConfig>() };
|
||||||
let msg = std::slice::from_raw_parts(msg, size);
|
let msg = unsafe { std::slice::from_raw_parts(msg, size) };
|
||||||
let res = bincode_ops().deserialize::<ServerMessage>(msg);
|
let res = bincode_ops().deserialize::<ServerMessage>(msg);
|
||||||
let msg = match res {
|
let msg = match res {
|
||||||
Ok(msg) => msg,
|
Ok(msg) => msg,
|
||||||
|
|
|
||||||
|
|
@ -270,6 +270,7 @@ mod leaks {
|
||||||
|
|
||||||
unsafe impl GlobalAlloc for TracingAllocator {
|
unsafe impl GlobalAlloc for TracingAllocator {
|
||||||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||||
|
unsafe {
|
||||||
let res = c::calloc(layout.size(), 1) as *mut u8;
|
let res = c::calloc(layout.size(), 1) as *mut u8;
|
||||||
if IN_ALLOCATOR.get() == 0 {
|
if IN_ALLOCATOR.get() == 0 {
|
||||||
IN_ALLOCATOR.set(1);
|
IN_ALLOCATOR.set(1);
|
||||||
|
|
@ -286,8 +287,10 @@ mod leaks {
|
||||||
}
|
}
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
|
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
|
||||||
|
unsafe {
|
||||||
if INITIALIZED.get() {
|
if INITIALIZED.get() {
|
||||||
ALLOCATIONS.get().deref_mut().remove(&ptr);
|
ALLOCATIONS.get().deref_mut().remove(&ptr);
|
||||||
}
|
}
|
||||||
|
|
@ -295,6 +298,7 @@ mod leaks {
|
||||||
c::free(ptr as _);
|
c::free(ptr as _);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn find_allocations_pointing_to(addr: *mut u8) -> Vec<(Allocation, usize)> {
|
fn find_allocations_pointing_to(addr: *mut u8) -> Vec<(Allocation, usize)> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
||||||
|
|
@ -183,16 +183,18 @@ unsafe extern "C" fn ___tracy_demangle(
|
||||||
if mangled.is_null() {
|
if mangled.is_null() {
|
||||||
return ptr::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();
|
return ptr::null();
|
||||||
};
|
};
|
||||||
let demangled = rustc_demangle::demangle(mangled);
|
let demangled = rustc_demangle::demangle(mangled);
|
||||||
static mut BUF: Vec<u8> = Vec::new();
|
static mut BUF: Vec<u8> = Vec::new();
|
||||||
|
unsafe {
|
||||||
BUF.clear();
|
BUF.clear();
|
||||||
if write!(BUF, "{demangled:#}\0").is_err() {
|
if write!(BUF, "{demangled:#}\0").is_err() {
|
||||||
return ptr::null();
|
return ptr::null();
|
||||||
}
|
}
|
||||||
BUF.as_ptr().cast()
|
BUF.as_ptr().cast()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ENABLED: AtomicBool = AtomicBool::new(false);
|
static ENABLED: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue