From 2554f2a8d4d0c6f5ed3daf88a986dbfbd745207e Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Sat, 22 Apr 2023 08:21:44 +0100 Subject: [PATCH] qcow: use std::mem::size_of_val() Rather than manually calculate the size of the slice in bytes. This fixes a beta clippy issue. Signed-off-by: Rob Bradford --- qcow/src/qcow_raw_file.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qcow/src/qcow_raw_file.rs b/qcow/src/qcow_raw_file.rs index 2c56cef23..75836fd22 100644 --- a/qcow/src/qcow_raw_file.rs +++ b/qcow/src/qcow_raw_file.rs @@ -66,7 +66,7 @@ impl QcowRawFile { non_zero_flags: u64, ) -> io::Result<()> { self.file.seek(SeekFrom::Start(offset))?; - let mut buffer = BufWriter::with_capacity(table.len() * size_of::(), &mut self.file); + let mut buffer = BufWriter::with_capacity(std::mem::size_of_val(table), &mut self.file); for addr in table { let val = if *addr == 0 { 0 @@ -91,7 +91,8 @@ impl QcowRawFile { /// Writes a refcount block to the file. pub fn write_refcount_block(&mut self, offset: u64, table: &[u16]) -> io::Result<()> { self.file.seek(SeekFrom::Start(offset))?; - let mut buffer = BufWriter::with_capacity(table.len() * size_of::(), &mut self.file); + let mut buffer = BufWriter::with_capacity(std::mem::size_of_val(table), &mut self.file); + for count in table { buffer.write_u16::(*count)?; }