Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
russelltg committed Dec 31, 2023
1 parent 36f92e6 commit 84fd13b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
4 changes: 2 additions & 2 deletions srt-c/src/c_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ pub extern "C" fn srt_sendmsg2(
.try_send(
Instant::now(),
Bytes::copy_from_slice(unsafe {
from_raw_parts(buf as *const u8, len as usize)
from_raw_parts(buf, len as usize)
}),
)
.is_err()
Expand All @@ -798,7 +798,7 @@ pub extern "C" fn srt_recv(sock: SRTSOCKET, buf: *mut c_char, len: c_int) -> c_i
Some(sock) => sock,
};

let bytes = unsafe { from_raw_parts_mut(buf as *mut u8, len as usize) };
let bytes = unsafe { from_raw_parts_mut(buf, len as usize) };

let mut l = sock.lock().unwrap();
if let SocketData::Established(ref mut sock, opts) = *l {
Expand Down
5 changes: 2 additions & 3 deletions srt-protocol/src/options/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ impl OptionsOf<Receiver> for SocketOptions {

#[cfg(test)]
mod test {
use std::convert::TryInto;
use std::time::Duration;

use super::*;
Expand All @@ -119,7 +118,7 @@ mod test {
})?
.with(Encryption {
key_size: KeySize::AES192,
passphrase: "this is a passphrase".try_into().ok(),
passphrase: Some("this is a passphrase".into()),
..Default::default()
})?
.with(Sender {
Expand All @@ -142,7 +141,7 @@ mod test {
},
encryption: Encryption {
key_size: KeySize::AES192,
passphrase: "this is a passphrase".try_into().ok(),
passphrase: Some("this is a passphrase".into()),
..Default::default()
},
sender: Sender {
Expand Down
2 changes: 1 addition & 1 deletion srt-protocol/src/options/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ mod tests {
socket.connect.linger = Some(Duration::from_millis(128));
socket.receiver.reorder_tolerance_max = PacketCount(256);
socket.session.max_segment_size = PacketSize(1300);
socket.encryption.passphrase = "passphrase1234".try_into().ok();
socket.encryption.passphrase = Some("passphrase1234".into());
socket.sender.max_payload_size = PacketSize(1234);
socket.encryption.key_size = KeySize::AES256;
socket.session.peer_idle_timeout = Duration::from_millis(4242);
Expand Down
2 changes: 0 additions & 2 deletions srt-protocol/src/packet/modular_num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ macro_rules! modular_num_impls {
}
};
}
pub use modular_num_impls;

#[cfg(test)]
mod tests {

Expand Down
8 changes: 4 additions & 4 deletions srt-protocol/tests/simulator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ struct SentPacket(Instant, (Packet, SocketAddr));

impl PartialOrd for SentPacket {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.0.cmp(&other.0).reverse()) // reverse to make it a min-heap
Some(self.cmp(other))
}
}

impl Ord for SentPacket {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.partial_cmp(other).unwrap()
self.0.cmp(&other.0).reverse() // reverse to make it a min-heap
}
}

Expand All @@ -44,13 +44,13 @@ impl Eq for ScheduledInput {}

impl PartialOrd for ScheduledInput {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.0.cmp(&other.0).reverse()) // reverse to make it a min-heap
Some(self.cmp(other))
}
}

impl Ord for ScheduledInput {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.partial_cmp(other).unwrap()
self.0.cmp(&other.0).reverse() // reverse to make it a min-heap
}
}

Expand Down
3 changes: 1 addition & 2 deletions srt-tokio/tests/accesscontrol.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::{
convert::{TryFrom, TryInto},
io,
time::Instant,
};
Expand Down Expand Up @@ -128,7 +127,7 @@ async fn set_password() {

let listener = tokio::spawn(async move {
while let Some(request) = incoming.incoming().next().await {
let passphrase = request.stream_id().unwrap().as_str().try_into().unwrap();
let passphrase = request.stream_id().unwrap().as_str().into();

if let Ok(mut sender) = request
.accept(Some(KeySettings {
Expand Down

0 comments on commit 84fd13b

Please sign in to comment.