Skip to content

Commit 5ec3a8b

Browse files
vireshkroypat
authored andcommitted
volatile_memory: Use size_of_val to fix clippy warnings
Clippy complains with following warnings currently: "error: manual slice size calculation" Fix it by using size_of_val instead. Also fix the usage at another site for the same helper. Signed-off-by: Viresh Kumar <[email protected]>
1 parent 9ce7558 commit 5ec3a8b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/volatile_memory.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,6 @@ mod tests {
14201420

14211421
use std::fs::File;
14221422
use std::io::Cursor;
1423-
use std::mem;
14241423
use std::mem::size_of_val;
14251424
use std::path::Path;
14261425
use std::sync::atomic::{AtomicUsize, Ordering};
@@ -1968,7 +1967,7 @@ mod tests {
19681967
// Trying to read more bytes than we have available in the cursor should
19691968
// make the read_from function return maximum cursor size (i.e. 20).
19701969
let mut bytes_to_read = BytesToRead::default();
1971-
let size_of_bytes = mem::size_of_val(&bytes_to_read);
1970+
let size_of_bytes = size_of_val(&bytes_to_read);
19721971
assert_eq!(
19731972
bytes_to_read
19741973
.as_bytes()
@@ -2192,7 +2191,7 @@ mod tests {
21922191
where
21932192
T: ByteValued + From<u8>,
21942193
{
2195-
let bitmap = AtomicBitmap::new(buf.len() * size_of::<T>(), page_size);
2194+
let bitmap = AtomicBitmap::new(size_of_val(buf), page_size);
21962195
let arr = unsafe {
21972196
VolatileArrayRef::with_bitmap(
21982197
buf.as_mut_ptr() as *mut u8,
@@ -2206,7 +2205,7 @@ mod tests {
22062205

22072206
assert!(range_is_clean(arr.bitmap(), 0, arr.len() * size_of::<T>()));
22082207
arr.copy_from(copy_buf.as_slice());
2209-
assert!(range_is_dirty(arr.bitmap(), 0, buf.len() * size_of::<T>()));
2208+
assert!(range_is_dirty(arr.bitmap(), 0, size_of_val(buf)));
22102209
}
22112210

22122211
#[test]

0 commit comments

Comments
 (0)