diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d20a65fb..202f30e1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,6 +67,8 @@ jobs: clippy: runs-on: ubuntu-latest + env: + RUSTFLAGS: "-Dwarnings" steps: - uses: actions/checkout@v2 with: @@ -79,14 +81,8 @@ jobs: profile: minimal components: clippy - - name: Run clippy (ACPI) - run: cargo clippy -p acpi - - - name: Run clippy (ACPI tests) - run: cargo clippy -p acpi --tests - - - name: Run clippy (AML) - run: cargo clippy -p aml + - name: Run clippy + run: cargo clippy --all - - name: Run clippy (AML tests) - run: cargo clippy -p aml --tests + - name: Run clippy (tests) + run: cargo clippy --all --tests diff --git a/aml/src/value.rs b/aml/src/value.rs index 4da19842..07fd715f 100644 --- a/aml/src/value.rs +++ b/aml/src/value.rs @@ -494,7 +494,7 @@ impl AmlValue { */ let bits_to_copy = cmp::min(length, 64); bitslice[offset..(offset + bits_to_copy)] - .copy_from_bitslice(&value.to_le_bytes().view_bits()[..(bits_to_copy as usize)]); + .copy_from_bitslice(&value.to_le_bytes().view_bits()[..(bits_to_copy)]); // Zero extend to the end of the buffer field bitslice[(offset + bits_to_copy)..(offset + length)].fill(false); Ok(()) @@ -514,7 +514,7 @@ impl AmlValue { let value_data = value.lock(); let bits_to_copy = cmp::min(length, value_data.len() * 8); bitslice[offset..(offset + bits_to_copy)] - .copy_from_bitslice(&value_data.view_bits()[..(bits_to_copy as usize)]); + .copy_from_bitslice(&value_data.view_bits()[..(bits_to_copy)]); // Zero extend to the end of the buffer field bitslice[(offset + bits_to_copy)..(offset + length)].fill(false); Ok(()) @@ -560,7 +560,7 @@ impl Args { } let mut args: Vec> = list.into_iter().map(Option::Some).collect(); - args.extend(core::iter::repeat(None).take(7 - args.len())); + args.extend(core::iter::repeat_n(None, 7 - args.len())); Ok(Args(args.try_into().unwrap())) } diff --git a/aml_tester/src/main.rs b/aml_tester/src/main.rs index 50fab073..75e6aac2 100644 --- a/aml_tester/src/main.rs +++ b/aml_tester/src/main.rs @@ -13,7 +13,7 @@ use aml::{AmlContext, DebugVerbosity}; use clap::{Arg, ArgAction, ArgGroup}; use std::{ cell::RefCell, - collections::{HashMap, HashSet}, + collections::HashSet, ffi::OsStr, fs::{self, File}, io::{Read, Write}, @@ -55,8 +55,8 @@ fn main() -> std::io::Result<()> { println!("Running tests in directory: {:?}", dir_path); fs::read_dir(dir_path)? .filter_map(|entry| { - if entry.is_ok() { - Some(entry.unwrap().path().to_string_lossy().to_string()) + if let Ok(entry) = entry { + Some(entry.path().to_string_lossy().to_string()) } else { None } @@ -67,15 +67,18 @@ fn main() -> std::io::Result<()> { }; // Make sure all files exist, propagate error if it occurs - files.iter().fold(Ok(()), |result: std::io::Result<()>, file| { + let mut result = Ok(()); + for file in files.iter() { let path = Path::new(file); if !path.is_file() { println!("Not a regular file: {}", file); // Get the io error if there is one - path.metadata()?; + if let Err(e) = path.metadata() { + result = Err(e); + } } - result - })?; + } + result?; // Make sure we have the ability to compile ASL -> AML, if user wants it let user_wants_compile = !matches.get_flag("no_compile"); diff --git a/rsdp/src/handler.rs b/rsdp/src/handler.rs index 6cc0cd05..36b923f7 100644 --- a/rsdp/src/handler.rs +++ b/rsdp/src/handler.rs @@ -33,6 +33,10 @@ where /// than `region_length`, due to requirements of the paging system or other reasoning. /// - `handler` should be the same `AcpiHandler` that created the mapping. When the `PhysicalMapping` is /// dropped, it will be used to unmap the structure. + /// + /// # Safety + /// + /// The caller must make sure that the parameters correctly represent an existing mapping. pub unsafe fn new( physical_start: usize, virtual_start: NonNull,