Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
Fixes warnings:
- deprecated
- clippy::collapsible_else_if
- clippy::empty_loop
- clippy::needless_borrow

The change from `llvm_asm!()` to `asm!()` uses explicit operands to
indicate to Rust that these are memory addresses, allowing it to drop
the casts.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
  • Loading branch information
crawfxrd committed Oct 24, 2021
1 parent dc9798d commit f1efa56
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
6 changes: 4 additions & 2 deletions src/app/bios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ impl BiosComponent {
}

println!("Halt");
loop {}
loop {
unsafe { asm!("cli", "hlt", options(nomem, nostack)); }
}
} else {
println!("Failed to locate EC");
}
Expand Down Expand Up @@ -376,7 +378,7 @@ impl Component for BiosComponent {
if ! matching {
spi.erase(i).unwrap();
if ! erased {
spi.write(i, &new_chunk).unwrap();
spi.write(i, new_chunk).unwrap();
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,8 @@ fn inner() -> Result<()> {
if success {
if find(IFLASHV).is_ok() {
// Do not reset DMI on meer5
} else {
if let Err(err) = reset_dmi() {
println!("Failed to reset DMI: {:?}", err);
}
} else if let Err(err) = reset_dmi() {
println!("Failed to reset DMI: {:?}", err);
}

if setup_menu {
Expand Down
28 changes: 16 additions & 12 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,22 +189,26 @@ impl<'a> Renderer for ScaledDisplay<'a> {
#[inline(always)]
#[cold]
pub unsafe fn fast_copy(dst: *mut u8, src: *const u8, len: usize) {
llvm_asm!("cld
rep movsb"
:
: "{rdi}"(dst as usize), "{rsi}"(src as usize), "{rcx}"(len)
: "cc", "memory", "rdi", "rsi", "rcx"
: "intel", "volatile");
asm!(
"cld",
"rep movsb [rdi], [rsi]",
inout("rdi") dst => _,
inout("rsi") src => _,
inout("rcx") len => _,
options(nostack)
);
}

#[cfg(target_arch = "x86_64")]
#[inline(always)]
#[cold]
pub unsafe fn fast_set32(dst: *mut u32, src: u32, len: usize) {
llvm_asm!("cld
rep stosd"
:
: "{rdi}"(dst as usize), "{eax}"(src), "{rcx}"(len)
: "cc", "memory", "rdi", "rcx"
: "intel", "volatile");
asm!(
"cld",
"rep stosd [rdi], eax",
inout("rdi") dst => _,
inout("eax") src => _,
inout("rcx") len => _,
options(nostack)
);
}
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![no_std]
#![no_main]
#![feature(llvm_asm)]
#![feature(asm)]
#![feature(prelude_import)]
#![feature(try_trait_v2)]
#![feature(control_flow_enum)]
Expand Down

0 comments on commit f1efa56

Please sign in to comment.