diff --git a/framework_lib/src/ccgx/binary.rs b/framework_lib/src/ccgx/binary.rs index cdc1815..30d7b33 100644 --- a/framework_lib/src/ccgx/binary.rs +++ b/framework_lib/src/ccgx/binary.rs @@ -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; diff --git a/framework_lib/src/ccgx/device.rs b/framework_lib/src/ccgx/device.rs index 1b71359..83e3c07 100644 --- a/framework_lib/src/ccgx/device.rs +++ b/framework_lib/src/ccgx/device.rs @@ -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; @@ -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..]), }) } diff --git a/framework_lib/src/commandline/mod.rs b/framework_lib/src/commandline/mod.rs index 82a9665..a7d9db8 100644 --- a/framework_lib/src/commandline/mod.rs +++ b/framework_lib/src/commandline/mod.rs @@ -292,7 +292,7 @@ fn print_versions(ec: &CrosEc) { println!("UEFI BIOS"); if let Some(smbios) = get_smbios() { let bios_entries = smbios.collect::(); - let bios = bios_entries.get(0).unwrap(); + let bios = bios_entries.first().unwrap(); println!(" Version: {}", bios.version()); println!(" Release Date: {}", bios.release_date()); } diff --git a/framework_lib/src/smbios.rs b/framework_lib/src/smbios.rs index bd29ac6..e88d785 100644 --- a/framework_lib/src/smbios.rs +++ b/framework_lib/src/smbios.rs @@ -124,7 +124,7 @@ pub fn get_smbios() -> Option { // 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()?; diff --git a/framework_lib/src/util.rs b/framework_lib/src/util.rs index d2a4f2c..8bcdb5c 100644 --- a/framework_lib/src/util.rs +++ b/framework_lib/src/util.rs @@ -104,8 +104,8 @@ pub unsafe fn any_as_mut_u8_slice(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(p: &[T]) -> &[u8] { - let len = ::std::mem::size_of::() * 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