Skip to content

Commit

Permalink
nightly bump: cleanups made obvious by clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ppannuto committed Feb 26, 2025
1 parent b856c70 commit c2965c1
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,11 @@ impl IoWrite for Writer {
});
}
for &c in buf {
unsafe {
uart.send_byte(c);
}
unsafe { uart.send_byte(c) }
while !uart.tx_ready() {}
}
}
Writer::WriterRtt(rtt_memory) => {
rtt_memory.write_sync(buf);
}
Writer::WriterRtt(rtt_memory) => rtt_memory.write_sync(buf),
}
buf.len()
}
Expand Down
8 changes: 2 additions & 6 deletions boards/nordic/nrf52840dk/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,11 @@ impl IoWrite for Writer {
});
}
for &c in buf {
unsafe {
uart.send_byte(c);
}
unsafe { uart.send_byte(c) }
while !uart.tx_ready() {}
}
}
Writer::WriterRtt(rtt_memory) => {
rtt_memory.write_sync(buf);
}
Writer::WriterRtt(rtt_memory) => rtt_memory.write_sync(buf),
}
buf.len()
}
Expand Down
4 changes: 1 addition & 3 deletions boards/particle_boron/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ impl IoWrite for Writer {
});
}
for &c in buf {
unsafe {
uart.send_byte(c);
}
unsafe { uart.send_byte(c) }
while !uart.tx_ready() {}
}
}
Expand Down
2 changes: 1 addition & 1 deletion boards/raspberry_pi_pico/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ pub unsafe fn start() -> (
match peripherals.rtc.rtc_init() {
Ok(()) => {}
Err(e) => {
debug!("error starting rtc {:?}", e);
debug!("error starting rtc {:?}", e)
}
}

Expand Down
4 changes: 1 addition & 3 deletions boards/sma_q3/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ impl IoWrite for Writer {
fn write(&mut self, buf: &[u8]) -> usize {
match self {
Writer::Uninitialized => {}
Writer::WriterRtt(rtt_memory) => {
rtt_memory.write_sync(buf);
}
Writer::WriterRtt(rtt_memory) => rtt_memory.write_sync(buf),
}
buf.len()
}
Expand Down
6 changes: 3 additions & 3 deletions capsules/extra/src/ieee802154/framer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ impl<'a, M: Mac<'a>, A: AES128CCM<'a>> radio::RxClient for Framer<'a, M, A> {
}
};
self.rx_state.replace(next_state);
self.step_receive_state();
self.step_receive_state()
});
}
}
Expand Down Expand Up @@ -1000,7 +1000,7 @@ impl<'a, M: Mac<'a>, A: AES128CCM<'a>> CCMClient for Framer<'a, M, A> {
RxState::Idle
};
self.rx_state.replace(next_state);
self.step_receive_state();
self.step_receive_state()
}
other_state => {
rx_waiting = match other_state {
Expand All @@ -1022,7 +1022,7 @@ impl<'a, M: Mac<'a>, A: AES128CCM<'a>> CCMClient for Framer<'a, M, A> {
});
});
} else if rx_waiting {
self.step_receive_state();
self.step_receive_state()
}
}
}
33 changes: 14 additions & 19 deletions capsules/extra/src/lsm6dsoxtr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ impl<I: i2c::I2CDevice> i2c::I2CClient for Lsm6dsoxtrI2C<'_, I> {
let mut y: usize = 0;
let mut z: usize = 0;

if status == Ok(()) {
self.nine_dof_client.map(|nine_dof_client| {
self.nine_dof_client.map(|nine_dof_client| {
if status == Ok(()) {
let scale_factor = self.accel_scale.get() as usize;
x = ((((buffer[0] as u16 + ((buffer[1] as u16) << 8)) as i16) as isize)
* (SCALE_FACTOR_ACCEL[scale_factor] as isize)
Expand All @@ -440,12 +440,10 @@ impl<I: i2c::I2CDevice> i2c::I2CClient for Lsm6dsoxtrI2C<'_, I> {
* (SCALE_FACTOR_ACCEL[scale_factor] as isize)
/ 1000) as usize;
nine_dof_client.callback(x, y, z)
});
} else {
self.nine_dof_client.map(|client| {
client.callback(0, 0, 0);
});
}
} else {
nine_dof_client.callback(0, 0, 0)
}
});
self.buffer.replace(buffer);
self.i2c.disable();
self.state.set(State::Idle);
Expand All @@ -455,8 +453,8 @@ impl<I: i2c::I2CDevice> i2c::I2CClient for Lsm6dsoxtrI2C<'_, I> {
let mut x: usize = 0;
let mut y: usize = 0;
let mut z: usize = 0;
if status == Ok(()) {
self.nine_dof_client.map(|nine_dof_client| {
self.nine_dof_client.map(|nine_dof_client| {
if status == Ok(()) {
let scale_factor = self.gyro_range.get() as usize;
x = (((buffer[0] as u16 + ((buffer[1] as u16) << 8)) as i16) as isize
* (SCALE_FACTOR_GYRO[scale_factor] as isize)
Expand All @@ -469,12 +467,10 @@ impl<I: i2c::I2CDevice> i2c::I2CClient for Lsm6dsoxtrI2C<'_, I> {
* (SCALE_FACTOR_GYRO[scale_factor] as isize)
/ 100) as usize;
nine_dof_client.callback(x, y, z)
});
} else {
self.nine_dof_client.map(|client| {
client.callback(0, 0, 0);
});
}
} else {
nine_dof_client.callback(0, 0, 0)
}
});
self.buffer.replace(buffer);
self.i2c.disable();
self.state.set(State::Idle);
Expand All @@ -489,9 +485,8 @@ impl<I: i2c::I2CDevice> i2c::I2CClient for Lsm6dsoxtrI2C<'_, I> {
* 100) as i32),
Err(i2c_error) => Err(i2c_error.into()),
};
self.temperature_client.map(|client| {
client.callback(temperature);
});
self.temperature_client
.map(|client| client.callback(temperature));
self.buffer.replace(buffer);
self.i2c.disable();
self.state.set(State::Idle);
Expand Down
6 changes: 3 additions & 3 deletions capsules/extra/src/net/thread/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,9 @@ impl<'a, A: time::Alarm<'a>> CCMClient for ThreadNetworkDriver<'a, A> {
// Move the decrypted MLE message into the recv_buf and execute the receiving logic. Upon
// an error in `recv_logic`, joining the network fails and schedule termination upcall
self.recv_buffer.replace(assembled_subslice);
self.recv_logic(IPAddr(src_ipv6))
.err()
.map(|code| self.terminate_child_join(Err(code)));
if let Err(code) = self.recv_logic(IPAddr(src_ipv6)) {
self.terminate_child_join(Err(code))
}
}
_ => (),
}
Expand Down
8 changes: 2 additions & 6 deletions capsules/extra/src/public_key_crypto/rsa_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,7 @@ impl<const L: usize> RsaPrivKey for RSAKeys<L> {
if let Some(private_key) = self.private_key.take() {
match private_key {
MutImutBuffer::Mutable(ref _buf) => unreachable!(),
MutImutBuffer::Immutable(buf) => {
closure(buf);
}
MutImutBuffer::Immutable(buf) => closure(buf),
}
self.private_key.replace(private_key);
Some(())
Expand All @@ -328,9 +326,7 @@ impl<const L: usize> RsaPrivKeyMut for RSAKeys<L> {
fn map_exponent(&self, closure: &dyn Fn(&mut [u8])) -> Option<()> {
if let Some(mut private_key) = self.private_key.take() {
match private_key {
MutImutBuffer::Mutable(ref mut buf) => {
closure(buf);
}
MutImutBuffer::Mutable(ref mut buf) => closure(buf),
MutImutBuffer::Immutable(_buf) => unreachable!(),
}
self.private_key.replace(private_key);
Expand Down
25 changes: 10 additions & 15 deletions capsules/extra/src/st77xx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,21 +489,17 @@ impl<'a, A: Alarm<'a>, B: Bus<'a, BusAddr8>, P: Pin> ST77XX<'a, A, B, P> {
self.sequence_buffer.map_or_else(
|| panic!("st77xx: do next op has no sequence buffer"),
|sequence| match sequence[position] {
SendCommand::Nop => {
self.do_next_op();
}
SendCommand::Nop => self.do_next_op(),
SendCommand::Default(cmd) => {
self.send_command_with_default_parameters(cmd);
self.send_command_with_default_parameters(cmd)
}
SendCommand::Position(cmd, position, len) => {
self.send_command(cmd, position, len, 1);
self.send_command(cmd, position, len, 1)
}
SendCommand::Repeat(cmd, position, len, repeat) => {
self.send_command(cmd, position, len, repeat);
}
SendCommand::Slice(cmd, len) => {
self.send_command_slice(cmd, len);
self.send_command(cmd, position, len, repeat)
}
SendCommand::Slice(cmd, len) => self.send_command_slice(cmd, len),
},
);
} else {
Expand All @@ -512,23 +508,22 @@ impl<'a, A: Alarm<'a>, B: Bus<'a, BusAddr8>, P: Pin> ST77XX<'a, A, B, P> {
self.client.map(|client| {
self.power_on.set(true);

client.screen_is_ready();
client.screen_is_ready()
});
} else {
if self.setup_command.get() {
self.setup_command.set(false);
self.setup_client.map(|setup_client| {
setup_client.command_complete(Ok(()));
});
self.setup_client
.map(|setup_client| setup_client.command_complete(Ok(())));
} else {
self.client.map(|client| {
if self.write_buffer.is_some() {
self.write_buffer.take().map(|buffer| {
let data = SubSliceMut::new(buffer);
client.write_complete(data, Ok(()));
client.write_complete(data, Ok(()))
});
} else {
client.command_complete(Ok(()));
client.command_complete(Ok(()))
}
});
}
Expand Down
9 changes: 3 additions & 6 deletions capsules/extra/src/usb_hid_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,9 @@ impl<'a, U: usb_hid::UsbHid<'a, [u8; 64]>> SyscallDriver for UsbHidDriver<'a, U>
// a receive we return `ErrorCode::ALREADY`. If the
// receive fails we return an error.
if let Some(buf) = self.recv_buffer.take() {
match self.usb.receive_buffer(buf) {
Ok(()) => {}
Err((err, buffer)) => {
self.recv_buffer.replace(buffer);
return CommandReturn::failure(err);
}
if let Err((err, buffer)) = self.usb.receive_buffer(buf) {
self.recv_buffer.replace(buffer);
return CommandReturn::failure(err);
}
} else {
return CommandReturn::failure(ErrorCode::ALREADY);
Expand Down
6 changes: 3 additions & 3 deletions chips/earlgrey/src/plic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl Plic {
/// Disable specific interrupt.
pub fn disable(&self, index: u32) {
if index >= PLIC_IRQ_NUM as u32 {
panic!("Invalid IRQ: {}", index);
panic!("Invalid IRQ: {}", index)
}
let offset = (index / 32) as usize;
let mask = !(1 << (index % 32));
Expand Down Expand Up @@ -127,7 +127,7 @@ impl Plic {
/// Saved interrupts are cleared when `'complete()` is called.
pub unsafe fn save_interrupt(&self, index: u32) {
if index >= PLIC_IRQ_NUM as u32 {
panic!("Invalid IRQ: {}", index);
panic!("Invalid IRQ: {}", index)
}
let offset = (index / 32) as usize;
let mask = 1 << (index % 32);
Expand Down Expand Up @@ -158,7 +158,7 @@ impl Plic {
pub unsafe fn complete(&self, index: u32) {
self.registers.claim.set(index);
if index >= PLIC_IRQ_NUM as u32 {
panic!("Invalid IRQ: {}", index);
panic!("Invalid IRQ: {}", index)
}
let offset = (index / 32) as usize;
let mask = !(1 << (index % 32));
Expand Down
2 changes: 1 addition & 1 deletion chips/sam4l/src/usart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ impl<'a> USART<'a> {
let cd = system_frequency / baud_rate;
usart.registers.brgr.write(BaudRate::CD.val(cd));
}
_ => {}
UsartMode::Unused => {}
}
}

Expand Down
6 changes: 3 additions & 3 deletions kernel/src/hil/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub trait Hasher<'a, const L: usize> {
/// callback is fired.
/// On error the return value will contain a return code and the original data
/// The possible ErrorCodes are:
/// - BUSY: The system is busy performing an operation The caller should
/// - BUSY: The system is busy performing an operation. The caller should
/// expect a callback
/// - SIZE: The size of the `data` buffer is invalid
fn add_data(
Expand All @@ -69,7 +69,7 @@ pub trait Hasher<'a, const L: usize> {
/// callback is fired.
/// On error the return value will contain a return code and the original data
/// The possible ErrorCodes are:
/// - BUSY: The system is busy performing an operation The caller should
/// - BUSY: The system is busy performing an operation. The caller should
/// expect a callback
/// - SIZE: The size of the `data` buffer is invalid
fn add_mut_data(
Expand All @@ -85,7 +85,7 @@ pub trait Hasher<'a, const L: usize> {
/// If there is data from the `add_data()` command asynchronously waiting to
/// be written it will be written before the operation starts.
/// The possible ErrorCodes are:
/// - BUSY: The system is busy performing an operation The caller should
/// - BUSY: The system is busy performing an operation. The caller should
/// expect a callback
/// - SIZE: The size of the `data` buffer is invalid
fn run(&'a self, hash: &'static mut [u8; L]) -> Result<(), (ErrorCode, &'static mut [u8; L])>;
Expand Down
5 changes: 2 additions & 3 deletions kernel/src/scheduler/mlfq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ impl<'a, A: 'static + time::Alarm<'static>> MLFQSched<'a, A> {

fn redeem_all_procs(&self) {
for queue in self.processes.iter().skip(1) {
match queue.pop_head() {
Some(proc) => self.processes[0].push_tail(proc),
None => {}
if let Some(proc) = queue.pop_head() {
self.processes[0].push_tail(proc)
}
}
}
Expand Down
Loading

0 comments on commit c2965c1

Please sign in to comment.