mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-21 23:41:15 +00:00
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 <rbradford@rivosinc.com>
This commit is contained in:
parent
036af673e6
commit
2554f2a8d4
@ -66,7 +66,7 @@ impl QcowRawFile {
|
|||||||
non_zero_flags: u64,
|
non_zero_flags: u64,
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
self.file.seek(SeekFrom::Start(offset))?;
|
self.file.seek(SeekFrom::Start(offset))?;
|
||||||
let mut buffer = BufWriter::with_capacity(table.len() * size_of::<u64>(), &mut self.file);
|
let mut buffer = BufWriter::with_capacity(std::mem::size_of_val(table), &mut self.file);
|
||||||
for addr in table {
|
for addr in table {
|
||||||
let val = if *addr == 0 {
|
let val = if *addr == 0 {
|
||||||
0
|
0
|
||||||
@ -91,7 +91,8 @@ impl QcowRawFile {
|
|||||||
/// Writes a refcount block to the file.
|
/// Writes a refcount block to the file.
|
||||||
pub fn write_refcount_block(&mut self, offset: u64, table: &[u16]) -> io::Result<()> {
|
pub fn write_refcount_block(&mut self, offset: u64, table: &[u16]) -> io::Result<()> {
|
||||||
self.file.seek(SeekFrom::Start(offset))?;
|
self.file.seek(SeekFrom::Start(offset))?;
|
||||||
let mut buffer = BufWriter::with_capacity(table.len() * size_of::<u16>(), &mut self.file);
|
let mut buffer = BufWriter::with_capacity(std::mem::size_of_val(table), &mut self.file);
|
||||||
|
|
||||||
for count in table {
|
for count in table {
|
||||||
buffer.write_u16::<BigEndian>(*count)?;
|
buffer.write_u16::<BigEndian>(*count)?;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user