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 <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2021-01-02 19:58:33 +00:00 committed by Sebastien Boeuf
parent a4134f6b25
commit a2e1e13918

View File

@ -218,16 +218,17 @@ impl VhostUserBlkBackend {
}; };
let nsectors = (image.lock().unwrap().seek(SeekFrom::End(0)).unwrap() as u64) / SECTOR_SIZE; let nsectors = (image.lock().unwrap().seek(SeekFrom::End(0)).unwrap() as u64) / SECTOR_SIZE;
let mut config = VirtioBlockConfig::default(); let config = VirtioBlockConfig {
capacity: nsectors,
config.capacity = nsectors; blk_size: BLK_SIZE,
config.blk_size = BLK_SIZE; size_max: 65535,
config.size_max = 65535; seg_max: 128 - 2,
config.seg_max = 128 - 2; min_io_size: 1,
config.min_io_size = 1; opt_io_size: 1,
config.opt_io_size = 1; num_queues: num_queues as u16,
config.num_queues = num_queues as u16; writeback: 1,
config.writeback = 1; ..Default::default()
};
let mut queues_per_thread = Vec::new(); let mut queues_per_thread = Vec::new();
let mut threads = Vec::new(); let mut threads = Vec::new();