diff --git a/framework_lib/src/commandline/mod.rs b/framework_lib/src/commandline/mod.rs index 49dce62a..196d2904 100644 --- a/framework_lib/src/commandline/mod.rs +++ b/framework_lib/src/commandline/mod.rs @@ -1725,6 +1725,8 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 { } } } + #[cfg(feature = "uefi")] + let _ = smartbattery_arg; } else if args.smartbattery_auth { #[cfg(not(feature = "uefi"))] { diff --git a/framework_lib/src/commandline/uefi.rs b/framework_lib/src/commandline/uefi.rs index 929673d6..11156448 100644 --- a/framework_lib/src/commandline/uefi.rs +++ b/framework_lib/src/commandline/uefi.rs @@ -121,7 +121,7 @@ pub fn parse(args: &[String]) -> Cli { host_command: None, }; - if args.len() == 0 { + if args.is_empty() { cli.help = true; } @@ -421,9 +421,9 @@ pub fn parse(args: &[String]) -> Cli { } else if arg == "--rgbkbd" { cli.rgbkbd = if args.len() > i + 2 { let mut colors = Vec::::new(); - for color_i in i + 1..args.len() { + for color in &args[i + 1..] { // TODO: Fail parsing instead of unwrap() - colors.push(args[color_i].parse::().unwrap()); + colors.push(color.parse::().unwrap()); } colors } else { @@ -758,8 +758,8 @@ pub fn parse(args: &[String]) -> Cli { let left = args[i + 1].parse::(); let right = args[i + 2].parse::(); let back = args[i + 3].parse::(); - if left.is_ok() && right.is_ok() && back.is_ok() { - Some((left.unwrap(), right.unwrap(), back.unwrap())) + if let (Ok(left), Ok(right), Ok(back)) = (left, right, back) { + Some((left, right, back)) } else { println!( "Invalid values for --pd-addrs: '{} {} {}'. Must be u16 integers.", @@ -779,8 +779,8 @@ pub fn parse(args: &[String]) -> Cli { let left = args[i + 1].parse::(); let right = args[i + 2].parse::(); let back = args[i + 3].parse::(); - if left.is_ok() && right.is_ok() && back.is_ok() { - Some((left.unwrap(), right.unwrap(), back.unwrap())) + if let (Ok(left), Ok(right), Ok(back)) = (left, right, back) { + Some((left, right, back)) } else { println!( "Invalid values for --pd-ports: '{} {} {}'. Must be u16 integers.", diff --git a/framework_uefi/src/main.rs b/framework_uefi/src/main.rs index a9e8f581..22b4e70c 100644 --- a/framework_uefi/src/main.rs +++ b/framework_uefi/src/main.rs @@ -11,6 +11,22 @@ extern crate alloc; use framework_lib::commandline; +/// Since Rust 1.99 (LLVM 23), loops that search for a NUL u16, like in +/// `CStr16::from_ptr`, are turned into calls to wcslen. +/// There's no libc on UEFI and compiler_builtins doesn't provide it. +/// +/// # Safety +/// `s` must point to a NUL-terminated UCS-2 string +#[no_mangle] +pub unsafe extern "C" fn wcslen(s: *const u16) -> usize { + let mut len = 0; + // Volatile read, so LLVM can't turn this loop into a call to itself + while core::ptr::read_volatile(s.add(len)) != 0 { + len += 1; + } + len +} + #[entry] fn main() -> Status { uefi::helpers::init().unwrap();