diff --git a/libraries/tickv/src/async_ops.rs b/libraries/tickv/src/async_ops.rs index 0c37b93713..9c3562e86b 100644 --- a/libraries/tickv/src/async_ops.rs +++ b/libraries/tickv/src/async_ops.rs @@ -398,6 +398,7 @@ mod tests { use crate::success_codes::SuccessCode; use crate::tickv::{HASH_OFFSET, LEN_OFFSET, MAIN_KEY, VERSION, VERSION_OFFSET}; use core::hash::{Hash, Hasher}; + use core::ptr::addr_of_mut; use std::cell::Cell; use std::cell::RefCell; use std::collections::hash_map::DefaultHasher; @@ -641,7 +642,8 @@ mod tests { println!("HASHED KEY {:?}", get_hashed_key(b"ONE")); - let ret = unsafe { tickv.append_key(get_hashed_key(b"ONE"), &mut VALUE, 32) }; + let ret = + unsafe { tickv.append_key(get_hashed_key(b"ONE"), &mut *addr_of_mut!(VALUE), 32) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -652,7 +654,8 @@ mod tests { _ => unreachable!(), } - let ret = unsafe { tickv.append_key(get_hashed_key(b"TWO"), &mut VALUE, 32) }; + let ret = + unsafe { tickv.append_key(get_hashed_key(b"TWO"), &mut *addr_of_mut!(VALUE), 32) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -689,7 +692,8 @@ mod tests { static mut BUF: [u8; 32] = [0; 32]; println!("Add key ONE"); - let ret = unsafe { tickv.append_key(get_hashed_key(b"ONE"), &mut VALUE, 32) }; + let ret = + unsafe { tickv.append_key(get_hashed_key(b"ONE"), &mut *addr_of_mut!(VALUE), 32) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -702,7 +706,7 @@ mod tests { println!("Get key ONE"); - let ret = unsafe { tickv.get_key(get_hashed_key(b"ONE"), &mut BUF) }; + let ret = unsafe { tickv.get_key(get_hashed_key(b"ONE"), &mut *addr_of_mut!(BUF)) }; match ret { Ok(SuccessCode::Queued) => { flash_ctrl_callback(&tickv); @@ -713,7 +717,7 @@ mod tests { } println!("Get non-existent key TWO"); - let ret = unsafe { tickv.get_key(get_hashed_key(b"TWO"), &mut BUF) }; + let ret = unsafe { tickv.get_key(get_hashed_key(b"TWO"), &mut *addr_of_mut!(BUF)) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -725,7 +729,8 @@ mod tests { } println!("Add key ONE again"); - let ret = unsafe { tickv.append_key(get_hashed_key(b"ONE"), &mut VALUE, 32) }; + let ret = + unsafe { tickv.append_key(get_hashed_key(b"ONE"), &mut *addr_of_mut!(VALUE), 32) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -740,7 +745,8 @@ mod tests { } println!("Add key TWO"); - let ret = unsafe { tickv.append_key(get_hashed_key(b"TWO"), &mut VALUE, 32) }; + let ret = + unsafe { tickv.append_key(get_hashed_key(b"TWO"), &mut *addr_of_mut!(VALUE), 32) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -752,7 +758,7 @@ mod tests { } println!("Get key ONE"); - let ret = unsafe { tickv.get_key(get_hashed_key(b"ONE"), &mut BUF) }; + let ret = unsafe { tickv.get_key(get_hashed_key(b"ONE"), &mut *addr_of_mut!(BUF)) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -764,7 +770,7 @@ mod tests { } println!("Get key TWO"); - let ret = unsafe { tickv.get_key(get_hashed_key(b"TWO"), &mut BUF) }; + let ret = unsafe { tickv.get_key(get_hashed_key(b"TWO"), &mut *addr_of_mut!(BUF)) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -776,7 +782,7 @@ mod tests { } println!("Get non-existent key THREE"); - let ret = unsafe { tickv.get_key(get_hashed_key(b"THREE"), &mut BUF) }; + let ret = unsafe { tickv.get_key(get_hashed_key(b"THREE"), &mut *addr_of_mut!(BUF)) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -786,7 +792,7 @@ mod tests { _ => unreachable!(), } - let ret = unsafe { tickv.get_key(get_hashed_key(b"THREE"), &mut BUF) }; + let ret = unsafe { tickv.get_key(get_hashed_key(b"THREE"), &mut *addr_of_mut!(BUF)) }; match ret { Ok(SuccessCode::Queued) => { flash_ctrl_callback(&tickv); @@ -822,7 +828,7 @@ mod tests { static mut BUF: [u8; 32] = [0; 32]; println!("Add key 0x1000"); - let ret = unsafe { tickv.append_key(0x1000, &mut VALUE, 32) }; + let ret = unsafe { tickv.append_key(0x1000, &mut *addr_of_mut!(VALUE), 32) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -834,7 +840,7 @@ mod tests { } println!("Add key 0x2000"); - let ret = unsafe { tickv.append_key(0x2000, &mut VALUE, 32) }; + let ret = unsafe { tickv.append_key(0x2000, &mut *addr_of_mut!(VALUE), 32) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -853,7 +859,7 @@ mod tests { } println!("Add key 0x3000"); - let ret = unsafe { tickv.append_key(0x3000, &mut VALUE, 32) }; + let ret = unsafe { tickv.append_key(0x3000, &mut *addr_of_mut!(VALUE), 32) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -876,7 +882,7 @@ mod tests { } println!("Get key 0x1000"); - let ret = unsafe { tickv.get_key(0x1000, &mut BUF) }; + let ret = unsafe { tickv.get_key(0x1000, &mut *addr_of_mut!(BUF)) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -898,7 +904,7 @@ mod tests { } println!("Get key 0x3000"); - let ret = unsafe { tickv.get_key(0x3000, &mut BUF) }; + let ret = unsafe { tickv.get_key(0x3000, &mut *addr_of_mut!(BUF)) }; match ret { Ok(_) => flash_ctrl_callback(&tickv), Err(_) => unreachable!(), @@ -942,7 +948,8 @@ mod tests { static mut BUF: [u8; 32] = [0; 32]; println!("Add key ONE"); - let ret = unsafe { tickv.append_key(get_hashed_key(b"ONE"), &mut VALUE, 32) }; + let ret = + unsafe { tickv.append_key(get_hashed_key(b"ONE"), &mut *addr_of_mut!(VALUE), 32) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -954,7 +961,7 @@ mod tests { } println!("Get key ONE"); - let ret = unsafe { tickv.get_key(get_hashed_key(b"ONE"), &mut BUF) }; + let ret = unsafe { tickv.get_key(get_hashed_key(b"ONE"), &mut *addr_of_mut!(BUF)) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -978,7 +985,7 @@ mod tests { println!("Get non-existent key ONE"); unsafe { - match tickv.get_key(get_hashed_key(b"ONE"), &mut BUF) { + match tickv.get_key(get_hashed_key(b"ONE"), &mut *addr_of_mut!(BUF)) { Ok(SuccessCode::Queued) => { flash_ctrl_callback(&tickv); @@ -1103,7 +1110,8 @@ mod tests { } println!("Add key ONE"); - let ret = unsafe { tickv.append_key(get_hashed_key(b"ONE"), &mut VALUE, 32) }; + let ret = + unsafe { tickv.append_key(get_hashed_key(b"ONE"), &mut *addr_of_mut!(VALUE), 32) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now @@ -1156,7 +1164,7 @@ mod tests { } println!("Get non-existent key ONE"); - match unsafe { tickv.get_key(get_hashed_key(b"ONE"), &mut BUF) } { + match unsafe { tickv.get_key(get_hashed_key(b"ONE"), &mut *addr_of_mut!(BUF)) } { Ok(SuccessCode::Queued) => { flash_ctrl_callback(&tickv); assert_eq!( @@ -1170,7 +1178,8 @@ mod tests { } println!("Add Key ONE"); - let ret = unsafe { tickv.append_key(get_hashed_key(b"ONE"), &mut VALUE, 32) }; + let ret = + unsafe { tickv.append_key(get_hashed_key(b"ONE"), &mut *addr_of_mut!(VALUE), 32) }; match ret { Ok(SuccessCode::Queued) => { // There is no actual delay in the test, just continue now