Skip to content

Commit 637acca

Browse files
committed
ci: fix clippy in all projects
1 parent 492c1f7 commit 637acca

File tree

12 files changed

+81
-71
lines changed

12 files changed

+81
-71
lines changed

esope-sld-c-w-s3/src/bin/main.rs

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use esp_hal::system::{CpuControl, Stack};
4949

5050
#[panic_handler]
5151
fn panic(_info: &core::panic::PanicInfo) -> ! {
52-
error!("Panic: {}", _info);
52+
error!("Panic: {_info}");
5353
loop {}
5454
}
5555

@@ -71,13 +71,13 @@ impl<C: PixelColor, const N: usize> HeapBuffer<C, N> {
7171
impl<C: PixelColor, const N: usize> core::ops::Deref for HeapBuffer<C, N> {
7272
type Target = [C; N];
7373
fn deref(&self) -> &Self::Target {
74-
&*self.0
74+
&self.0
7575
}
7676
}
7777

7878
impl<C: PixelColor, const N: usize> core::ops::DerefMut for HeapBuffer<C, N> {
7979
fn deref_mut(&mut self) -> &mut Self::Target {
80-
&mut *self.0
80+
&mut self.0
8181
}
8282
}
8383

@@ -135,10 +135,13 @@ fn update_game_of_life(
135135
}
136136
let nx = x as i32 + dx;
137137
let ny = y as i32 + dy;
138-
if nx >= 0 && nx < GRID_WIDTH as i32 && ny >= 0 && ny < GRID_HEIGHT as i32 {
139-
if current[ny as usize][nx as usize] > 0 {
140-
neighbors += 1;
141-
}
138+
if nx >= 0
139+
&& nx < GRID_WIDTH as i32
140+
&& ny >= 0
141+
&& ny < GRID_HEIGHT as i32
142+
&& current[ny as usize][nx as usize] > 0
143+
{
144+
neighbors += 1;
142145
}
143146
}
144147
}
@@ -208,7 +211,7 @@ fn write_generation<D: DrawTarget<Color = Rgb565>>(
208211
generation: usize,
209212
) -> Result<(), D::Error> {
210213
let mut num_str = String::<20>::new();
211-
write!(num_str, "{}", generation).unwrap();
214+
write!(num_str, "{generation}").unwrap();
212215
Text::new(
213216
num_str.as_str(),
214217
Point::new(8, 13),
@@ -252,14 +255,11 @@ async fn main(_spawner: Spawner) -> ! {
252255
eeprom.read_data(0x00, &mut eeid).unwrap();
253256
let display_width = u16::from_be_bytes([eeid[8], eeid[9]]) as usize;
254257
let display_height = u16::from_be_bytes([eeid[10], eeid[11]]) as usize;
255-
info!(
256-
"Display size from EEPROM: {}x{}",
257-
display_width, display_height
258-
);
258+
info!("Display size from EEPROM: {display_width}x{display_height}");
259259

260260
// Full-screen DMA constants
261261
const MAX_FRAME_BYTES: usize = 320 * 240 * 2;
262-
const MAX_NUM_DMA_DESC: usize = (MAX_FRAME_BYTES + CHUNK_SIZE - 1) / CHUNK_SIZE;
262+
const MAX_NUM_DMA_DESC: usize = MAX_FRAME_BYTES.div_ceil(CHUNK_SIZE);
263263

264264
#[unsafe(link_section = ".dma")]
265265
static mut TX_DESCRIPTORS: [DmaDescriptor; MAX_NUM_DMA_DESC] =
@@ -273,7 +273,7 @@ async fn main(_spawner: Spawner) -> ! {
273273
unsafe { core::slice::from_raw_parts_mut(fb_ptr as *mut u8, FRAME_BYTES) };
274274
// Verify PSRAM buffer allocation and alignment
275275
let buf_ptr = psram_buf.as_ptr() as usize;
276-
info!("PSRAM buffer allocated at address: 0x{:08X}", buf_ptr);
276+
info!("PSRAM buffer allocated at address: 0x{buf_ptr:08X}");
277277
info!("PSRAM buffer length: {}", psram_buf.len());
278278
info!("PSRAM buffer alignment modulo 32: {}", buf_ptr % 32);
279279
assert!(
@@ -322,14 +322,14 @@ async fn main(_spawner: Spawner) -> ! {
322322

323323
// Log all infomration about display configuration
324324
info!("Display configuration:");
325-
info!(" Resolution: {}x{}", h_res, v_res);
326-
info!(" PCLK: {} Hz", pclk_hz);
327-
info!(" HSYNC pulse: {} pixels", hsync_pulse);
328-
info!(" HSYNC back porch: {} pixels", hsync_back);
329-
info!(" HSYNC front porch: {} pixels", hsync_front);
330-
info!(" VSYNC pulse: {} lines", vsync_pulse);
331-
info!(" VSYNC back porch: {} lines", vsync_back);
332-
info!(" VSYNC front porch: {} lines", vsync_front);
325+
info!(" Resolution: {h_res}x{v_res}");
326+
info!(" PCLK: {pclk_hz} Hz");
327+
info!(" HSYNC pulse: {hsync_pulse} pixels");
328+
info!(" HSYNC back porch: {hsync_back} pixels");
329+
info!(" HSYNC front porch: {hsync_front} pixels");
330+
info!(" VSYNC pulse: {vsync_pulse} lines");
331+
info!(" VSYNC back porch: {vsync_back} lines");
332+
info!(" VSYNC front porch: {vsync_front} lines");
333333

334334
let dpi_config = DpiConfig::default()
335335
.with_clock_mode(ClockMode {
@@ -482,11 +482,11 @@ async fn dma_display_task(mut dpi: Dpi<'static, esp_hal::Blocking>, mut dma_tx:
482482
dpi = new_dpi;
483483
dma_tx = new_dma_tx;
484484
if let Err(e) = res {
485-
error!("[CORE 1] DMA transfer error: {:?}", e);
485+
error!("[CORE 1] DMA transfer error: {e:?}");
486486
}
487487
}
488488
Err((e, new_dpi, new_dma_tx)) => {
489-
error!("[CORE 1] DMA send error: {:?}", e);
489+
error!("[CORE 1] DMA send error: {e:?}");
490490
dpi = new_dpi;
491491
dma_tx = new_dma_tx;
492492
}
@@ -501,14 +501,10 @@ async fn conway_task(psram_ptr: *mut u8, _psram_len: usize, mut rng: Rng) {
501501
let fb: &mut [Rgb565; LCD_BUFFER_SIZE] =
502502
unsafe { &mut *(psram_ptr as *mut [Rgb565; LCD_BUFFER_SIZE]) };
503503
let mut game_grid = Box::new([[0u8; GRID_WIDTH]; GRID_HEIGHT]);
504-
randomize_grid(&mut rng, &mut *game_grid);
504+
randomize_grid(&mut rng, &mut game_grid);
505505
let mut next_grid = Box::new([[0u8; GRID_WIDTH]; GRID_HEIGHT]);
506506

507-
let mut frame_buf = FrameBuf::new(
508-
PSRAMFrameBuffer::new(fb),
509-
LCD_H_RES_USIZE.into(),
510-
LCD_V_RES_USIZE.into(),
511-
);
507+
let mut frame_buf = FrameBuf::new(PSRAMFrameBuffer::new(fb), LCD_H_RES_USIZE, LCD_V_RES_USIZE);
512508
let mut ticker = Ticker::every(embassy_time::Duration::from_millis(100));
513509
let mut generation_count: usize = 0;
514510
const RESET_AFTER_GENERATIONS: usize = 500;
@@ -519,13 +515,13 @@ async fn conway_task(psram_ptr: *mut u8, _psram_len: usize, mut rng: Rng) {
519515
// Cpu::current() as usize
520516
// );
521517

522-
update_game_of_life(&*game_grid, &mut *next_grid);
518+
update_game_of_life(&game_grid, &mut next_grid);
523519
core::mem::swap(&mut game_grid, &mut next_grid);
524-
draw_grid(&mut frame_buf, &*game_grid).ok();
520+
draw_grid(&mut frame_buf, &game_grid).ok();
525521
generation_count += 1;
526522
write_generation(&mut frame_buf, generation_count).ok();
527523
if generation_count >= RESET_AFTER_GENERATIONS {
528-
randomize_grid(&mut rng, &mut *game_grid);
524+
randomize_grid(&mut rng, &mut game_grid);
529525
generation_count = 0;
530526
}
531527
ticker.next().await;

esp32-c3-lcdkit/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ impl<C: PixelColor, const N: usize> HeapBuffer<C, N> {
5454
impl<C: PixelColor, const N: usize> core::ops::Deref for HeapBuffer<C, N> {
5555
type Target = [C; N];
5656
fn deref(&self) -> &Self::Target {
57-
&*self.0
57+
&self.0
5858
}
5959
}
6060

6161
impl<C: PixelColor, const N: usize> core::ops::DerefMut for HeapBuffer<C, N> {
6262
fn deref_mut(&mut self) -> &mut Self::Target {
63-
&mut *self.0
63+
&mut self.0
6464
}
6565
}
6666

@@ -221,7 +221,7 @@ fn write_generation<D: DrawTarget<Color = Rgb565>>(
221221
let y = 140;
222222

223223
let mut num_str = heapless::String::<20>::new();
224-
write!(num_str, "Generation: {}", generation).unwrap();
224+
write!(num_str, "Generation: {generation}").unwrap();
225225
Text::new(
226226
num_str.as_str(),
227227
Point::new(x, y),
@@ -355,6 +355,7 @@ fn main() -> ! {
355355
init_logger_from_env();
356356

357357
// --- DMA Buffers for SPI ---
358+
#[allow(clippy::manual_div_ceil)]
358359
let (rx_buffer, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(1024);
359360
let dma_rx_buf = DmaRxBuf::new(rx_descriptors, rx_buffer).unwrap();
360361
let dma_tx_buf = DmaTxBuf::new(tx_descriptors, tx_buffer).unwrap();

esp32-s3-box-3-minimal/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn write_generation<D: DrawTarget<Color = Rgb565>>(
4949
let mut num_str = String::<20>::new();
5050
// Write the generation number into the string
5151
// unwrap is safe here since we know the number is at most 20 characters
52-
write!(num_str, "{}", generation).unwrap();
52+
write!(num_str, "{generation}").unwrap();
5353
// Create the text drawable with the generation number
5454
Text::new(
5555
num_str.as_str(),

esp32-s3-box-3/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ impl<C: PixelColor, const N: usize> HeapBuffer<C, N> {
5353
impl<C: PixelColor, const N: usize> core::ops::Deref for HeapBuffer<C, N> {
5454
type Target = [C; N];
5555
fn deref(&self) -> &Self::Target {
56-
&*self.0
56+
&self.0
5757
}
5858
}
5959

6060
impl<C: PixelColor, const N: usize> core::ops::DerefMut for HeapBuffer<C, N> {
6161
fn deref_mut(&mut self) -> &mut Self::Target {
62-
&mut *self.0
62+
&mut self.0
6363
}
6464
}
6565

@@ -217,7 +217,7 @@ fn write_generation<D: DrawTarget<Color = Rgb565>>(
217217
generation: usize,
218218
) -> Result<(), D::Error> {
219219
let mut num_str = heapless::String::<20>::new();
220-
write!(num_str, "{}", generation).unwrap();
220+
write!(num_str, "{generation}").unwrap();
221221
Text::new(
222222
num_str.as_str(),
223223
Point::new(8, 13),
@@ -325,6 +325,7 @@ fn main() -> ! {
325325
init_logger_from_env();
326326

327327
// --- DMA Buffers for SPI ---
328+
#[allow(clippy::manual_div_ceil)]
328329
let (rx_buffer, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(8912);
329330
let dma_rx_buf = DmaRxBuf::new(rx_descriptors, rx_buffer).unwrap();
330331
let dma_tx_buf = DmaTxBuf::new(tx_descriptors, tx_buffer).unwrap();

esp32-s3-lcd-ev-board/src/main.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use log::{error, info};
3636

3737
#[panic_handler]
3838
fn panic(_info: &core::panic::PanicInfo) -> ! {
39-
error!("Panic: {}", _info);
39+
error!("Panic: {_info}");
4040
loop {}
4141
}
4242

@@ -231,13 +231,13 @@ impl<C: PixelColor, const N: usize> HeapBuffer<C, N> {
231231
impl<C: PixelColor, const N: usize> core::ops::Deref for HeapBuffer<C, N> {
232232
type Target = [C; N];
233233
fn deref(&self) -> &Self::Target {
234-
&*self.0
234+
&self.0
235235
}
236236
}
237237

238238
impl<C: PixelColor, const N: usize> core::ops::DerefMut for HeapBuffer<C, N> {
239239
fn deref_mut(&mut self) -> &mut Self::Target {
240-
&mut *self.0
240+
&mut self.0
241241
}
242242
}
243243

@@ -352,6 +352,7 @@ const LCD_BUFFER_SIZE: usize = 480 * 480;
352352
// Size of the entire frame in bytes (2 bytes per pixel)
353353
const FRAME_BYTES: usize = BUFFER_SIZE * 2;
354354
// Number of descriptors needed, each up to CHUNK_SIZE (4095)
355+
#[allow(clippy::manual_div_ceil)]
355356
const NUM_DMA_DESC: usize = (FRAME_BYTES + CHUNK_SIZE - 1) / CHUNK_SIZE;
356357

357358
/// Place the descriptor(s) in DMA-capable RAM.
@@ -438,6 +439,7 @@ fn main() -> ! {
438439
}
439440
}
440441
}
442+
#[allow(clippy::drop_non_drop)]
441443
drop(vsync_must_be_high_during_setup);
442444

443445
// Set up DMA channel for LCD
@@ -552,11 +554,11 @@ fn main() -> ! {
552554
dpi = dpi2;
553555
dma_tx = buf2;
554556
if let Err(e) = res {
555-
error!("DMA error: {:?}", e);
557+
error!("DMA error: {e:?}");
556558
}
557559
}
558560
Err((e, dpi2, buf2)) => {
559-
error!("DMA send error: {:?}", e);
561+
error!("DMA send error: {e:?}");
560562
dpi = dpi2;
561563
dma_tx = buf2;
562564
}

esp32-wrover-kit/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ impl<C: PixelColor, const N: usize> HeapBuffer<C, N> {
7777
impl<C: PixelColor, const N: usize> core::ops::Deref for HeapBuffer<C, N> {
7878
type Target = [C; N];
7979
fn deref(&self) -> &Self::Target {
80-
&*self.0
80+
&self.0
8181
}
8282
}
8383

8484
impl<C: PixelColor, const N: usize> core::ops::DerefMut for HeapBuffer<C, N> {
8585
fn deref_mut(&mut self) -> &mut Self::Target {
86-
&mut *self.0
86+
&mut self.0
8787
}
8888
}
8989

@@ -224,7 +224,7 @@ fn write_generation<D: DrawTarget<Color = Rgb565>>(
224224
generation: usize,
225225
) -> Result<(), D::Error> {
226226
let mut num_str = heapless::String::<20>::new();
227-
write!(num_str, "{}", generation).unwrap();
227+
write!(num_str, "{generation}").unwrap();
228228
Text::new(
229229
num_str.as_str(),
230230
Point::new(8, 13),
@@ -332,6 +332,7 @@ fn main() -> ! {
332332
init_logger_from_env();
333333

334334
// --- DMA Buffers for SPI ---
335+
#[allow(clippy::manual_div_ceil)]
335336
let (rx_buffer, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(8912);
336337
let dma_rx_buf = DmaRxBuf::new(rx_descriptors, rx_buffer).unwrap();
337338
let dma_tx_buf = DmaTxBuf::new(tx_descriptors, tx_buffer).unwrap();

m5stack-atom-s3/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ impl<C: PixelColor, const N: usize> HeapBuffer<C, N> {
5656
impl<C: PixelColor, const N: usize> core::ops::Deref for HeapBuffer<C, N> {
5757
type Target = [C; N];
5858
fn deref(&self) -> &Self::Target {
59-
&*self.0
59+
&self.0
6060
}
6161
}
6262

6363
impl<C: PixelColor, const N: usize> core::ops::DerefMut for HeapBuffer<C, N> {
6464
fn deref_mut(&mut self) -> &mut Self::Target {
65-
&mut *self.0
65+
&mut self.0
6666
}
6767
}
6868

@@ -220,7 +220,7 @@ fn write_generation<D: DrawTarget<Color = Rgb565>>(
220220
generation: usize,
221221
) -> Result<(), D::Error> {
222222
let mut num_str = heapless::String::<20>::new();
223-
write!(num_str, "{}", generation).unwrap();
223+
write!(num_str, "{generation}").unwrap();
224224
Text::new(
225225
num_str.as_str(),
226226
Point::new(8, 13),
@@ -356,6 +356,7 @@ fn main() -> ! {
356356
init_logger_from_env();
357357

358358
// --- DMA Buffers for SPI ---
359+
#[allow(clippy::manual_div_ceil)]
359360
let (rx_buffer, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(8912);
360361
let dma_rx_buf = DmaRxBuf::new(rx_descriptors, rx_buffer).unwrap();
361362
let dma_tx_buf = DmaTxBuf::new(tx_descriptors, tx_buffer).unwrap();

m5stack-cores3/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ impl<C: PixelColor, const N: usize> HeapBuffer<C, N> {
5959
impl<C: PixelColor, const N: usize> core::ops::Deref for HeapBuffer<C, N> {
6060
type Target = [C; N];
6161
fn deref(&self) -> &Self::Target {
62-
&*self.0
62+
&self.0
6363
}
6464
}
6565

6666
impl<C: PixelColor, const N: usize> core::ops::DerefMut for HeapBuffer<C, N> {
6767
fn deref_mut(&mut self) -> &mut Self::Target {
68-
&mut *self.0
68+
&mut self.0
6969
}
7070
}
7171

@@ -254,7 +254,7 @@ fn write_generation<D: DrawTarget<Color = Rgb565>>(
254254
generation: usize,
255255
) -> Result<(), D::Error> {
256256
let mut num_str = heapless::String::<20>::new();
257-
write!(num_str, "{}", generation).unwrap();
257+
write!(num_str, "{generation}").unwrap();
258258
Text::new(
259259
num_str.as_str(),
260260
Point::new(8, 13),
@@ -323,6 +323,7 @@ fn main() -> ! {
323323
init_logger_from_env();
324324

325325
// --- DMA Buffers for SPI ---
326+
#[allow(clippy::manual_div_ceil)]
326327
let (rx_buffer, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(8912);
327328
let dma_rx_buf = DmaRxBuf::new(rx_descriptors, rx_buffer).unwrap();
328329
let dma_tx_buf = DmaTxBuf::new(tx_descriptors, tx_buffer).unwrap();

0 commit comments

Comments
 (0)