From 1505d37b53352d891623f529b6a3d0df08e7319d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20L=C3=B3pez?= Date: Wed, 5 Feb 2025 13:00:51 +0100 Subject: [PATCH 1/4] aml_tester: fix clippy warnings --- aml_tester/src/main.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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"); From cc3744b576ae3d868b5db8853c9119d528404d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20L=C3=B3pez?= Date: Wed, 5 Feb 2025 13:05:53 +0100 Subject: [PATCH 2/4] aml: fix clippy warnings --- aml/src/value.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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())) } From 494c57d478673e8d44169fae1b6df5dfe142b344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20L=C3=B3pez?= Date: Wed, 5 Feb 2025 13:08:23 +0100 Subject: [PATCH 3/4] rsdp: fix clippy warnings --- rsdp/src/handler.rs | 4 ++++ 1 file changed, 4 insertions(+) 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, From 10d813949eae85d432a0e790ee02ebd8375c4e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20L=C3=B3pez?= Date: Wed, 5 Feb 2025 13:11:39 +0100 Subject: [PATCH 4/4] CI: run clippy for all packages and deny warnings Now that all clippy warnings have been fixed, simply run clippy for all packages in the workspace. While we are at it, emit an error on clippy warnings, which were previously being allowed. --- .github/workflows/build.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) 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