mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: Fix clippy: chunks_exact with constant chunk size
```
warning: using `chunks_exact` with a constant chunk size
--> block/src/formats/qcow/internal/header.rs:253:39
|
253 | for entry in data.chunks_exact(FEATURE_NAME_ENTRY_SIZE) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `as_chunks` instead
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#chunks_exact_to_as_chunks
= note: `-D clippy::chunks-exact-to-as-chunks` implied by `-D clippy::all`
```
Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
@@ -250,7 +250,7 @@ impl QcowHeader {
|
||||
.map_err(Error::ReadingHeader)?;
|
||||
offset += data.len() as u64;
|
||||
let table = feature_table.as_mut().unwrap();
|
||||
for entry in data.chunks_exact(FEATURE_NAME_ENTRY_SIZE) {
|
||||
for entry in data.as_chunks::<FEATURE_NAME_ENTRY_SIZE>().0 {
|
||||
if entry[0] == FEAT_TYPE_INCOMPATIBLE {
|
||||
let bit_number = entry[1];
|
||||
let name_bytes = &entry[2..];
|
||||
|
||||
@@ -203,8 +203,10 @@ impl QcowRawFile {
|
||||
self.file.read_exact_at(&mut bytes, offset)?;
|
||||
let m = mask.unwrap_or(u64::MAX);
|
||||
let table = bytes
|
||||
.chunks_exact(size_of::<u64>())
|
||||
.map(|c| u64::from_be_bytes(c.try_into().unwrap()) & m)
|
||||
.as_chunks::<{ size_of::<u64>() }>()
|
||||
.0
|
||||
.iter()
|
||||
.map(|c| u64::from_be_bytes(*c) & m)
|
||||
.collect();
|
||||
Ok(table)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user