From a9e1f02f0fdc55ab7ec8f5527ca5a310f8d3cb80 Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Mon, 16 Oct 2023 12:18:45 +0100 Subject: [PATCH] Fix clippy warnings & errors after Rust update. --- chirpstack/src/downlink/join.rs | 2 +- chirpstack/src/downlink/roaming.rs | 2 +- chirpstack/src/downlink/tx_ack.rs | 2 +- chirpstack/src/integration/mqtt.rs | 6 +++--- chirpstack/src/storage/device_session.rs | 3 --- chirpstack/src/uplink/data.rs | 2 +- chirpstack/src/uplink/join.rs | 2 +- chirpstack/src/uplink/join_sns.rs | 2 +- 8 files changed, 9 insertions(+), 12 deletions(-) diff --git a/chirpstack/src/downlink/join.rs b/chirpstack/src/downlink/join.rs index 8fc6c099..32cb65e2 100644 --- a/chirpstack/src/downlink/join.rs +++ b/chirpstack/src/downlink/join.rs @@ -174,7 +174,7 @@ impl JoinAccept<'_> { .gateway_tenant_id_map .get(&gw_id) .map(|v| v.into_bytes().to_vec()) - .unwrap_or_else(Vec::new), + .unwrap_or_default(), } }) .collect(), diff --git a/chirpstack/src/downlink/roaming.rs b/chirpstack/src/downlink/roaming.rs index db81d76e..b1374cb3 100644 --- a/chirpstack/src/downlink/roaming.rs +++ b/chirpstack/src/downlink/roaming.rs @@ -92,7 +92,7 @@ impl PassiveRoamingDownlink { .gateway_tenant_id_map .get(&gw_id) .map(|v| v.into_bytes().to_vec()) - .unwrap_or_else(Vec::new), + .unwrap_or_default(), } }) .collect(), diff --git a/chirpstack/src/downlink/tx_ack.rs b/chirpstack/src/downlink/tx_ack.rs index 9bbb06c1..e3a6b019 100644 --- a/chirpstack/src/downlink/tx_ack.rs +++ b/chirpstack/src/downlink/tx_ack.rs @@ -667,7 +667,7 @@ impl TxAck { let mut plaintext_frm_payload = false; if let Payload::MACPayload(pl) = &phy.payload { // f_port must be either 0 or 226 (Relay). - if vec![0, lrwn::LA_FPORT_RELAY].contains(&pl.f_port.unwrap_or(0)) { + if [0, lrwn::LA_FPORT_RELAY].contains(&pl.f_port.unwrap_or(0)) { phy.decrypt_frm_payload(&nwk_s_enc_key)?; plaintext_frm_payload = true; } diff --git a/chirpstack/src/integration/mqtt.rs b/chirpstack/src/integration/mqtt.rs index 186f6805..aef31533 100644 --- a/chirpstack/src/integration/mqtt.rs +++ b/chirpstack/src/integration/mqtt.rs @@ -145,9 +145,9 @@ impl<'a> Integration<'a> { command_regex: Regex::new(&templates.render( "command_topic", &CommandTopicContext { - application_id: r#"(?P[\w-]+)"#.to_string(), - dev_eui: r#"(?P[\w]+)"#.to_string(), - command: r#"(?P[\w]+)"#.to_string(), + application_id: r"(?P[\w-]+)".to_string(), + dev_eui: r"(?P[\w]+)".to_string(), + command: r"(?P[\w]+)".to_string(), }, )?)?, qos: conf.qos, diff --git a/chirpstack/src/storage/device_session.rs b/chirpstack/src/storage/device_session.rs index 014143e3..7ad31d89 100644 --- a/chirpstack/src/storage/device_session.rs +++ b/chirpstack/src/storage/device_session.rs @@ -311,7 +311,6 @@ pub async fn get_for_phypayload( async fn get_dev_euis_for_dev_addr(dev_addr: DevAddr) -> Result> { task::spawn_blocking({ - let dev_addr = dev_addr; move || -> Result> { let key = redis_key(format!("devaddr:{{{}}}", dev_addr)); let mut c = get_redis_conn()?; @@ -333,8 +332,6 @@ async fn get_dev_euis_for_dev_addr(dev_addr: DevAddr) -> Result> { async fn remove_dev_eui_from_dev_addr_set(dev_addr: DevAddr, dev_eui: EUI64) -> Result<()> { task::spawn_blocking({ - let dev_addr = dev_addr; - let dev_eui = dev_eui; move || -> Result<()> { let key = redis_key(format!("devaddr:{{{}}}", dev_addr)); let mut c = get_redis_conn()?; diff --git a/chirpstack/src/uplink/data.rs b/chirpstack/src/uplink/data.rs index 0794c41e..4ff27f3f 100644 --- a/chirpstack/src/uplink/data.rs +++ b/chirpstack/src/uplink/data.rs @@ -458,7 +458,7 @@ impl Data { .gateway_tenant_id_map .get(&gw_id) .map(|v| v.into_bytes().to_vec()) - .unwrap_or_else(Vec::new), + .unwrap_or_default(), } }) .collect(), diff --git a/chirpstack/src/uplink/join.rs b/chirpstack/src/uplink/join.rs index 17a81308..24f93b95 100644 --- a/chirpstack/src/uplink/join.rs +++ b/chirpstack/src/uplink/join.rs @@ -253,7 +253,7 @@ impl JoinRequest { } }; - if !self.device_keys.is_some() { + if self.device_keys.is_none() { trace!(join_eui = %jr.join_eui, "Getting Join Server client"); self.js_client = Some(joinserver::get(&jr.join_eui)?); } diff --git a/chirpstack/src/uplink/join_sns.rs b/chirpstack/src/uplink/join_sns.rs index b0dcade2..4440439d 100644 --- a/chirpstack/src/uplink/join_sns.rs +++ b/chirpstack/src/uplink/join_sns.rs @@ -145,7 +145,7 @@ impl JoinRequest { } }; - if !self.device_keys.is_some() { + if self.device_keys.is_none() { trace!(join_eui = %jr.join_eui, "Getting Join Server client"); self.js_client = Some(joinserver::get(&jr.join_eui)?); }