Skip to content

Commit

Permalink
Fix some more clippy lints
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Schaefer <[email protected]>
  • Loading branch information
JohnAZoidberg committed Jul 7, 2024
1 parent a80b6dd commit 63441d3
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion framework_lib/src/ccgx/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ fn read_version(
unsafe { std::ptr::read(data[0..version_len].as_ptr() as *const _) };

let base_version = BaseVersion::from(version_info.base_version);
let app_version = AppVersion::try_from(version_info.app_version).ok()?;
let app_version = AppVersion::from(version_info.app_version);

let fw_silicon_id = version_info.silicon_id;
let fw_silicon_family = version_info.silicon_family;
Expand Down
5 changes: 2 additions & 3 deletions framework_lib/src/ccgx/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use core::prelude::rust_2021::derive;

use crate::ccgx::{AppVersion, BaseVersion, ControllerVersion};
use crate::chromium_ec::command::EcCommands;
use crate::chromium_ec::{CrosEc, CrosEcDriver, EcError, EcResponseStatus, EcResult};
use crate::chromium_ec::{CrosEc, CrosEcDriver, EcError, EcResult};
use crate::util::{self, assert_win_len, Config, Platform};
use std::mem::size_of;

Expand Down Expand Up @@ -299,8 +299,7 @@ impl PdController {
let data = self.ccgx_read(register, 8)?;
Ok(ControllerVersion {
base: BaseVersion::from(&data[..4]),
app: AppVersion::try_from(&data[4..])
.or(Err(EcError::Response(EcResponseStatus::InvalidResponse)))?,
app: AppVersion::from(&data[4..]),
})
}

Expand Down
2 changes: 1 addition & 1 deletion framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ fn print_versions(ec: &CrosEc) {
println!("UEFI BIOS");
if let Some(smbios) = get_smbios() {
let bios_entries = smbios.collect::<SMBiosInformation>();
let bios = bios_entries.get(0).unwrap();
let bios = bios_entries.first().unwrap();
println!(" Version: {}", bios.version());
println!(" Release Date: {}", bios.release_date());
}
Expand Down
2 changes: 1 addition & 1 deletion framework_lib/src/smbios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub fn get_smbios() -> Option<SMBiosData> {
// Get the SMBIOS entrypoint address from the kernel environment
let addr_hex = kenv_get("hint.smbios.0.mem").ok()?;
let addr_hex = addr_hex.trim_start_matches("0x");
let addr = u64::from_str_radix(&addr_hex, 16).unwrap();
let addr = u64::from_str_radix(addr_hex, 16).unwrap();
trace!("SMBIOS Entrypoint Addr: {} 0x{:x}", addr_hex, addr);

let mut dev_mem = std::fs::File::open("/dev/mem").ok()?;
Expand Down
4 changes: 2 additions & 2 deletions framework_lib/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ pub unsafe fn any_as_mut_u8_slice<T: Sized>(p: &mut T) -> &mut [u8] {

/// Convert an array/slice of any type to a u8 slice (Like a C byte buffer)
pub unsafe fn any_vec_as_u8_slice<T: Sized>(p: &[T]) -> &[u8] {
let len = ::std::mem::size_of::<T>() * p.len();
::std::slice::from_raw_parts((p.as_ptr() as *const T) as *const u8, len)
let len = ::std::mem::size_of_val(p);
::std::slice::from_raw_parts(p.as_ptr() as *const u8, len)
}

/// Print a byte buffer as a series of hex bytes
Expand Down

0 comments on commit 63441d3

Please sign in to comment.