Skip to content

Commit 0c20beb

Browse files
JBYoshiJonathanWoollett-Light
authored andcommitted
Change u64 to usize in vmm/devices/virtio/queue
We can use usize in place of u64 here to reduce type conversion warnings. On 64-bit systems the types are equivalent, but Clippy allows automatic conversions in the one direction but not in the other. Signed-off-by: Jonathan Browne <[email protected]>
1 parent e650087 commit 0c20beb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/vmm/src/devices/virtio/queue.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl Queue {
238238

239239
/// Validates the queue's in-memory layout is correct.
240240
pub fn is_layout_valid(&self, mem: &GuestMemoryMmap) -> bool {
241-
let queue_size = u64::from(self.actual_size());
241+
let queue_size = usize::from(self.actual_size());
242242
let desc_table = self.desc_table;
243243
let desc_table_size = 16 * queue_size;
244244
let avail_ring = self.avail_ring;
@@ -263,21 +263,21 @@ impl Queue {
263263
error!("virtio queue used ring breaks alignment constraints");
264264
false
265265
// range check entire descriptor table to be assigned valid guest physical addresses
266-
} else if mem.get_slice(desc_table, desc_table_size as usize).is_err() {
266+
} else if mem.get_slice(desc_table, desc_table_size).is_err() {
267267
error!(
268268
"virtio queue descriptor table goes out of bounds: start:0x{:08x} size:0x{:08x}",
269269
desc_table.raw_value(),
270270
desc_table_size
271271
);
272272
false
273-
} else if mem.get_slice(avail_ring, avail_ring_size as usize).is_err() {
273+
} else if mem.get_slice(avail_ring, avail_ring_size).is_err() {
274274
error!(
275275
"virtio queue available ring goes out of bounds: start:0x{:08x} size:0x{:08x}",
276276
avail_ring.raw_value(),
277277
avail_ring_size
278278
);
279279
false
280-
} else if mem.get_slice(used_ring, used_ring_size as usize).is_err() {
280+
} else if mem.get_slice(used_ring, used_ring_size).is_err() {
281281
error!(
282282
"virtio queue used ring goes out of bounds: start:0x{:08x} size:0x{:08x}",
283283
used_ring.raw_value(),

0 commit comments

Comments
 (0)