Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
lulf committed Apr 10, 2024
1 parent dab2c20 commit 8fd359a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions host/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ where
C: AsyncCmd,
T: ControllerCmdAsync<C>,
{
let ret = cmd.exec(&self.controller).await?;
Ok(ret)
cmd.exec(&self.controller).await?;
Ok(())
}

pub(crate) async fn connect(&self, config: &ConnectConfig<'_>) -> Result<Connection<'_>, AdapterError<T::Error>>
Expand Down
5 changes: 2 additions & 3 deletions host/src/channel_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ impl CreditFlowControl {
}

fn process(&mut self) -> Option<u16> {
let flow = match self.policy {
match self.policy {
CreditFlowPolicy::Every(count) => {
if self.received >= count {
let amount = self.received;
Expand All @@ -653,8 +653,7 @@ impl CreditFlowControl {
None
}
}
};
flow
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion host/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl<'d> Connection<'d> {
where
T: ControllerCmdAsync<LeConnUpdate>,
{
let ret = adapter
adapter
.async_command(LeConnUpdate::new(
self.info.handle,
params.min_connection_interval.into(),
Expand Down
21 changes: 12 additions & 9 deletions host/src/l2cap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ pub struct AssembledPacket<'d> {
}

impl<'d> AssembledPacket<'d> {
pub fn new(packet: Packet<'d>, initial: usize) -> Self {
pub(crate) fn new(packet: Packet<'d>, initial: usize) -> Self {
Self {
packet,
written: initial,
}
}

pub fn write(&mut self, data: &[u8]) -> Result<(), Error> {
pub(crate) fn write(&mut self, data: &[u8]) -> Result<(), Error> {
if self.written + data.len() > self.packet.len() {
return Err(Error::InsufficientSpace);
}
Expand All @@ -47,11 +47,11 @@ impl<'d> AssembledPacket<'d> {
Ok(())
}

pub fn len(&self) -> usize {
pub(crate) fn len(&self) -> usize {
self.written
}

pub fn finalize(self, header: L2capHeader) -> Result<(L2capHeader, Packet<'d>), Error> {
pub(crate) fn finalize(self, header: L2capHeader) -> Result<(L2capHeader, Packet<'d>), Error> {
if header.length as usize != self.written {
return Err(Error::InvalidValue);
}
Expand All @@ -63,6 +63,11 @@ impl<'d> AssembledPacket<'d> {
pub struct PacketReassembly<'d, const CONNS: usize> {
handles: RefCell<[Option<(ConnHandle, L2capHeader, AssembledPacket<'d>)>; CONNS]>,
}
impl<'d, const CONNS: usize> Default for PacketReassembly<'d, CONNS> {
fn default() -> Self {
Self::new()
}
}

impl<'d, const CONNS: usize> PacketReassembly<'d, CONNS> {
const EMPTY: Option<(ConnHandle, L2capHeader, AssembledPacket<'d>)> = None;
Expand All @@ -80,11 +85,9 @@ impl<'d, const CONNS: usize> PacketReassembly<'d, CONNS> {
let mut state = self.handles.borrow_mut();

// Sanity check
for entry in state.iter() {
if let Some(entry) = entry {
if entry.0 == handle {
return Err(Error::InvalidState);
}
for entry in state.iter().flatten() {
if entry.0 == handle {
return Err(Error::InvalidState);
}
}

Expand Down
4 changes: 2 additions & 2 deletions host/tests/l2cap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ async fn l2cap_connection_oriented_channels() {

match tokio::time::timeout(Duration::from_secs(30), local).await {
Ok(_) => {
let _ = central.await.unwrap().unwrap();
let _ = peripheral.await.unwrap().unwrap();
central.await.unwrap().unwrap();
peripheral.await.unwrap().unwrap();
println!("Test completed successfully");
}
Err(e) => {
Expand Down

0 comments on commit 8fd359a

Please sign in to comment.