mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-03 11:25:20 +00:00
virtio-devices: Address Rust 1.51.0 clippy issue (vec_init_then_push)
warning: calls to `push` immediately after creation --> virtio-devices/src/vhost_user/net.rs:291:13 | 291 | / let mut interrupt_list_sub: Vec<(Option<EventFd>, Queue)> = Vec::with_capacity(2); 292 | | interrupt_list_sub.push(vu_interrupt_list.remove(0)); 293 | | interrupt_list_sub.push(vu_interrupt_list.remove(0)); | |_________________________________________________________________^ help: consider using the `vec![]` macro: `let mut interrupt_list_sub: Vec<(Option<EventFd>, Queue)> = vec![..];` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#vec_init_then_push Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
3b8d1f1411
commit
2571cc8041
@ -449,15 +449,11 @@ impl VirtioDevice for Net {
|
||||
let tx = TxVirtio::new();
|
||||
let rx_tap_listening = false;
|
||||
|
||||
let mut queue_pair = Vec::new();
|
||||
queue_pair.push(queues.remove(0));
|
||||
queue_pair.push(queues.remove(0));
|
||||
let mut queue_pair = vec![queues.remove(0), queues.remove(0)];
|
||||
queue_pair[0].set_event_idx(event_idx);
|
||||
queue_pair[1].set_event_idx(event_idx);
|
||||
|
||||
let mut queue_evt_pair = Vec::new();
|
||||
queue_evt_pair.push(queue_evts.remove(0));
|
||||
queue_evt_pair.push(queue_evts.remove(0));
|
||||
let queue_evt_pair = vec![queue_evts.remove(0), queue_evts.remove(0)];
|
||||
|
||||
let kill_evt = self
|
||||
.common
|
||||
|
@ -631,7 +631,7 @@ impl VirtioPciDevice {
|
||||
|
||||
if offset < std::mem::size_of::<VirtioPciCap>() {
|
||||
let (_, right) = cap_slice.split_at_mut(offset);
|
||||
right[..data_len].copy_from_slice(&data[..]);
|
||||
right[..data_len].copy_from_slice(&data);
|
||||
None
|
||||
} else {
|
||||
// Safe since we know self.cap_pci_cfg_info.cap.cap.offset is 32bits long.
|
||||
|
@ -231,8 +231,7 @@ impl VirtioDevice for Blk {
|
||||
|
||||
let mut epoll_threads = Vec::new();
|
||||
for i in 0..vu_interrupt_list.len() {
|
||||
let mut interrupt_list_sub: Vec<(Option<EventFd>, Queue)> = Vec::with_capacity(1);
|
||||
interrupt_list_sub.push(vu_interrupt_list.remove(0));
|
||||
let interrupt_list_sub = vec![vu_interrupt_list.remove(0)];
|
||||
|
||||
let kill_evt = self
|
||||
.common
|
||||
|
@ -288,9 +288,7 @@ impl VirtioDevice for Net {
|
||||
|
||||
let mut epoll_threads = Vec::new();
|
||||
for i in 0..vu_interrupt_list.len() / 2 {
|
||||
let mut interrupt_list_sub: Vec<(Option<EventFd>, Queue)> = Vec::with_capacity(2);
|
||||
interrupt_list_sub.push(vu_interrupt_list.remove(0));
|
||||
interrupt_list_sub.push(vu_interrupt_list.remove(0));
|
||||
let interrupt_list_sub = vec![vu_interrupt_list.remove(0), vu_interrupt_list.remove(0)];
|
||||
|
||||
let kill_evt = self
|
||||
.common
|
||||
|
Loading…
Reference in New Issue
Block a user