From 854bd6bf65c959685e6effd4d393dc3f9265a98c Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Mon, 6 Jul 2026 23:47:00 +0100 Subject: [PATCH] devices: Fix clippy: unneeded late initialization ``` warning: unneeded late initialization --> devices/src/legacy/gpio_pl061.rs:258:9 | 258 | let value; | ^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init = note: `-D clippy::needless-late-init` implied by `-D clippy::all` ``` Signed-off-by: Rob Bradford --- devices/src/legacy/gpio_pl061.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/devices/src/legacy/gpio_pl061.rs b/devices/src/legacy/gpio_pl061.rs index 23ebc7795..8aba26296 100644 --- a/devices/src/legacy/gpio_pl061.rs +++ b/devices/src/legacy/gpio_pl061.rs @@ -255,16 +255,15 @@ impl Gpio { impl BusDevice for Gpio { fn read(&mut self, _base: u64, offset: u64, data: &mut [u8]) { - let value; let mut read_ok = true; - if (GPIO_ID_LOW..GPIO_ID_HIGH).contains(&offset) { + let value = if (GPIO_ID_LOW..GPIO_ID_HIGH).contains(&offset) { let index = ((offset - GPIO_ID_LOW) >> 2) as usize; - value = u32::from(GPIO_ID[index]); + u32::from(GPIO_ID[index]) } else if offset < OFS_DATA { - value = self.data & ((offset >> 2) as u32); + self.data & ((offset >> 2) as u32) } else { - value = match offset { + match offset { GPIODIR => self.dir, GPIOIS => self.isense, GPIOIBE => self.ibe, @@ -277,8 +276,8 @@ impl BusDevice for Gpio { read_ok = false; 0 } - }; - } + } + }; if read_ok && data.len() <= 4 { write_le_u32(data, value);