From 036af4abaa2a4ceea4f6194938fbf2008118aef1 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Sat, 4 Feb 2023 14:20:10 +0100 Subject: [PATCH] all: address clippy issues --- build/build.rs | 4 +++- jay-config/src/lib.rs | 6 +++++- src/async_engine.rs | 2 +- src/backends/x.rs | 1 + src/cursor.rs | 4 ++-- src/main.rs | 6 +++++- src/pipewire/pw_parser.rs | 4 ++-- src/portal/ptr_gui.rs | 3 +-- src/state.rs | 4 ++-- src/video/drm.rs | 2 +- 10 files changed, 23 insertions(+), 13 deletions(-) diff --git a/build/build.rs b/build/build.rs index 3aa67608..254ca1fc 100644 --- a/build/build.rs +++ b/build/build.rs @@ -8,7 +8,9 @@ clippy::unnecessary_to_owned, clippy::match_like_matches_macro, clippy::too_many_arguments, - clippy::iter_skip_next + clippy::iter_skip_next, + clippy::uninlined_format_args, + clippy::manual_is_ascii_check )] extern crate core; diff --git a/jay-config/src/lib.rs b/jay-config/src/lib.rs index 9a9bc913..6faf1c1f 100644 --- a/jay-config/src/lib.rs +++ b/jay-config/src/lib.rs @@ -34,7 +34,11 @@ //! config!(configure); //! ``` -#![allow(clippy::zero_prefixed_literal, clippy::manual_range_contains)] +#![allow( + clippy::zero_prefixed_literal, + clippy::manual_range_contains, + clippy::uninlined_format_args +)] use { crate::keyboard::ModifiedKeySym, diff --git a/src/async_engine.rs b/src/async_engine.rs index dfdbfb95..8efcf941 100644 --- a/src/async_engine.rs +++ b/src/async_engine.rs @@ -86,7 +86,7 @@ impl AsyncEngine { while self.num_queued.get() > 0 { self.iteration.fetch_add(1); let mut phase = 0; - while phase < NUM_PHASES as usize { + while phase < NUM_PHASES { self.queues[phase].swap(&mut *stash); if stash.is_empty() { phase += 1; diff --git a/src/backends/x.rs b/src/backends/x.rs index 4bb9562b..e746be61 100644 --- a/src/backends/x.rs +++ b/src/backends/x.rs @@ -920,6 +920,7 @@ impl XBackend { if changed { let images = self.create_images(output.window, width, height).await?; for (new, old) in images.iter().zip(output.images.iter()) { + #[allow(clippy::let_underscore_future)] let _ = self.c.call(&FreePixmap { pixmap: old.pixmap.get(), }); diff --git a/src/cursor.rs b/src/cursor.rs index aa1dbe9e..f98c1245 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -613,8 +613,8 @@ fn parser_cursor_file( }; let num_bytes = width as usize * height as usize * 4; unsafe { - image.pixels.reserve_exact(num_bytes as usize); - image.pixels.set_len(num_bytes as usize); + image.pixels.reserve_exact(num_bytes); + image.pixels.set_len(num_bytes); r.read_exact(slice::from_raw_parts_mut( image.pixels.as_mut_ptr() as _, num_bytes, diff --git a/src/main.rs b/src/main.rs index 43428a35..9246f5ae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,7 +35,11 @@ clippy::collapsible_match, clippy::field_reassign_with_default, clippy::new_ret_no_self, - clippy::or_fun_call + clippy::or_fun_call, + clippy::uninlined_format_args, + clippy::manual_is_ascii_check, + clippy::needless_borrow, + clippy::unnecessary_cast )] #[macro_use] diff --git a/src/pipewire/pw_parser.rs b/src/pipewire/pw_parser.rs index 78a71395..c878e7ec 100644 --- a/src/pipewire/pw_parser.rs +++ b/src/pipewire/pw_parser.rs @@ -218,7 +218,7 @@ impl<'a> PwParser<'a> { packed: bool, ) -> Result, PwParserError> { let size = if packed { len } else { (len + 7) & !7 }; - if self.len() < size as usize { + if self.len() < size { return Err(PwParserError::UnexpectedEof); } let val = match ty { @@ -278,7 +278,7 @@ impl<'a> PwParser<'a> { } _ => return Err(PwParserError::UnknownType(ty)), }; - self.pos += size as usize; + self.pos += size; Ok(val) } diff --git a/src/portal/ptr_gui.rs b/src/portal/ptr_gui.rs index 589877d1..19f4a9bf 100644 --- a/src/portal/ptr_gui.rs +++ b/src/portal/ptr_gui.rs @@ -210,8 +210,7 @@ impl GuiElement for Button { r.fill_boxes_f(&rects, &color); } if let Some(tex) = self.tex.get() { - let (tx, ty) = - r.scale_point_f(x1 + self.tex_off_x.get(), y1 as f32 + self.tex_off_y.get()); + let (tx, ty) = r.scale_point_f(x1 + self.tex_off_x.get(), y1 + self.tex_off_y.get()); r.render_texture( &tex, tx.round() as _, diff --git a/src/state.rs b/src/state.rs index 2a454ea3..e4979dfa 100644 --- a/src/state.rs +++ b/src/state.rs @@ -469,12 +469,12 @@ impl State { let mut x1 = output_rect.x1(); let mut y1 = output_rect.y1(); if width < output_rect.width() { - x1 += (output_rect.width() - width) as i32 / 2; + x1 += (output_rect.width() - width) / 2; } else { width = output_rect.width(); } if height < output_rect.height() { - y1 += (output_rect.height() - height) as i32 / 2; + y1 += (output_rect.height() - height) / 2; } else { height = output_rect.height(); } diff --git a/src/video/drm.rs b/src/video/drm.rs index d8902a82..8c9e8402 100644 --- a/src/video/drm.rs +++ b/src/video/drm.rs @@ -405,7 +405,7 @@ impl DrmMaster { } _ => {} } - buf = &buf[len as usize..]; + buf = &buf[len..]; } } Ok(self.events.pop())