From 1446873b2805e4580f0be9cd93b81a83ab91409f Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 22 Aug 2023 10:56:28 +0100 Subject: [PATCH] virtio-devices: vsock: Fix slow vector initialization warning: slow zero-filling initialization --> virtio-devices/src/vsock/csm/txbuf.rs:218:9 | 216 | let mut tmp: Vec = Vec::new(); | ---------- help: consider replacing this with: `vec![0; TxBuf::SIZE - 2]` 217 | 218 | tmp.resize(TxBuf::SIZE - 2, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization = note: `#[warn(clippy::slow_vector_initialization)]` on by default Signed-off-by: Rob Bradford (cherry picked from commit 05a86d892e11cad503ae75f0d213d08e927c99b1) --- virtio-devices/src/vsock/csm/txbuf.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/virtio-devices/src/vsock/csm/txbuf.rs b/virtio-devices/src/vsock/csm/txbuf.rs index d36e28fb7..83d4a8203 100644 --- a/virtio-devices/src/vsock/csm/txbuf.rs +++ b/virtio-devices/src/vsock/csm/txbuf.rs @@ -213,9 +213,7 @@ mod tests { fn test_push_wrap() { let mut txbuf = TxBuf::new(); let mut sink = TestSink::new(); - let mut tmp: Vec = Vec::new(); - - tmp.resize(TxBuf::SIZE - 2, 0); + let tmp: Vec = vec![0; TxBuf::SIZE - 2]; txbuf.push(tmp.as_slice()).unwrap(); txbuf.flush_to(&mut sink).unwrap(); sink.clear();