Add unsafe_op_in_unsafe_fn lint
This commit is contained in:
parent
0512033ddd
commit
72726e00d5
4 changed files with 15 additions and 8 deletions
|
@ -1,5 +1,6 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
#![deny(unsafe_op_in_unsafe_fn)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
|
|
|
@ -10,14 +10,18 @@ struct AllocInfo {
|
|||
pub unsafe fn wrapped_alloc(layout: Layout) -> *mut u8 {
|
||||
let header_layout = Layout::new::<AllocInfo>();
|
||||
let (to_request, offset) = header_layout.extend(layout).unwrap();
|
||||
let orig_ptr = underlying_alloc(to_request);
|
||||
let result_ptr = orig_ptr.add(offset);
|
||||
let info_ptr = result_ptr.sub(size_of::<AllocInfo>()) as *mut AllocInfo;
|
||||
info_ptr.write_unaligned(AllocInfo { layout: to_request, ptr: orig_ptr });
|
||||
result_ptr
|
||||
unsafe {
|
||||
let orig_ptr = underlying_alloc(to_request);
|
||||
let result_ptr = orig_ptr.add(offset);
|
||||
let info_ptr = result_ptr.sub(size_of::<AllocInfo>()) as *mut AllocInfo;
|
||||
info_ptr.write_unaligned(AllocInfo { layout: to_request, ptr: orig_ptr });
|
||||
result_ptr
|
||||
}
|
||||
}
|
||||
pub unsafe fn wrapped_dealloc(ptr: *mut u8) {
|
||||
let info_ptr = ptr.sub(size_of::<AllocInfo>()) as *const AllocInfo;
|
||||
let info = info_ptr.read_unaligned();
|
||||
underlying_dealloc(info.ptr, info.layout);
|
||||
unsafe {
|
||||
let info_ptr = ptr.sub(size_of::<AllocInfo>()) as *const AllocInfo;
|
||||
let info = info_ptr.read_unaligned();
|
||||
underlying_dealloc(info.ptr, info.layout);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
#![allow(warnings)]
|
||||
#![allow(unsafe_op_in_unsafe_fn)]
|
||||
include!("acpica-bindings.rs");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
#![forbid(unsafe_op_in_unsafe_fn)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue