Skip to content

Commit

Permalink
Fix/ignore clippy warning
Browse files Browse the repository at this point in the history
Allow the following warnings:

- clippy::needless_range_loop
- clippy::single_match
- clippy::uninlined_format_args

Fix the following warnings:

- clippy::borrow_deref_ref
- clippy::should_implement_trait
- clippy::unnecessary_cast

Signed-off-by: Tim Crawford <tcrawford@system76.com>
  • Loading branch information
crawfxrd authored and jackpot51 committed Oct 3, 2023
1 parent 869995f commit 1f74c50
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/app/mapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ impl Mapper for UefiMapper {
address: PhysicalAddress,
_size: usize,
) -> Result<VirtualAddress, &'static str> {
Ok(VirtualAddress(address.0 as usize))
Ok(VirtualAddress(address.0))
}

unsafe fn unmap_aligned(
Expand Down
4 changes: 2 additions & 2 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ impl Display {
fast_copy(
data_ptr as *mut u8,
data_ptr.add(off1) as *const u8,
off2 as usize * 4,
off2 * 4,
);
fast_set32(data_ptr.add(off2), color.data, off1 as usize);
fast_set32(data_ptr.add(off2), color.data, off1);
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/image/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ impl Image {
})
}

/// Create a new empty image
pub fn default() -> Self {
Self::new(0, 0)
}

/// Get a piece of the image
pub fn roi(&self, x: u32, y: u32, w: u32, h: u32) -> ImageRoi {
let x1 = cmp::min(x, self.width());
Expand Down Expand Up @@ -106,6 +101,12 @@ impl Image {
}
}

impl Default for Image {
fn default() -> Self {
Self::new(0, 0)
}
}

impl Renderer for Image {
/// Get the width of the image in pixels
fn width(&self) -> u32 {
Expand Down
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#![allow(clippy::collapsible_if)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::needless_range_loop)]
#![allow(clippy::single_match)]
#![allow(clippy::uninlined_format_args)]

extern crate alloc;
#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion src/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl NullDisplay {
ClearScreen: clear_screen,
SetCursorPosition: set_cursor_position,
EnableCursor: enable_cursor,
Mode: unsafe { mem::transmute(&*mode.deref()) },
Mode: unsafe { mem::transmute(mode.deref()) },

mode,
}
Expand Down
4 changes: 2 additions & 2 deletions src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl<'a> TextDisplay<'a> {
ClearScreen: clear_screen,
SetCursorPosition: set_cursor_position,
EnableCursor: enable_cursor,
Mode: unsafe { mem::transmute(&*mode.deref()) },
Mode: unsafe { mem::transmute(mode.deref()) },

mode,
off_x: 0,
Expand Down Expand Up @@ -227,7 +227,7 @@ impl<'a> TextDisplay<'a> {
if scrolled {
let (cx, cw) = (0, self.display.width() as i32);
let (cy, ch) = (self.off_y, self.rows as u32 * 16);
self.display.blit(cx, cy, cw as u32, ch as u32);
self.display.blit(cx, cy, cw as u32, ch);
} else if changed {
let (_x, y) = self.pos();
let (cx, cw) = (0, self.display.width() as i32);
Expand Down

0 comments on commit 1f74c50

Please sign in to comment.