Skip to content

Commit

Permalink
Fix clippy for rust 1.66 (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
lookback-hugotunius authored Dec 19, 2022
1 parent aba3f46 commit 630c46f
Show file tree
Hide file tree
Showing 45 changed files with 79 additions and 81 deletions.
4 changes: 2 additions & 2 deletions dtls/examples/hub/src/utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn load_key_and_certificate(

/// load_key Load/read key from file
pub fn load_key(path: PathBuf) -> Result<CryptoPrivateKey, Error> {
let f = File::open(&path)?;
let f = File::open(path)?;
let mut reader = BufReader::new(f);
let mut buf = vec![];
reader.read_to_end(&mut buf)?;
Expand All @@ -102,7 +102,7 @@ pub fn load_key(path: PathBuf) -> Result<CryptoPrivateKey, Error> {

/// load_certificate Load/read certificate(s) from file
pub fn load_certificate(path: PathBuf) -> Result<Vec<rustls::Certificate>, Error> {
let f = File::open(&path)?;
let f = File::open(path)?;

let mut reader = BufReader::new(f);
match certs(&mut reader) {
Expand Down
4 changes: 2 additions & 2 deletions dtls/src/cipher_suite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub fn cipher_suite_for_id(id: CipherSuiteId) -> Result<Box<dyn CipherSuite + Se
Ok(Box::new(new_cipher_suite_tls_psk_with_aes_128_ccm8()))
}
CipherSuiteId::Tls_Psk_With_Aes_128_Gcm_Sha256 => {
Ok(Box::new(CipherSuiteTlsPskWithAes128GcmSha256::default()))
Ok(Box::<CipherSuiteTlsPskWithAes128GcmSha256>::default())
}
_ => Err(Error::ErrInvalidCipherSuite),
}
Expand All @@ -191,7 +191,7 @@ fn all_cipher_suites() -> Vec<Box<dyn CipherSuite + Send + Sync>> {
Box::new(CipherSuiteAes256CbcSha::new(true)),
Box::new(new_cipher_suite_tls_psk_with_aes_128_ccm()),
Box::new(new_cipher_suite_tls_psk_with_aes_128_ccm8()),
Box::new(CipherSuiteTlsPskWithAes128GcmSha256::default()),
Box::<CipherSuiteTlsPskWithAes128GcmSha256>::default(),
]
}

Expand Down
2 changes: 1 addition & 1 deletion dtls/src/extension/extension_supported_point_formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl ExtensionSupportedPointFormats {
writer.write_u16::<BigEndian>(1 + self.point_formats.len() as u16)?;
writer.write_u8(self.point_formats.len() as u8)?;
for v in &self.point_formats {
writer.write_u8(*v as u8)?;
writer.write_u8(*v)?;
}

Ok(writer.flush()?)
Expand Down
4 changes: 2 additions & 2 deletions dtls/src/fragment_buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ impl FragmentBuffer {

fn size(&self) -> usize {
self.cache
.iter()
.map(|(_, fragment)| fragment.iter().map(|f| f.data.len()).sum::<usize>())
.values()
.map(|fragment| fragment.iter().map(|f| f.data.len()).sum::<usize>())
.sum()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async fn create_responder() -> anyhow::Result<RTCPeerConnection> {
let start = SystemTime::now();

tokio::time::sleep(Duration::from_secs(1)).await;
println!("");
println!();

loop {
let total_bytes_received =
Expand Down Expand Up @@ -246,7 +246,7 @@ async fn main() -> anyhow::Result<()> {
requester.close().await?;
responder.close().await?;

println!("");
println!();

Ok(())
}
2 changes: 1 addition & 1 deletion examples/examples/data-channels/data-channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
4 changes: 2 additions & 2 deletions examples/examples/insertable-streams/insertable-streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ async fn main() -> Result<()> {
let (mut ivf, header) = IVFReader::new(reader)?;

// Wait for connection established
let _ = notify_video.notified().await;
notify_video.notified().await;

println!("play video from disk file output.ivf");

Expand Down Expand Up @@ -259,7 +259,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/offer-answer/answer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/offer-answer/offer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
6 changes: 3 additions & 3 deletions examples/examples/play-from-disk-h264/play-from-disk-h264.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ async fn main() -> Result<()> {
let mut h264 = H264Reader::new(reader);

// Wait for connection established
let _ = notify_video.notified().await;
notify_video.notified().await;

println!("play video from disk file {}", video_file_name);

Expand Down Expand Up @@ -252,7 +252,7 @@ async fn main() -> Result<()> {
let (mut ogg, _) = OggReader::new(reader, true)?;

// Wait for connection established
let _ = notify_audio.notified().await;
notify_audio.notified().await;

println!("play audio from disk file output.ogg");

Expand Down Expand Up @@ -351,7 +351,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
6 changes: 3 additions & 3 deletions examples/examples/play-from-disk-vpx/play-from-disk-vpx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async fn main() -> Result<()> {
let (mut ivf, header) = IVFReader::new(reader)?;

// Wait for connection established
let _ = notify_video.notified().await;
notify_video.notified().await;

println!("play video from disk file {}", video_file_name);

Expand Down Expand Up @@ -263,7 +263,7 @@ async fn main() -> Result<()> {
}
};
// Wait for connection established
let _ = notify_audio.notified().await;
notify_audio.notified().await;

println!("play audio from disk file output.ogg");

Expand Down Expand Up @@ -362,7 +362,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/reflect/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/rtp-forwarder/rtp-forwarder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/rtp-to-webrtc/rtp-to-webrtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/save-to-disk-h264/save-to-disk-h264.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/save-to-disk-vpx/save-to-disk-vpx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ async fn main() -> Result<()> {
println!("received done signal!");
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
}
};

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/swap-tracks/swap-tracks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ async fn main() -> Result<()> {
break;
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
break;
}
};
Expand Down
2 changes: 1 addition & 1 deletion ice/examples/ping_pong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ async fn main() -> Result<(), Error> {
let _ = done_tx.send(());
}
_ = tokio::signal::ctrl_c() => {
println!("");
println!();
let _ = done_tx.send(());
}
};
Expand Down
2 changes: 1 addition & 1 deletion ice/src/agent/agent_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl AgentInternal {
Box::new(BINDING_REQUEST),
Box::new(TransactionId::new()),
Box::new(Username::new(ATTR_USERNAME, username)),
Box::new(UseCandidateAttr::default()),
Box::<UseCandidateAttr>::default(),
Box::new(AttrControlling(self.tie_breaker.load(Ordering::SeqCst))),
Box::new(PriorityAttr(pair.local.priority())),
Box::new(MessageIntegrity::new_short_term_integrity(
Expand Down
2 changes: 1 addition & 1 deletion ice/src/control/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl TieBreaker {
/// Adds Tiebreaker value to m as t attribute.
pub fn add_to_as(self, m: &mut Message, t: AttrType) -> Result<(), stun::Error> {
let mut v = vec![0; TIE_BREAKER_SIZE];
v.copy_from_slice(&(self.0 as u64).to_be_bytes());
v.copy_from_slice(&self.0.to_be_bytes());
m.add(t, &v);
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion interceptor/src/report/receiver/receiver_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl ReceiverStreamInternal {
// following frames
self.set_received(pkt.header.sequence_number);

let diff = pkt.header.sequence_number as i32 - self.last_seq_num as i32;
let diff = pkt.header.sequence_number as i32 - self.last_seq_num;
if !(-0x0FFF..=0).contains(&diff) {
// overflow
if diff < -0x0FFF {
Expand Down
2 changes: 1 addition & 1 deletion interceptor/src/stats/interceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ fn calculate_rtt_ms(now: u32, delay: u32, last_report: u32) -> Option<f64> {
let rtt_seconds = rtt >> 16;
let rtt_fraction = (rtt & (u16::MAX as u32)) as f64 / (u16::MAX as u32) as f64;

Some(rtt_seconds as f64 * 1000.0 + (rtt_fraction as f64) * 1000.0)
Some(rtt_seconds as f64 * 1000.0 + rtt_fraction * 1000.0)
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion mdns/src/message/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl fmt::Display for Header {
impl Header {
pub fn pack(&self) -> (u16, u16) {
let id = self.id;
let mut bits = (self.op_code as u16) << 11 | self.rcode as u16;
let mut bits = self.op_code << 11 | self.rcode as u16;
if self.recursion_available {
bits |= HEADER_BIT_RA
}
Expand Down
20 changes: 10 additions & 10 deletions mdns/src/message/resource/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,16 @@ pub fn unpack_resource_body(
length: usize,
) -> Result<(Box<dyn ResourceBody>, usize)> {
let mut rb: Box<dyn ResourceBody> = match typ {
DnsType::A => Box::new(AResource::default()),
DnsType::Ns => Box::new(NsResource::default()),
DnsType::Cname => Box::new(CnameResource::default()),
DnsType::Soa => Box::new(SoaResource::default()),
DnsType::Ptr => Box::new(PtrResource::default()),
DnsType::Mx => Box::new(MxResource::default()),
DnsType::Txt => Box::new(TxtResource::default()),
DnsType::Aaaa => Box::new(AaaaResource::default()),
DnsType::Srv => Box::new(SrvResource::default()),
DnsType::Opt => Box::new(OptResource::default()),
DnsType::A => Box::<AResource>::default(),
DnsType::Ns => Box::<NsResource>::default(),
DnsType::Cname => Box::<CnameResource>::default(),
DnsType::Soa => Box::<SoaResource>::default(),
DnsType::Ptr => Box::<PtrResource>::default(),
DnsType::Mx => Box::<MxResource>::default(),
DnsType::Txt => Box::<TxtResource>::default(),
DnsType::Aaaa => Box::<AaaaResource>::default(),
DnsType::Srv => Box::<SrvResource>::default(),
DnsType::Opt => Box::<OptResource>::default(),
_ => return Err(Error::ErrNilResourceBody),
};

Expand Down
4 changes: 2 additions & 2 deletions media/src/io/ivf_writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ impl<W: Write + Seek> Writer for IVFWriter<W> {
/// write_rtp adds a new packet and writes the appropriate headers for it
fn write_rtp(&mut self, packet: &rtp::packet::Packet) -> Result<()> {
let mut depacketizer: Box<dyn Depacketizer> = if self.is_vp9 {
Box::new(rtp::codecs::vp9::Vp9Packet::default())
Box::<rtp::codecs::vp9::Vp9Packet>::default()
} else {
Box::new(rtp::codecs::vp8::Vp8Packet::default())
Box::<rtp::codecs::vp8::Vp8Packet>::default()
};

let payload = depacketizer.depacketize(&packet.payload)?;
Expand Down
2 changes: 1 addition & 1 deletion media/src/io/ogg_reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<R: Read> OggReader<R> {
}

let mut payload = BytesMut::with_capacity(payload_size);
payload.resize(payload_size as usize, 0);
payload.resize(payload_size, 0);
self.reader.read_exact(&mut payload)?;

if self.do_checksum {
Expand Down
2 changes: 1 addition & 1 deletion rtcp/src/goodbye/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl Unmarshal for Goodbye {
return Err(Error::PacketTooShort.into());
}

let reason_offset = (HEADER_LENGTH + header.count as usize * SSRC_LENGTH) as usize;
let reason_offset = HEADER_LENGTH + header.count as usize * SSRC_LENGTH;

if reason_offset > raw_packet_len {
return Err(Error::PacketTooShort.into());
Expand Down
2 changes: 1 addition & 1 deletion rtcp/src/transport_feedbacks/transport_layer_cc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl Unmarshal for RunLengthChunk {
let b1 = raw_packet.get_u8();

// get PacketStatusSymbol
let packet_status_symbol = (get_nbits_from_byte(b0, 1, 2) as u16).into();
let packet_status_symbol = get_nbits_from_byte(b0, 1, 2).into();

// get RunLength
let run_length = ((get_nbits_from_byte(b0, 3, 5) as usize) << 8) as u16 + (b1 as u16);
Expand Down
Loading

0 comments on commit 630c46f

Please sign in to comment.