Skip to content

Commit

Permalink
Clippy fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
thejpster committed Aug 20, 2024
1 parent 71110b2 commit 8c33f26
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion neotron-os/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ fn main() {

if option_env!("ROMFS_PATH").is_some() {
println!("cargo::rustc-cfg=romfs_enabled=\"yes\"");
println!("cargo::rustc-check-cfg=cfg(romfs_enabled, values(\"yes\"))");
println!("cargo::rerun-if-env-changed=ROMFS_PATH");
}
println!("cargo::rustc-check-cfg=cfg(romfs_enabled, values(\"yes\"))");
}

/// Put the given script in our output directory and ensure it's on the linker
Expand Down
16 changes: 7 additions & 9 deletions neotron-os/src/commands/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn romfn(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, args: &[&str], ctx: &
osprintln!("No ROM available");
return;
};
if let Some(arg) = args.get(0) {
if let Some(arg) = args.first() {
let Some(entry) = romfs.find(arg) else {
osprintln!("Couldn't find {} in ROM", arg);
return;
Expand All @@ -199,14 +199,12 @@ fn romfn(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, args: &[&str], ctx: &
osprintln!("Error: {:?}", e);
}
} else {
for entry in romfs.into_iter() {
if let Ok(entry) = entry {
osprintln!(
"{} ({} bytes)",
entry.metadata.file_name,
entry.metadata.file_size
);
}
for entry in romfs.into_iter().flatten() {
osprintln!(
"{} ({} bytes)",
entry.metadata.file_name,
entry.metadata.file_size
);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions neotron-os/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ static STD_INPUT: CsRefCell<StdInput> = CsRefCell::new(StdInput::new());
static FILESYSTEM: fs::Filesystem = fs::Filesystem::new();

#[cfg(romfs_enabled = "yes")]
static ROMFS: &'static [u8] = include_bytes!(env!("ROMFS_PATH"));
static ROMFS: &[u8] = include_bytes!(env!("ROMFS_PATH"));

#[cfg(not(romfs_enabled = "yes"))]
static ROMFS: &'static [u8] = &[];
static ROMFS: &[u8] = &[];

// ===========================================================================
// Macros
Expand Down
1 change: 1 addition & 0 deletions neotron-os/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ impl TransientProgramArea {
// We support a maximum of four arguments.
#[allow(clippy::get_first)]
let ffi_args = [
#[allow(clippy::get_first)]
neotron_api::FfiString::new(args.get(0).unwrap_or(&"")),
neotron_api::FfiString::new(args.get(1).unwrap_or(&"")),
neotron_api::FfiString::new(args.get(2).unwrap_or(&"")),
Expand Down
2 changes: 1 addition & 1 deletion utilities/flames/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl App {

/// Generates a number in the range [0, limit)
fn random_up_to(&mut self, limit: usize) -> usize {
let buckets = ::core::usize::MAX / limit;
let buckets = usize::MAX / limit;
let upper_edge = buckets * limit;
loop {
let attempt = self.random();
Expand Down

0 comments on commit 8c33f26

Please sign in to comment.