Skip to content

Commit

Permalink
Address clippy lints
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Spinale <[email protected]>
  • Loading branch information
nspin committed Jan 7, 2024
1 parent c55678b commit 02806fc
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/sel4-async/block-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ pub async fn read_bytes<T: BlockIO<A>, A: ReadAccess>(
pub async fn write_bytes<T: BlockIO<A>, A: ReadAccess + WriteAccess>(
io: &T,
offset: u64,
buf: &mut [u8],
buf: &[u8],
) -> Result<(), T::Error> {
read_or_write_bytes(io, offset, Operation::write(buf)).await
}
2 changes: 2 additions & 0 deletions crates/sel4-async/block-io/src/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ impl<'a, A: Access> Iterator for OperationChunks<'a, A> {
}

impl<'a> Operation<'a, ReadOnly> {
#[allow(clippy::explicit_auto_deref)]
pub fn as_read(&'a mut self) -> &'a mut [u8] {
match self {
Self::Read { buf, .. } => buf,
Expand All @@ -179,6 +180,7 @@ impl<'a> Operation<'a, ReadOnly> {
}

impl<'a> Operation<'a, WriteOnly> {
#[allow(clippy::explicit_auto_deref)]
pub fn as_write(&'a self) -> &'a [u8] {
match self {
Self::Read { witness, .. } => *witness,
Expand Down
6 changes: 5 additions & 1 deletion crates/sel4-async/time/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ impl TimerShared {
fn mark_expired(&mut self) {
assert!(!self.expired);
self.expired = true;
self.waker.take().map(Waker::wake);
if let Some(waker) = self.waker.take() {
waker.wake();
};
}
}

Expand All @@ -71,6 +73,7 @@ impl TimerManagerShared {
}

impl TimerManager {
#![allow(clippy::new_without_default)]
pub fn new() -> Self {
Self {
shared: Rc::new(RefCell::new(TimerManagerShared::new())),
Expand Down Expand Up @@ -155,6 +158,7 @@ pub struct Timeout<F> {
impl<F: Future> Future for Timeout<F> {
type Output = Result<F::Output, Elapsed>;

#[allow(clippy::redundant_pattern_matching)]
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.project();
if let Poll::Ready(v) = this.value.poll(cx) {
Expand Down
2 changes: 2 additions & 0 deletions crates/sel4-externally-shared/src/atomics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ impl<T, A> fmt::Debug for AtomicPtr<'_, T, A> {
}

impl<'a, T, A> AtomicPtr<'a, T, A> {
#[allow(clippy::missing_safety_doc)]
pub const unsafe fn new(pointer: NonNull<T>) -> Self {
AtomicPtr {
pointer,
Expand All @@ -62,6 +63,7 @@ impl<'a, T, A> AtomicPtr<'a, T, A> {
}
}

#[allow(clippy::missing_safety_doc)]
pub unsafe trait Atomic: AtomicSealed + Copy {
const IS_SIGNED: bool;
}
Expand Down
4 changes: 2 additions & 2 deletions crates/sel4-externally-shared/src/atomics/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ impl<'a, T: Atomic, A: Readable + Writable> AtomicPtr<'a, T, A> {
where
F: FnMut(T) -> Option<T>,
{
let mut prev = self.load(fetch_order.into());
let mut prev = self.load(fetch_order);
while let Some(next) = f(prev) {
match self.compare_exchange_weak(prev, next, set_order.into(), fetch_order.into()) {
match self.compare_exchange_weak(prev, next, set_order, fetch_order) {
x @ Ok(_) => return x,
Err(next_prev) => prev = next_prev,
}
Expand Down
2 changes: 2 additions & 0 deletions crates/sel4-externally-shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pub type ExternallySharedRef<'a, T, A = ReadWrite> = VolatileRef<'a, T, A, Exter
pub type ExternallySharedPtr<'a, T, A = ReadWrite> = VolatilePtr<'a, T, A, ExternallySharedOps>;

pub trait ExternallySharedRefExt<'a, T: ?Sized, A: Access> {
#[allow(clippy::missing_safety_doc)]
#[allow(clippy::new_ret_no_self)]
unsafe fn new(pointer: NonNull<T>) -> ExternallySharedRef<'a, T, A>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ impl<T: UnsignedPrimitiveWithUnorderedAtomics + Copy> UnitaryOps<T> for Unordere
}
}

#[allow(clippy::missing_safety_doc)]
pub unsafe trait UnsignedPrimitiveWithUnorderedAtomics {}

macro_rules! impl_unsigned_primitive_with_unordered_atomics {
Expand Down
1 change: 1 addition & 0 deletions crates/sel4-newlib/src/errno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub(crate) fn set_errno(err: c_int) {
}
}

#[allow(dead_code)]
pub(crate) mod values {
use super::*;

Expand Down
6 changes: 3 additions & 3 deletions crates/sel4-shared-ring-buffer/block-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<N, P: Access, A: AbstractBounceBufferAllocator, F: FnMut()>
async fn request<'a>(
&'a self,
start_block_idx: u64,
mut operation: Operation<'a, P>,
operation: Operation<'a, P>,
) -> Result<(), Error> {
let request_index = {
let sem = self.shared.borrow().owned.slot_set_semaphore().clone();
Expand All @@ -89,7 +89,7 @@ impl<N, P: Access, A: AbstractBounceBufferAllocator, F: FnMut()>
.issue_request(
&mut reservation,
start_block_idx,
&mut IssueRequestBuf::new(&mut operation),
&mut IssueRequestBuf::new(&operation),
)
.map_err(ErrorOrUserError::unwrap_error)?
};
Expand Down Expand Up @@ -147,7 +147,7 @@ pub struct RequestFuture<'a, N, P: Access, A: AbstractBounceBufferAllocator, F:
}

impl<'a, N, P: Access, A: AbstractBounceBufferAllocator, F: FnMut()> RequestFuture<'a, N, P, A, F> {
fn poll_inner<'b>(&'b mut self, cx: &mut Context<'_>) -> Poll<Result<(), Error>>
fn poll_inner<'b>(&'b mut self, cx: &Context<'_>) -> Poll<Result<(), Error>>
where
'a: 'b,
{
Expand Down
8 changes: 5 additions & 3 deletions crates/sel4-shared-ring-buffer/block-io/src/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl<S: SlotSemaphore, A: AbstractBounceBufferAllocator, F: FnMut()>
)
}

pub fn issue_request<'a>(
pub fn issue_request(
&mut self,
reservation: &mut SlotSetReservation<'_, S, NUM_SLOT_POOLS>,
start_block_idx: u64,
Expand Down Expand Up @@ -209,7 +209,7 @@ impl<S: SlotSemaphore, A: AbstractBounceBufferAllocator, F: FnMut()>

self.requests
.occupy(Occupied {
req: req.clone(),
req,
state: OccupiedState::Pending { waker: None },
})
.unwrap();
Expand Down Expand Up @@ -355,7 +355,9 @@ impl<S: SlotSemaphore, A: AbstractBounceBufferAllocator, F: FnMut()>
},
};

waker.map(Waker::wake);
if let Some(waker) = waker {
waker.wake();
}
}
OccupiedState::Canceled => {
let range = occupied.req.buf().encoded_addr_range();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub trait SlotSemaphore {
}

pub trait AsyncSlotSemaphore: SlotSemaphore {
#[allow(clippy::needless_lifetimes)]
fn take<'a>(
&'a self,
n: usize,
Expand Down Expand Up @@ -205,6 +206,7 @@ impl From<SlotCountTrackerError> for Error {
pub struct SlotSemaphoreClosedError(());

impl SlotSemaphoreClosedError {
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
Self(())
}
Expand All @@ -214,6 +216,7 @@ impl SlotSemaphoreClosedError {
pub struct SlotReservationExhaustedError(());

impl SlotReservationExhaustedError {
#![allow(clippy::new_without_default)]
pub fn new() -> Self {
Self(())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-shared-ring-buffer/smoltcp/src/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl<A: AbstractBounceBufferAllocator> Inner<A> {

while let Some(desc) = self.rx_ring_buffers.used_mut().dequeue()? {
let ix = desc.cookie();
if !(ix < self.rx_buffers.capacity()) {
if ix >= self.rx_buffers.capacity() {
return Err(PeerMisbehaviorError::OutOfBoundsCookie);
}

Expand Down

0 comments on commit 02806fc

Please sign in to comment.