Skip to content

Commit 870e66a

Browse files
author
yngrtc
committed
fix clippy warning
1 parent 1e41daa commit 870e66a

File tree

23 files changed

+48
-37
lines changed

23 files changed

+48
-37
lines changed

dtls/src/conn/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ impl DTLSConn {
200200
if let Some(remote_addr) = conn.remote_addr() {
201201
server_name = remote_addr.ip().to_string();
202202
} else {
203-
log::warn!("conn.remote_addr is empty, please set explicitly server_name in Config! Use default \"localhost\" as server_name now");
204-
server_name = "localhost".to_owned();
203+
warn!("conn.remote_addr is empty, please set explicitly server_name in Config! Use default \"localhost\" as server_name now");
204+
"localhost".clone_into(&mut server_name);
205205
}
206206
}
207207

dtls/src/flight/flight0.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl Flight for Flight0 {
135135
}
136136
}
137137
Extension::ServerName(e) => {
138-
state.server_name = e.server_name.clone(); // remote server name
138+
state.server_name.clone_from(&e.server_name); // remote server name
139139
}
140140
_ => {}
141141
}

dtls/src/flight/flight1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl Flight for Flight1 {
102102
));
103103
}
104104

105-
state.cookie = h.cookie.clone();
105+
state.cookie.clone_from(&h.cookie);
106106
state.handshake_recv_sequence = seq;
107107
Ok(Box::new(Flight3 {}))
108108
} else {

dtls/src/flight/flight3.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl Flight for Flight3 {
8888
));
8989
}
9090

91-
state.cookie = h.cookie.clone();
91+
state.cookie.clone_from(&h.cookie);
9292
state.handshake_recv_sequence = seq;
9393
return Ok(Box::new(Flight3 {}) as Box<dyn Flight + Send + Sync>);
9494
}
@@ -302,7 +302,7 @@ impl Flight for Flight3 {
302302
))
303303
}
304304
};
305-
state.peer_certificates = h.certificate.clone();
305+
state.peer_certificates.clone_from(&h.certificate);
306306
}
307307

308308
if let Some(message) = msgs.get(&HandshakeType::ServerKeyExchange) {
@@ -430,7 +430,7 @@ pub(crate) fn handle_server_key_exchange(
430430
}
431431
};
432432

433-
state.identity_hint = h.identity_hint.clone();
433+
state.identity_hint.clone_from(&h.identity_hint);
434434
state.pre_master_secret = prf_psk_pre_master_secret(&psk);
435435
} else {
436436
let local_keypair = match h.named_curve.generate_keypair() {

dtls/src/flight/flight4.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl Flight for Flight4 {
108108
}
109109
};
110110

111-
state.peer_certificates = h.certificate.clone();
111+
state.peer_certificates.clone_from(&h.certificate);
112112
trace!(
113113
"[handshake] PeerCertificates4 {}",
114114
state.peer_certificates.len()
@@ -303,7 +303,9 @@ impl Flight for Flight4 {
303303
}
304304
};
305305

306-
state.identity_hint = client_key_exchange.identity_hint.clone();
306+
state
307+
.identity_hint
308+
.clone_from(&client_key_exchange.identity_hint);
307309
pre_master_secret = prf_psk_pre_master_secret(&psk);
308310
} else if let Some(local_keypair) = &state.local_keypair {
309311
pre_master_secret = match prf_pre_master_secret(

dtls/src/flight/flight5.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,14 @@ impl Flight for Flight5 {
228228
};
229229
if cfg.local_psk_callback.is_none() {
230230
if let Some(local_keypair) = &state.local_keypair {
231-
client_key_exchange.public_key = local_keypair.public_key.clone();
231+
client_key_exchange
232+
.public_key
233+
.clone_from(&local_keypair.public_key);
232234
}
233235
} else if let Some(local_psk_identity_hint) = &cfg.local_psk_identity_hint {
234-
client_key_exchange.identity_hint = local_psk_identity_hint.clone();
236+
client_key_exchange
237+
.identity_hint
238+
.clone_from(local_psk_identity_hint);
235239
}
236240

237241
pkts.push(Packet {

dtls/src/state.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl State {
183183
self.is_client = serialized.is_client;
184184

185185
// Set master secret
186-
self.master_secret = serialized.master_secret.clone();
186+
self.master_secret.clone_from(&serialized.master_secret);
187187

188188
// Set cipher suite
189189
self.cipher_suite = Arc::new(Mutex::new(Some(cipher_suite_for_id(
@@ -193,8 +193,9 @@ impl State {
193193
self.srtp_protection_profile = serialized.srtp_protection_profile.into();
194194

195195
// Set remote certificate
196-
self.peer_certificates = serialized.peer_certificates.clone();
197-
self.identity_hint = serialized.identity_hint.clone();
196+
self.peer_certificates
197+
.clone_from(&serialized.peer_certificates);
198+
self.identity_hint.clone_from(&serialized.identity_hint);
198199

199200
Ok(())
200201
}

examples/examples/offer-answer/answer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ async fn main() -> Result<()> {
245245

246246
{
247247
let mut oa = ADDRESS.lock().await;
248-
*oa = offer_addr.clone();
248+
oa.clone_from(&offer_addr);
249249
}
250250

251251
// Prepare the configuration

examples/examples/offer-answer/offer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ async fn main() -> Result<()> {
203203

204204
{
205205
let mut oa = ADDRESS.lock().await;
206-
*oa = answer_addr.clone();
206+
oa.clone_from(&answer_addr);
207207
}
208208

209209
// Prepare the configuration

examples/examples/signal/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pub async fn http_sdp_server(port: u16) -> mpsc::Receiver<String> {
7575
}
7676

7777
/// must_read_stdin blocks until input is received from stdin
78+
#[allow(clippy::assigning_clones)]
7879
pub fn must_read_stdin() -> Result<String> {
7980
let mut line = String::new();
8081

0 commit comments

Comments
 (0)