From 456109640091a7a553e4da6281d7dee54d4e392d Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Mon, 31 Mar 2025 13:57:53 +0800 Subject: [PATCH] clippy: Fix clippy::dangling_pointers_from_temporaries Fix `clippy::dangling_pointers_from_temporaries` reported by clippy 0.1.85 (4d91de4e48 2025-02-17). Use slice instead of vector. ```console error: a dangling pointer will be produced because the temporary `std::vec::Vec` will be dropped --> vhost-device-spi/src/spi.rs:913:32 | 913 | tx_buf: vec![7, 4].as_ptr() as u64, | ---------- ^^^^^^ this pointer will immediately be invalid | | | this `std::vec::Vec` is deallocated at the end of the statement, bind it to a variable to extend its lifetime ``` Signed-off-by: Ruoqing He --- vhost-device-spi/src/spi.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vhost-device-spi/src/spi.rs b/vhost-device-spi/src/spi.rs index a973e5a..3fd3095 100644 --- a/vhost-device-spi/src/spi.rs +++ b/vhost-device-spi/src/spi.rs @@ -910,8 +910,8 @@ pub(crate) mod tests { // rdwr failure let mut reqs = [SpiIocTransfer { - tx_buf: vec![7, 4].as_ptr() as u64, - rx_buf: vec![7, 4].as_ptr() as u64, + tx_buf: [7, 4].as_ptr() as u64, + rx_buf: [7, 4].as_ptr() as u64, len: 2, speed_hz: 10000, delay_usecs: 0,