From b9c877aa35a42f11550d59eb3865c55d5d8098a4 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Tue, 3 Oct 2023 12:02:31 +0000 Subject: [PATCH] Address clippy lints Signed-off-by: Nick Spinale --- Cargo.lock | 1 + .../microkit/http-server/pds/virtio-blk-driver/src/main.rs | 2 +- crates/private/meta/Cargo.toml | 1 + crates/private/meta/src/lib.rs | 1 + crates/sel4-async/block-io/fat/src/dummy_time_source.rs | 1 + crates/sel4-async/unsync/src/mutex.rs | 4 ++-- .../cli/src/bin/sel4-embed-debug-info.rs | 2 +- crates/sel4-kernel-loader/build.rs | 1 + crates/sel4-kernel-loader/embed-page-tables/src/embed.rs | 4 ++-- crates/sel4-kernel-loader/embed-page-tables/src/regions.rs | 6 +++--- crates/sel4-kernel-loader/embed-page-tables/src/table.rs | 2 +- crates/sel4-kernel-loader/payload-types/src/lib.rs | 2 ++ crates/sel4-kernel-loader/src/main.rs | 1 + crates/sel4-shared-ring-buffer/block-io/src/lib.rs | 1 + crates/sel4/src/bootinfo.rs | 2 ++ crates/sel4/src/invocations.rs | 2 ++ crates/sel4/sys/build/xml/invocations/mod.rs | 3 +++ .../cargo-manifest-sources/crates/private/meta/crate.nix | 1 + 18 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f7128cba8..b08aacc5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2447,6 +2447,7 @@ dependencies = [ "sel4-async-request-statuses", "sel4-async-single-threaded-executor", "sel4-async-timers", + "sel4-async-unsync", "sel4-bounce-buffer-allocator", "sel4-config", "sel4-externally-shared", diff --git a/crates/examples/microkit/http-server/pds/virtio-blk-driver/src/main.rs b/crates/examples/microkit/http-server/pds/virtio-blk-driver/src/main.rs index f8da7461e..2113b481d 100644 --- a/crates/examples/microkit/http-server/pds/virtio-blk-driver/src/main.rs +++ b/crates/examples/microkit/http-server/pds/virtio-blk-driver/src/main.rs @@ -208,7 +208,7 @@ impl Handler for HandlerImpl { CLIENT => match msg_info.recv_using_postcard::() { Ok(req) => match req { Request::GetNumBlocks => { - let num_blocks = self.dev.capacity().try_into().unwrap(); + let num_blocks = self.dev.capacity(); MessageInfo::send_using_postcard(GetNumBlocksResponse { num_blocks }) .unwrap() } diff --git a/crates/private/meta/Cargo.toml b/crates/private/meta/Cargo.toml index 8e658be45..f682caca8 100644 --- a/crates/private/meta/Cargo.toml +++ b/crates/private/meta/Cargo.toml @@ -20,6 +20,7 @@ sel4-async-network = { path = "../../sel4-async/network" } sel4-async-request-statuses = { path = "../../sel4-async/request-statuses" } sel4-async-single-threaded-executor = { path = "../../sel4-async/single-threaded-executor" } sel4-async-timers = { path = "../../sel4-async/timers" } +sel4-async-unsync = { path = "../../sel4-async/unsync" } sel4-bounce-buffer-allocator = { path = "../../sel4-bounce-buffer-allocator" } sel4-config = { path = "../../sel4/config" } sel4-immediate-sync-once-cell = { path = "../../sel4-immediate-sync-once-cell" } diff --git a/crates/private/meta/src/lib.rs b/crates/private/meta/src/lib.rs index 9284c8531..98279f4f2 100644 --- a/crates/private/meta/src/lib.rs +++ b/crates/private/meta/src/lib.rs @@ -81,6 +81,7 @@ definitely! { sel4_async_request_statuses sel4_async_single_threaded_executor sel4_async_timers + sel4_async_unsync sel4_bounce_buffer_allocator sel4_config sel4_externally_shared diff --git a/crates/sel4-async/block-io/fat/src/dummy_time_source.rs b/crates/sel4-async/block-io/fat/src/dummy_time_source.rs index c9a5ccd58..607a26c9d 100644 --- a/crates/sel4-async/block-io/fat/src/dummy_time_source.rs +++ b/crates/sel4-async/block-io/fat/src/dummy_time_source.rs @@ -1,5 +1,6 @@ pub use embedded_fat as fat; +#[derive(Default)] pub struct DummyTimeSource(()); impl DummyTimeSource { diff --git a/crates/sel4-async/unsync/src/mutex.rs b/crates/sel4-async/unsync/src/mutex.rs index b950b583f..6e4b33b51 100644 --- a/crates/sel4-async/unsync/src/mutex.rs +++ b/crates/sel4-async/unsync/src/mutex.rs @@ -39,12 +39,12 @@ impl Deref for Guard<'_, T> { type Target = T; fn deref(&self) -> &Self::Target { - &*self.ref_mut + &self.ref_mut } } impl DerefMut for Guard<'_, T> { fn deref_mut(&mut self) -> &mut Self::Target { - &mut *self.ref_mut + &mut self.ref_mut } } diff --git a/crates/sel4-backtrace/embedded-debug-info/cli/src/bin/sel4-embed-debug-info.rs b/crates/sel4-backtrace/embedded-debug-info/cli/src/bin/sel4-embed-debug-info.rs index 55a1487d5..982644772 100644 --- a/crates/sel4-backtrace/embedded-debug-info/cli/src/bin/sel4-embed-debug-info.rs +++ b/crates/sel4-backtrace/embedded-debug-info/cli/src/bin/sel4-embed-debug-info.rs @@ -78,5 +78,5 @@ fn with_bit_width>( input .concrete_patches .push(("embedded_debug_info_size".to_owned(), content_len)); - input.render_with_data(&image_elf).unwrap() + input.render_with_data(image_elf).unwrap() } diff --git a/crates/sel4-kernel-loader/build.rs b/crates/sel4-kernel-loader/build.rs index b22d80e1d..e8b1ee116 100644 --- a/crates/sel4-kernel-loader/build.rs +++ b/crates/sel4-kernel-loader/build.rs @@ -1,4 +1,5 @@ #![feature(int_roundings)] +#![allow(clippy::useless_conversion)] use std::env; use std::fs; diff --git a/crates/sel4-kernel-loader/embed-page-tables/src/embed.rs b/crates/sel4-kernel-loader/embed-page-tables/src/embed.rs index 191ad66c5..bfea8caa0 100644 --- a/crates/sel4-kernel-loader/embed-page-tables/src/embed.rs +++ b/crates/sel4-kernel-loader/embed-page-tables/src/embed.rs @@ -56,7 +56,7 @@ impl Embedding { } } - fn embed<'a, T: Scheme>(mut self, table: &'a Table) -> TokenStream { + fn embed(mut self, table: &Table) -> TokenStream { let _ = self.embed_inner(table); self.check_tables_order(); let runtime_mod_ident = self.runtime_mod_ident; @@ -82,7 +82,7 @@ impl Embedding { }); } - fn embed_inner<'a, T: Scheme>(&mut self, table: &'a Table) -> usize { + fn embed_inner(&mut self, table: &Table) -> usize { let index = self.allocate_index(); let entries = table.entries.iter().map(|entry| { let entry = EntryForEmbedding::::from_abstract_entry(entry); diff --git a/crates/sel4-kernel-loader/embed-page-tables/src/regions.rs b/crates/sel4-kernel-loader/embed-page-tables/src/regions.rs index d21b6f90b..fc99162fb 100644 --- a/crates/sel4-kernel-loader/embed-page-tables/src/regions.rs +++ b/crates/sel4-kernel-loader/embed-page-tables/src/regions.rs @@ -12,7 +12,7 @@ impl AbstractRegion { Self { range, content } } - fn to_arc(self) -> AbstractRegion> { + fn into_arc(self) -> AbstractRegion> { AbstractRegion { range: self.range, content: Arc::new(self.content), @@ -33,7 +33,7 @@ pub struct AbstractRegions { impl AbstractRegionsBuilder { pub fn new_with_background(background: AbstractRegion) -> Self { Self { - regions: vec![background.to_arc()], + regions: vec![background.into_arc()], } } @@ -67,7 +67,7 @@ impl AbstractRegionsBuilder { let new_regions = regions[..i_left] .iter() .chain( - [left, region.to_arc(), right] + [left, region.into_arc(), right] .iter() .filter(|r| r.range.start < r.range.end), ) diff --git a/crates/sel4-kernel-loader/embed-page-tables/src/table.rs b/crates/sel4-kernel-loader/embed-page-tables/src/table.rs index aa3a26262..0e947d525 100644 --- a/crates/sel4-kernel-loader/embed-page-tables/src/table.rs +++ b/crates/sel4-kernel-loader/embed-page-tables/src/table.rs @@ -125,7 +125,7 @@ where } fn current_content(&self) -> Option<&RegionContent> { - (&*self.current().content).as_ref() + (*self.current().content).as_ref() } fn advance(&mut self) -> bool { diff --git a/crates/sel4-kernel-loader/payload-types/src/lib.rs b/crates/sel4-kernel-loader/payload-types/src/lib.rs index 05719f74d..bf8e00b1f 100644 --- a/crates/sel4-kernel-loader/payload-types/src/lib.rs +++ b/crates/sel4-kernel-loader/payload-types/src/lib.rs @@ -1,6 +1,7 @@ #![no_std] #![feature(strict_provenance)] #![deny(unsafe_op_in_unsafe_fn)] +#![allow(clippy::useless_conversion)] use core::ops::Range; use core::ptr; @@ -117,6 +118,7 @@ impl<'a> RegionContent for DirectRegionContent<'a> { } impl Payload { + #[allow(clippy::missing_safety_doc)] pub unsafe fn copy_data_out(&self, region_content_source: &U::Source) { for region in self.data.iter() { let dst = unsafe { diff --git a/crates/sel4-kernel-loader/src/main.rs b/crates/sel4-kernel-loader/src/main.rs index df3ac4306..2b05673a5 100644 --- a/crates/sel4-kernel-loader/src/main.rs +++ b/crates/sel4-kernel-loader/src/main.rs @@ -11,6 +11,7 @@ #![feature(stdsimd)] #![allow(dead_code)] #![allow(unreachable_code)] +#![allow(clippy::reversed_empty_ranges)] use spin::RwLock; diff --git a/crates/sel4-shared-ring-buffer/block-io/src/lib.rs b/crates/sel4-shared-ring-buffer/block-io/src/lib.rs index 234bb9d6c..a4e65e825 100644 --- a/crates/sel4-shared-ring-buffer/block-io/src/lib.rs +++ b/crates/sel4-shared-ring-buffer/block-io/src/lib.rs @@ -2,6 +2,7 @@ #![feature(async_fn_in_trait)] #![feature(never_type)] #![feature(strict_provenance)] +#![allow(clippy::useless_conversion)] extern crate alloc; diff --git a/crates/sel4/src/bootinfo.rs b/crates/sel4/src/bootinfo.rs index 0587ac990..818b93be8 100644 --- a/crates/sel4/src/bootinfo.rs +++ b/crates/sel4/src/bootinfo.rs @@ -1,3 +1,5 @@ +#![allow(clippy::useless_conversion)] + use core::mem; use core::ops::Range; use core::slice; diff --git a/crates/sel4/src/invocations.rs b/crates/sel4/src/invocations.rs index db7a17034..96f9d9e68 100644 --- a/crates/sel4/src/invocations.rs +++ b/crates/sel4/src/invocations.rs @@ -1,3 +1,5 @@ +#![allow(clippy::useless_conversion)] + use core::mem; use sel4_config::{sel4_cfg, sel4_cfg_if}; diff --git a/crates/sel4/sys/build/xml/invocations/mod.rs b/crates/sel4/sys/build/xml/invocations/mod.rs index b56e171a6..274521d88 100644 --- a/crates/sel4/sys/build/xml/invocations/mod.rs +++ b/crates/sel4/sys/build/xml/invocations/mod.rs @@ -1,3 +1,6 @@ +#![allow(clippy::eq_op)] +#![allow(clippy::nonminimal_bool)] + use std::collections::BTreeMap; use std::fmt::Write; use std::ops::Range; diff --git a/hacking/cargo-manifest-sources/crates/private/meta/crate.nix b/hacking/cargo-manifest-sources/crates/private/meta/crate.nix index 7d4cf626c..c20f21706 100644 --- a/hacking/cargo-manifest-sources/crates/private/meta/crate.nix +++ b/hacking/cargo-manifest-sources/crates/private/meta/crate.nix @@ -20,6 +20,7 @@ mk { sel4-async-request-statuses sel4-async-single-threaded-executor sel4-async-timers + sel4-async-unsync sel4-bounce-buffer-allocator sel4-externally-shared sel4-immediate-sync-once-cell