fix(clippy): make clippy = host libs + riscv programs (shared PROGRAMS); libkos alloc spinlock (was unlocked across threads); keystore Account; gpu Rect; factory Entry; Default impls, let-chains, div_ceil, iter loops

This commit is contained in:
2026-10-28 01:17:21 +01:00
parent 91f7d28834
commit c4871320a0
20 changed files with 188 additions and 134 deletions

View File

@@ -43,16 +43,30 @@ impl Path {
}
}
/// Up to `BATCH` entries of `dir`: names and whether each is a folder.
fn entries(fs: &mut Storage, dir: &Path) -> Option<([([u8; NAME], usize, bool); BATCH], usize)> {
let mut out = [([0u8; NAME], 0, false); BATCH];
/// One thing in a folder.
#[derive(Clone, Copy)]
struct Entry {
name: [u8; NAME],
len: usize,
is_dir: bool,
}
impl Entry {
fn name(&self) -> &[u8] {
&self.name[..self.len]
}
}
/// Up to `BATCH` entries of `dir`.
fn entries(fs: &mut Storage, dir: &Path) -> Option<([Entry; BATCH], usize)> {
let mut out = [Entry { name: [0; NAME], len: 0, is_dir: false }; BATCH];
let mut n = 0;
fs.list_dir(dir.as_bytes(), |e| {
let name = e.name();
if name != b"." && name != b".." && n < BATCH {
out[n].0[..name.len()].copy_from_slice(name);
out[n].1 = name.len();
out[n].2 = e.is_dir;
out[n].name[..name.len()].copy_from_slice(name);
out[n].len = name.len();
out[n].is_dir = e.is_dir;
n += 1;
}
})
@@ -83,9 +97,9 @@ fn copy_tree(fs: &mut Storage, from: &Path, to: &Path, buf: &mut [u8]) -> Result
// Nothing shipped for this area.
None => return Ok(()),
};
for (name, len, is_dir) in &list[..n] {
let (src, dst) = (from.join(&name[..*len]).ok_or("path too long")?, to.join(&name[..*len]).ok_or("path too long")?);
if *is_dir {
for entry in &list[..n] {
let (src, dst) = (from.join(entry.name()).ok_or("path too long")?, to.join(entry.name()).ok_or("path too long")?);
if entry.is_dir {
fs.mkdir(dst.as_bytes()).map_err(|_| "cannot make a folder")?;
copy_tree(fs, &src, &dst, buf)?;
} else {

View File

@@ -54,7 +54,7 @@ pub(crate) fn load_binary(
let page_start = segment.vaddr & !0xFFF;
let offset_in_page = segment.vaddr & 0xFFF;
let total_size = offset_in_page + segment.mem_size;
let seg_pages = (total_size + PAGE_SIZE - 1) / PAGE_SIZE;
let seg_pages = total_size.div_ceil(PAGE_SIZE);
let page_count = PageCount::new(u16::try_from(seg_pages).ok()?)?;
let local = libkos::window::request(page_count)?;