mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2025-12-29 00:41:19 +00:00
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<i32>` 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<i32>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
```
Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
parent
7cc433f50f
commit
4561096400
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user