Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
{
Expand Down
14 changes: 7 additions & 7 deletions framework_lib/src/commandline/uefi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub fn parse(args: &[String]) -> Cli {
host_command: None,
};

if args.len() == 0 {
if args.is_empty() {
cli.help = true;
}

Expand Down Expand Up @@ -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::<u64>::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::<u64>().unwrap());
colors.push(color.parse::<u64>().unwrap());
}
colors
} else {
Expand Down Expand Up @@ -758,8 +758,8 @@ pub fn parse(args: &[String]) -> Cli {
let left = args[i + 1].parse::<u16>();
let right = args[i + 2].parse::<u16>();
let back = args[i + 3].parse::<u16>();
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.",
Expand All @@ -779,8 +779,8 @@ pub fn parse(args: &[String]) -> Cli {
let left = args[i + 1].parse::<u8>();
let right = args[i + 2].parse::<u8>();
let back = args[i + 3].parse::<u8>();
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.",
Expand Down
16 changes: 16 additions & 0 deletions framework_uefi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading