virtio-devices: mem: Address clippy issue

error: all if blocks contain the same code at the start
   --> virtio-devices/src/mem.rs:508:9
    |
508 | /         if plug {
509 | |             let handlers =
    self.dma_mapping_handlers.lock().unwrap();
    |
|_____________________________________________________________________^
    |
    = note: `-D clippy::branches-sharing-code` implied by `-D warnings`
    = help: for further information visit
https://rust-lang.github.io/rust-clippy/master/index.html#branches_sharing_code
help: consider moving the start statements out like this
    |
508 |         let handlers = self.dma_mapping_handlers.lock().unwrap();
509 |         if plug {
    |

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2021-05-07 10:15:08 +00:00 committed by Sebastien Boeuf
parent 18012d9ee8
commit 0d3c5c966b

View File

@ -505,8 +505,8 @@ impl MemEpollHandler {
.unwrap()
.set_range(first_block_index, nb_blocks, plug);
let handlers = self.dma_mapping_handlers.lock().unwrap();
if plug {
let handlers = self.dma_mapping_handlers.lock().unwrap();
let mut gpa = addr;
for _ in 0..nb_blocks {
for (_, handler) in handlers.iter() {
@ -524,7 +524,6 @@ impl MemEpollHandler {
config.plugged_size += size;
} else {
let handlers = self.dma_mapping_handlers.lock().unwrap();
for (_, handler) in handlers.iter() {
if let Err(e) = handler.unmap(addr, size) {
error!(