From a2e1e139183cfe943beb3cb21a178cff20f0ef56 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Sat, 2 Jan 2021 19:58:33 +0000 Subject: [PATCH] vhost_user_block: Use struct instantiation rather than mut variable error: field assignment outside of initializer for an instance created with Default::default() --> vhost_user_block/src/lib.rs:223:9 | 223 | config.capacity = nsectors; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::field-reassign-with-default` implied by `-D warnings` note: consider initializing the variable with `block_util::VirtioBlockConfig { capacity: nsectors, blk_size: BLK_SIZE, size_max: 65535, seg_max: 128 - 2, min_io_size: 1, opt_io_size: 1, num_queues: num_queues as u16, writeback: 1, ..Default::default() }` and removing relevant reassignments --> vhost_user_block/src/lib.rs:221:9 | 221 | let mut config = VirtioBlockConfig::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default Signed-off-by: Rob Bradford --- vhost_user_block/src/lib.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/vhost_user_block/src/lib.rs b/vhost_user_block/src/lib.rs index 2696976de..6754e2d7a 100644 --- a/vhost_user_block/src/lib.rs +++ b/vhost_user_block/src/lib.rs @@ -218,16 +218,17 @@ impl VhostUserBlkBackend { }; let nsectors = (image.lock().unwrap().seek(SeekFrom::End(0)).unwrap() as u64) / SECTOR_SIZE; - let mut config = VirtioBlockConfig::default(); - - config.capacity = nsectors; - config.blk_size = BLK_SIZE; - config.size_max = 65535; - config.seg_max = 128 - 2; - config.min_io_size = 1; - config.opt_io_size = 1; - config.num_queues = num_queues as u16; - config.writeback = 1; + let config = VirtioBlockConfig { + capacity: nsectors, + blk_size: BLK_SIZE, + size_max: 65535, + seg_max: 128 - 2, + min_io_size: 1, + opt_io_size: 1, + num_queues: num_queues as u16, + writeback: 1, + ..Default::default() + }; let mut queues_per_thread = Vec::new(); let mut threads = Vec::new();