1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-20 05:18:08 +00:00

chore(core): fix rust warnings and clippy errors

[no changelog]
This commit is contained in:
tychovrahe 2024-01-09 12:12:20 +01:00 committed by TychoVrahe
parent 82cd9ca34e
commit 1c0da78536
10 changed files with 16 additions and 13 deletions

View File

@ -2,6 +2,7 @@
#![deny(clippy::all)] #![deny(clippy::all)]
#![allow(clippy::new_without_default)] #![allow(clippy::new_without_default)]
#![deny(unsafe_op_in_unsafe_fn)] #![deny(unsafe_op_in_unsafe_fn)]
#![allow(internal_features)]
// Allowing dead code not to cause a lot of warnings when building for a specific target // Allowing dead code not to cause a lot of warnings when building for a specific target
// (when building for TR, a lot of code only used in TT would get marked as unused). // (when building for TR, a lot of code only used in TT would get marked as unused).
#![allow(dead_code)] #![allow(dead_code)]

View File

@ -8,8 +8,7 @@ pub use ffi::{DISPLAY_RESX, DISPLAY_RESY};
#[cfg(feature = "framebuffer")] #[cfg(feature = "framebuffer")]
pub use ffi::{ pub use ffi::{
DISPLAY_FRAMEBUFFER_HEIGHT, DISPLAY_FRAMEBUFFER_OFFSET_X, DISPLAY_FRAMEBUFFER_OFFSET_Y, DISPLAY_FRAMEBUFFER_OFFSET_X, DISPLAY_FRAMEBUFFER_OFFSET_Y, DISPLAY_FRAMEBUFFER_WIDTH,
DISPLAY_FRAMEBUFFER_WIDTH,
}; };
#[cfg(all(feature = "framebuffer", not(feature = "framebuffer32bit")))] #[cfg(all(feature = "framebuffer", not(feature = "framebuffer32bit")))]

View File

@ -1,3 +1,5 @@
#![allow(unused_imports)]
use super::ffi; use super::ffi;
pub use ffi::{secbool, secfalse, sectrue}; pub use ffi::{secbool, secfalse, sectrue};

View File

@ -235,7 +235,7 @@ where
self.marked_for_clear = true; self.marked_for_clear = true;
let mut dummy_ctx = EventCtx::new(); let mut dummy_ctx = EventCtx::new();
let paint_msg = self.inner.event(&mut dummy_ctx, Event::RequestPaint); let paint_msg = self.inner.event(&mut dummy_ctx, Event::RequestPaint);
assert!(matches!(paint_msg, None)); assert!(paint_msg.is_none());
assert!(dummy_ctx.timers.is_empty()); assert!(dummy_ctx.timers.is_empty());
} }
msg msg

View File

@ -11,7 +11,6 @@ use crate::{
geometry::{Alignment2D, Offset, Point, Rect}, geometry::{Alignment2D, Offset, Point, Rect},
}, },
}; };
use core::cmp::max;
#[cfg(feature = "dma2d")] #[cfg(feature = "dma2d")]
use crate::{ use crate::{
@ -27,6 +26,8 @@ use crate::ui::display::{get_color_table, pixeldata};
#[cfg(feature = "framebuffer")] #[cfg(feature = "framebuffer")]
use crate::trezorhal::{buffers::BufferLine4bpp, dma2d::dma2d_setup_4bpp}; use crate::trezorhal::{buffers::BufferLine4bpp, dma2d::dma2d_setup_4bpp};
#[cfg(feature = "framebuffer")]
use core::cmp::max;
use super::Color; use super::Color;

View File

@ -132,7 +132,7 @@ extern "C" fn screen_install_confirm(
let mut fingerprint_buffer: [u8; 64] = [0; 64]; let mut fingerprint_buffer: [u8; 64] = [0; 64];
let fingerprint_str = unsafe { let fingerprint_str = unsafe {
let fingerprint_slice = core::slice::from_raw_parts(fingerprint as *const u8, 32); let fingerprint_slice = core::slice::from_raw_parts(fingerprint, 32);
hexlify(fingerprint_slice, &mut fingerprint_buffer); hexlify(fingerprint_slice, &mut fingerprint_buffer);
core::str::from_utf8_unchecked(fingerprint_buffer.as_ref()) core::str::from_utf8_unchecked(fingerprint_buffer.as_ref())
}; };

View File

@ -47,8 +47,8 @@ use super::{
AddressDetails, ButtonActions, ButtonDetails, ButtonLayout, ButtonPage, CancelConfirmMsg, AddressDetails, ButtonActions, ButtonDetails, ButtonLayout, ButtonPage, CancelConfirmMsg,
CancelInfoConfirmMsg, CoinJoinProgress, ConfirmHomescreen, Flow, FlowPages, Frame, CancelInfoConfirmMsg, CoinJoinProgress, ConfirmHomescreen, Flow, FlowPages, Frame,
Homescreen, Lockscreen, NumberInput, Page, PassphraseEntry, PinEntry, Progress, Homescreen, Lockscreen, NumberInput, Page, PassphraseEntry, PinEntry, Progress,
ScrollableContent, ScrollableFrame, ShareWords, ShowMore, SimpleChoice, WelcomeScreen, ScrollableContent, ScrollableFrame, ShareWords, ShowMore, SimpleChoice, WordlistEntry,
WordlistEntry, WordlistType, WordlistType,
}, },
constant, theme, constant, theme,
}; };

View File

@ -142,7 +142,7 @@ extern "C" fn screen_install_confirm(
let mut fingerprint_buffer: [u8; 64] = [0; 64]; let mut fingerprint_buffer: [u8; 64] = [0; 64];
let fingerprint_str = unsafe { let fingerprint_str = unsafe {
let fingerprint_slice = core::slice::from_raw_parts(fingerprint as *const u8, 32); let fingerprint_slice = core::slice::from_raw_parts(fingerprint, 32);
hexlify(fingerprint_slice, &mut fingerprint_buffer); hexlify(fingerprint_slice, &mut fingerprint_buffer);
core::str::from_utf8_unchecked(fingerprint_buffer.as_ref()) core::str::from_utf8_unchecked(fingerprint_buffer.as_ref())
}; };

View File

@ -541,7 +541,7 @@ pub fn homescreen_blurred(data: &mut dyn HomescreenDecompressor, texts: &[Homesc
let mut next_text_idx = 1; let mut next_text_idx = 1;
let mut text_info = let mut text_info =
homescreen_position_text(unwrap!(texts.get(0)), &mut text_buffer, &mut icon_data); homescreen_position_text(unwrap!(texts.first()), &mut text_buffer, &mut icon_data);
let mcu_height = data.get_height(); let mcu_height = data.get_height();
data.decompress(); data.decompress();
@ -671,7 +671,7 @@ pub fn homescreen(
} }
} else { } else {
next_text_idx += 1; next_text_idx += 1;
homescreen_position_text(unwrap!(texts.get(0)), &mut text_buffer, &mut icon_data) homescreen_position_text(unwrap!(texts.first()), &mut text_buffer, &mut icon_data)
}; };
set_window(screen()); set_window(screen());

View File

@ -32,7 +32,7 @@ use crate::{
}, },
Border, Component, Empty, FormattedText, Label, Never, Qr, Timeout, Border, Component, Empty, FormattedText, Label, Never, Qr, Timeout,
}, },
display::{self, tjpgd::jpeg_info}, display::tjpgd::jpeg_info,
geometry, geometry,
layout::{ layout::{
obj::{ComponentMsgObj, LayoutObj}, obj::{ComponentMsgObj, LayoutObj},
@ -50,9 +50,9 @@ use super::{
FidoMsg, Frame, FrameMsg, Homescreen, HomescreenMsg, IconDialog, Lockscreen, MnemonicInput, FidoMsg, Frame, FrameMsg, Homescreen, HomescreenMsg, IconDialog, Lockscreen, MnemonicInput,
MnemonicKeyboard, MnemonicKeyboardMsg, NumberInputDialog, NumberInputDialogMsg, MnemonicKeyboard, MnemonicKeyboardMsg, NumberInputDialog, NumberInputDialogMsg,
PassphraseKeyboard, PassphraseKeyboardMsg, PinKeyboard, PinKeyboardMsg, Progress, PassphraseKeyboard, PassphraseKeyboardMsg, PinKeyboard, PinKeyboardMsg, Progress,
SelectWordCount, SelectWordCountMsg, SelectWordMsg, SimplePage, Slip39Input, WelcomeScreen, SelectWordCount, SelectWordCountMsg, SelectWordMsg, SimplePage, Slip39Input,
}, },
constant, theme, theme,
}; };
impl TryFrom<CancelConfirmMsg> for Obj { impl TryFrom<CancelConfirmMsg> for Obj {