From 2563b08ff0cfa82f0c5be5c0eecbf813547befa0 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 7 Jan 2022 10:20:13 +0000 Subject: [PATCH] virtio-queue: Fix clippy (needless_late_init) issue warning: unneeded late initalization --> virtio-queue/src/chain.rs:381:13 | 381 | let desc: Descriptor; | ^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(clippy::needless_late_init)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init help: declare `desc` here | 382 | let desc: Descriptor = if i < 3 { | ++++++++++++++++++++++ help: remove the assignments from the branches | 383 ~ Descriptor::new(0x1000 * i as u64, 0x1000, VIRTQ_DESC_F_NEXT, i + 1) 384 | } else { 385 ~ Descriptor::new(0x1000 * i as u64, 0x1000, 0, 0) | help: add a semicolon after the `if` expression | 386 | }; | + Signed-off-by: Rob Bradford --- virtio-queue/src/chain.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/virtio-queue/src/chain.rs b/virtio-queue/src/chain.rs index 5f5c0a795..5565bb49f 100644 --- a/virtio-queue/src/chain.rs +++ b/virtio-queue/src/chain.rs @@ -378,12 +378,11 @@ mod tests { // create an indirect table with 4 chained descriptors let idtable = DescriptorTable::new(m, GuestAddress(0x7000), 4); for i in 0..4u16 { - let desc: Descriptor; - if i < 3 { - desc = Descriptor::new(0x1000 * i as u64, 0x1000, VIRTQ_DESC_F_NEXT, i + 1); + let desc = if i < 3 { + Descriptor::new(0x1000 * i as u64, 0x1000, VIRTQ_DESC_F_NEXT, i + 1) } else { - desc = Descriptor::new(0x1000 * i as u64, 0x1000, 0, 0); - } + Descriptor::new(0x1000 * i as u64, 0x1000, 0, 0) + }; idtable.store(i, desc); }