Skip to content

Commit 630c46f

Browse files
Fix clippy for rust 1.66 (webrtc-rs#369)
1 parent aba3f46 commit 630c46f

File tree

45 files changed

+79
-81
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+79
-81
lines changed

dtls/examples/hub/src/utilities.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub fn load_key_and_certificate(
8888

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

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

107107
let mut reader = BufReader::new(f);
108108
match certs(&mut reader) {

dtls/src/cipher_suite/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ pub fn cipher_suite_for_id(id: CipherSuiteId) -> Result<Box<dyn CipherSuite + Se
165165
Ok(Box::new(new_cipher_suite_tls_psk_with_aes_128_ccm8()))
166166
}
167167
CipherSuiteId::Tls_Psk_With_Aes_128_Gcm_Sha256 => {
168-
Ok(Box::new(CipherSuiteTlsPskWithAes128GcmSha256::default()))
168+
Ok(Box::<CipherSuiteTlsPskWithAes128GcmSha256>::default())
169169
}
170170
_ => Err(Error::ErrInvalidCipherSuite),
171171
}
@@ -191,7 +191,7 @@ fn all_cipher_suites() -> Vec<Box<dyn CipherSuite + Send + Sync>> {
191191
Box::new(CipherSuiteAes256CbcSha::new(true)),
192192
Box::new(new_cipher_suite_tls_psk_with_aes_128_ccm()),
193193
Box::new(new_cipher_suite_tls_psk_with_aes_128_ccm8()),
194-
Box::new(CipherSuiteTlsPskWithAes128GcmSha256::default()),
194+
Box::<CipherSuiteTlsPskWithAes128GcmSha256>::default(),
195195
]
196196
}
197197

dtls/src/extension/extension_supported_point_formats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl ExtensionSupportedPointFormats {
2828
writer.write_u16::<BigEndian>(1 + self.point_formats.len() as u16)?;
2929
writer.write_u8(self.point_formats.len() as u8)?;
3030
for v in &self.point_formats {
31-
writer.write_u8(*v as u8)?;
31+
writer.write_u8(*v)?;
3232
}
3333

3434
Ok(writer.flush()?)

dtls/src/fragment_buffer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ impl FragmentBuffer {
127127

128128
fn size(&self) -> usize {
129129
self.cache
130-
.iter()
131-
.map(|(_, fragment)| fragment.iter().map(|f| f.data.len()).sum::<usize>())
130+
.values()
131+
.map(|fragment| fragment.iter().map(|f| f.data.len()).sum::<usize>())
132132
.sum()
133133
}
134134
}

examples/examples/data-channels-close/data-channels-close.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ async fn main() -> Result<()> {
229229
println!("received done signal!");
230230
}
231231
_ = tokio::signal::ctrl_c() => {
232-
println!("");
232+
println!();
233233
}
234234
};
235235

examples/examples/data-channels-create/data-channels-create.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ async fn main() -> Result<()> {
183183
println!("received done signal!");
184184
}
185185
_ = tokio::signal::ctrl_c() => {
186-
println!("");
186+
println!();
187187
}
188188
};
189189

examples/examples/data-channels-detach-create/data-channels-detach-create.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ async fn main() -> Result<()> {
192192
println!("received done signal!");
193193
}
194194
_ = tokio::signal::ctrl_c() => {
195-
println!("");
195+
println!();
196196
}
197197
};
198198

examples/examples/data-channels-detach/data-channels-detach.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ async fn main() -> Result<()> {
200200
println!("received done signal!");
201201
}
202202
_ = tokio::signal::ctrl_c() => {
203-
println!("");
203+
println!();
204204
}
205205
};
206206

examples/examples/data-channels-flow-control/data-channels-flow-control.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ async fn create_responder() -> anyhow::Result<RTCPeerConnection> {
127127
let start = SystemTime::now();
128128

129129
tokio::time::sleep(Duration::from_secs(1)).await;
130-
println!("");
130+
println!();
131131

132132
loop {
133133
let total_bytes_received =
@@ -246,7 +246,7 @@ async fn main() -> anyhow::Result<()> {
246246
requester.close().await?;
247247
responder.close().await?;
248248

249-
println!("");
249+
println!();
250250

251251
Ok(())
252252
}

examples/examples/data-channels/data-channels.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ async fn main() -> Result<()> {
191191
println!("received done signal!");
192192
}
193193
_ = tokio::signal::ctrl_c() => {
194-
println!("");
194+
println!();
195195
}
196196
};
197197

examples/examples/insertable-streams/insertable-streams.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ async fn main() -> Result<()> {
155155
let (mut ivf, header) = IVFReader::new(reader)?;
156156

157157
// Wait for connection established
158-
let _ = notify_video.notified().await;
158+
notify_video.notified().await;
159159

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

@@ -259,7 +259,7 @@ async fn main() -> Result<()> {
259259
println!("received done signal!");
260260
}
261261
_ = tokio::signal::ctrl_c() => {
262-
println!("");
262+
println!();
263263
}
264264
};
265265

examples/examples/offer-answer/answer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ async fn main() -> Result<()> {
381381
println!("received done signal!");
382382
}
383383
_ = tokio::signal::ctrl_c() => {
384-
println!("");
384+
println!();
385385
}
386386
};
387387

examples/examples/offer-answer/offer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ async fn main() -> Result<()> {
367367
println!("received done signal!");
368368
}
369369
_ = tokio::signal::ctrl_c() => {
370-
println!("");
370+
println!();
371371
}
372372
};
373373

examples/examples/play-from-disk-h264/play-from-disk-h264.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ async fn main() -> Result<()> {
175175
let mut h264 = H264Reader::new(reader);
176176

177177
// Wait for connection established
178-
let _ = notify_video.notified().await;
178+
notify_video.notified().await;
179179

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

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

254254
// Wait for connection established
255-
let _ = notify_audio.notified().await;
255+
notify_audio.notified().await;
256256

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

@@ -351,7 +351,7 @@ async fn main() -> Result<()> {
351351
println!("received done signal!");
352352
}
353353
_ = tokio::signal::ctrl_c() => {
354-
println!("");
354+
println!();
355355
}
356356
};
357357

examples/examples/play-from-disk-renegotiation/play-from-disk-renegotiation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ async fn main() -> Result<()> {
361361
println!("received done signal!");
362362
}
363363
_ = tokio::signal::ctrl_c() => {
364-
println!("");
364+
println!();
365365
}
366366
};
367367

examples/examples/play-from-disk-vpx/play-from-disk-vpx.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ async fn main() -> Result<()> {
185185
let (mut ivf, header) = IVFReader::new(reader)?;
186186

187187
// Wait for connection established
188-
let _ = notify_video.notified().await;
188+
notify_video.notified().await;
189189

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

@@ -263,7 +263,7 @@ async fn main() -> Result<()> {
263263
}
264264
};
265265
// Wait for connection established
266-
let _ = notify_audio.notified().await;
266+
notify_audio.notified().await;
267267

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

@@ -362,7 +362,7 @@ async fn main() -> Result<()> {
362362
println!("received done signal!");
363363
}
364364
_ = tokio::signal::ctrl_c() => {
365-
println!("");
365+
println!();
366366
}
367367
};
368368

examples/examples/reflect/reflect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ async fn main() -> Result<()> {
315315
println!("received done signal!");
316316
}
317317
_ = tokio::signal::ctrl_c() => {
318-
println!("");
318+
println!();
319319
}
320320
};
321321

examples/examples/rtp-forwarder/rtp-forwarder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ async fn main() -> Result<()> {
312312
println!("received done signal!");
313313
}
314314
_ = tokio::signal::ctrl_c() => {
315-
println!("");
315+
println!();
316316
}
317317
};
318318

examples/examples/rtp-to-webrtc/rtp-to-webrtc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ async fn main() -> Result<()> {
209209
println!("received done signal!");
210210
}
211211
_ = tokio::signal::ctrl_c() => {
212-
println!("");
212+
println!();
213213
}
214214
};
215215

examples/examples/save-to-disk-h264/save-to-disk-h264.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ async fn main() -> Result<()> {
307307
println!("received done signal!");
308308
}
309309
_ = tokio::signal::ctrl_c() => {
310-
println!("");
310+
println!();
311311
}
312312
};
313313

examples/examples/save-to-disk-vpx/save-to-disk-vpx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ async fn main() -> Result<()> {
337337
println!("received done signal!");
338338
}
339339
_ = tokio::signal::ctrl_c() => {
340-
println!("");
340+
println!();
341341
}
342342
};
343343

examples/examples/swap-tracks/swap-tracks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ async fn main() -> Result<()> {
299299
break;
300300
}
301301
_ = tokio::signal::ctrl_c() => {
302-
println!("");
302+
println!();
303303
break;
304304
}
305305
};

ice/examples/ping_pong.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ async fn main() -> Result<(), Error> {
395395
let _ = done_tx.send(());
396396
}
397397
_ = tokio::signal::ctrl_c() => {
398-
println!("");
398+
println!();
399399
let _ = done_tx.send(());
400400
}
401401
};

ice/src/agent/agent_selector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl AgentInternal {
120120
Box::new(BINDING_REQUEST),
121121
Box::new(TransactionId::new()),
122122
Box::new(Username::new(ATTR_USERNAME, username)),
123-
Box::new(UseCandidateAttr::default()),
123+
Box::<UseCandidateAttr>::default(),
124124
Box::new(AttrControlling(self.tie_breaker.load(Ordering::SeqCst))),
125125
Box::new(PriorityAttr(pair.local.priority())),
126126
Box::new(MessageIntegrity::new_short_term_integrity(

ice/src/control/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl TieBreaker {
1717
/// Adds Tiebreaker value to m as t attribute.
1818
pub fn add_to_as(self, m: &mut Message, t: AttrType) -> Result<(), stun::Error> {
1919
let mut v = vec![0; TIE_BREAKER_SIZE];
20-
v.copy_from_slice(&(self.0 as u64).to_be_bytes());
20+
v.copy_from_slice(&self.0.to_be_bytes());
2121
m.add(t, &v);
2222
Ok(())
2323
}

interceptor/src/report/receiver/receiver_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl ReceiverStreamInternal {
5151
// following frames
5252
self.set_received(pkt.header.sequence_number);
5353

54-
let diff = pkt.header.sequence_number as i32 - self.last_seq_num as i32;
54+
let diff = pkt.header.sequence_number as i32 - self.last_seq_num;
5555
if !(-0x0FFF..=0).contains(&diff) {
5656
// overflow
5757
if diff < -0x0FFF {

interceptor/src/stats/interceptor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ fn calculate_rtt_ms(now: u32, delay: u32, last_report: u32) -> Option<f64> {
816816
let rtt_seconds = rtt >> 16;
817817
let rtt_fraction = (rtt & (u16::MAX as u32)) as f64 / (u16::MAX as u32) as f64;
818818

819-
Some(rtt_seconds as f64 * 1000.0 + (rtt_fraction as f64) * 1000.0)
819+
Some(rtt_seconds as f64 * 1000.0 + rtt_fraction * 1000.0)
820820
}
821821

822822
#[cfg(test)]

mdns/src/message/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl fmt::Display for Header {
3333
impl Header {
3434
pub fn pack(&self) -> (u16, u16) {
3535
let id = self.id;
36-
let mut bits = (self.op_code as u16) << 11 | self.rcode as u16;
36+
let mut bits = self.op_code << 11 | self.rcode as u16;
3737
if self.recursion_available {
3838
bits |= HEADER_BIT_RA
3939
}

mdns/src/message/resource/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,16 @@ pub fn unpack_resource_body(
254254
length: usize,
255255
) -> Result<(Box<dyn ResourceBody>, usize)> {
256256
let mut rb: Box<dyn ResourceBody> = match typ {
257-
DnsType::A => Box::new(AResource::default()),
258-
DnsType::Ns => Box::new(NsResource::default()),
259-
DnsType::Cname => Box::new(CnameResource::default()),
260-
DnsType::Soa => Box::new(SoaResource::default()),
261-
DnsType::Ptr => Box::new(PtrResource::default()),
262-
DnsType::Mx => Box::new(MxResource::default()),
263-
DnsType::Txt => Box::new(TxtResource::default()),
264-
DnsType::Aaaa => Box::new(AaaaResource::default()),
265-
DnsType::Srv => Box::new(SrvResource::default()),
266-
DnsType::Opt => Box::new(OptResource::default()),
257+
DnsType::A => Box::<AResource>::default(),
258+
DnsType::Ns => Box::<NsResource>::default(),
259+
DnsType::Cname => Box::<CnameResource>::default(),
260+
DnsType::Soa => Box::<SoaResource>::default(),
261+
DnsType::Ptr => Box::<PtrResource>::default(),
262+
DnsType::Mx => Box::<MxResource>::default(),
263+
DnsType::Txt => Box::<TxtResource>::default(),
264+
DnsType::Aaaa => Box::<AaaaResource>::default(),
265+
DnsType::Srv => Box::<SrvResource>::default(),
266+
DnsType::Opt => Box::<OptResource>::default(),
267267
_ => return Err(Error::ErrNilResourceBody),
268268
};
269269

media/src/io/ivf_writer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ impl<W: Write + Seek> Writer for IVFWriter<W> {
5757
/// write_rtp adds a new packet and writes the appropriate headers for it
5858
fn write_rtp(&mut self, packet: &rtp::packet::Packet) -> Result<()> {
5959
let mut depacketizer: Box<dyn Depacketizer> = if self.is_vp9 {
60-
Box::new(rtp::codecs::vp9::Vp9Packet::default())
60+
Box::<rtp::codecs::vp9::Vp9Packet>::default()
6161
} else {
62-
Box::new(rtp::codecs::vp8::Vp8Packet::default())
62+
Box::<rtp::codecs::vp8::Vp8Packet>::default()
6363
};
6464

6565
let payload = depacketizer.depacketize(&packet.payload)?;

media/src/io/ogg_reader/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl<R: Read> OggReader<R> {
132132
}
133133

134134
let mut payload = BytesMut::with_capacity(payload_size);
135-
payload.resize(payload_size as usize, 0);
135+
payload.resize(payload_size, 0);
136136
self.reader.read_exact(&mut payload)?;
137137

138138
if self.do_checksum {

rtcp/src/goodbye/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl Unmarshal for Goodbye {
158158
return Err(Error::PacketTooShort.into());
159159
}
160160

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

163163
if reason_offset > raw_packet_len {
164164
return Err(Error::PacketTooShort.into());

rtcp/src/transport_feedbacks/transport_layer_cc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl Unmarshal for RunLengthChunk {
204204
let b1 = raw_packet.get_u8();
205205

206206
// get PacketStatusSymbol
207-
let packet_status_symbol = (get_nbits_from_byte(b0, 1, 2) as u16).into();
207+
let packet_status_symbol = get_nbits_from_byte(b0, 1, 2).into();
208208

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

0 commit comments

Comments
 (0)