Skip to content

Commit

Permalink
Fix new Clippy 1.67.0 warns and bump Zenoh
Browse files Browse the repository at this point in the history
  • Loading branch information
JEnoch committed Jan 27, 2023
1 parent 2ca61e2 commit 0da4c5a
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 56 deletions.
52 changes: 26 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion zenoh-bridge-dds/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ r#"--watchdog=[PERIOD] 'Experimental!! Run a watchdog thread that monitors the
}
if let Some(port) = args.value_of("rest-http-port") {
config
.insert_json5("plugins/rest/http_port", &format!(r#""{}""#, port))
.insert_json5("plugins/rest/http_port", &format!(r#""{port}""#))
.unwrap();
}
// Always add timestamps to publications (required for PublicationCache used in case of TRANSIENT_LOCAL topics)
Expand Down
9 changes: 4 additions & 5 deletions zplugin-dds/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ where
let s: String = Deserialize::deserialize(deserializer)?;
Regex::new(&s)
.map(Some)
.map_err(|e| de::Error::custom(format!("Invalid regex 'allow={}': {}", s, e)))
.map_err(|e| de::Error::custom(format!("Invalid regex 'allow={s}': {e}")))
}

fn deserialize_max_frequencies<'de, D>(deserializer: D) -> Result<Vec<(Regex, f32)>, D::Error>
Expand All @@ -132,14 +132,13 @@ where
for s in strs {
let i = s
.find('=')
.ok_or_else(|| de::Error::custom(format!("Invalid 'max_frequency': {}", s)))?;
.ok_or_else(|| de::Error::custom(format!("Invalid 'max_frequency': {s}")))?;
let regex = Regex::new(&s[0..i]).map_err(|e| {
de::Error::custom(format!("Invalid regex for 'max_frequency': '{}': {}", s, e))
de::Error::custom(format!("Invalid regex for 'max_frequency': '{s}': {e}"))
})?;
let frequency: f32 = s[i + 1..].parse().map_err(|e| {
de::Error::custom(format!(
"Invalid float value for 'max_frequency': '{}': {}",
s, e
"Invalid float value for 'max_frequency': '{s}': {e}"
))
})?;
result.push((regex, frequency));
Expand Down
4 changes: 2 additions & 2 deletions zplugin-dds/src/dds_mgt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ pub fn delete_dds_entity(entity: dds_entity_t) -> Result<(), String> {
let r = dds_delete(entity);
match r {
0 | DDS_RETCODE_ALREADY_DELETED => Ok(()),
e => Err(format!("Error deleting DDS entity - retcode={}", e)),
e => Err(format!("Error deleting DDS entity - retcode={e}")),
}
}
}
Expand All @@ -386,7 +386,7 @@ pub fn get_guid(entity: &dds_entity_t) -> Result<String, String> {
if r == 0 {
Ok(hex::encode(guid.v))
} else {
Err(format!("Error getting GUID of DDS entity - retcode={}", r))
Err(format!("Error getting GUID of DDS entity - retcode={r}"))
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions zplugin-dds/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl Serialize for DdsPluginRuntime<'_> {
.config
.max_frequencies
.iter()
.map(|(re, freq)| format!("{}={}", re, freq))
.map(|(re, freq)| format!("{re}={freq}"))
.collect::<Vec<String>>(),
)?;
s.serialize_field("forward_discovery", &self.config.forward_discovery)?;
Expand Down Expand Up @@ -646,9 +646,9 @@ impl<'a> DdsPluginRuntime<'a> {
) -> ZResult<OwnedKeyExpr> {
// key_expr for a topic is: "<scope>/<partition>/<topic_name>" with <scope> and <partition> being optional
match (scope, partition) {
(Some(scope), Some(part)) => scope.join(&format!("{}/{}", part, topic_name)),
(Some(scope), Some(part)) => scope.join(&format!("{part}/{topic_name}")),
(Some(scope), None) => scope.join(topic_name),
(None, Some(part)) => format!("{}/{}", part, topic_name).try_into(),
(None, Some(part)) => format!("{part}/{topic_name}").try_into(),
(None, None) => topic_name.try_into(),
}
}
Expand Down Expand Up @@ -1272,7 +1272,7 @@ impl<'a> DdsPluginRuntime<'a> {
// remove all the references to the plugin's enities, removing no longer used routes
// and updating/re-publishing ParticipantEntitiesInfo
let admin_space = &mut self.admin_space;
let admin_subke = format!("@/service/{}/dds/", mid);
let admin_subke = format!("@/service/{mid}/dds/");
let mut participant_info_changed = false;
self.routes_to_dds.retain(|zkey, route| {
route.remove_remote_routed_writers_containing(&admin_subke);
Expand Down
2 changes: 1 addition & 1 deletion zplugin-dds/src/qos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ fn test_qos_serialization() {
let qos = Qos::from_writer_qos_native(native);
let json = serde_json::to_string(&qos).unwrap();

println!("{}", json);
println!("{json}");
let qos2 = serde_json::from_str::<Qos>(&json).unwrap();
assert!(qos == qos2);

Expand Down
10 changes: 5 additions & 5 deletions zplugin-dds/src/ros_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl RosDiscoveryInfoMgr {
pub(crate) fn write(&self, info: &ParticipantEntitiesInfo) -> Result<(), String> {
unsafe {
let buf = cdr::serialize::<_, _, CdrLe>(info, Infinite)
.map_err(|e| format!("Error serializing ParticipantEntitiesInfo: {}", e))?;
.map_err(|e| format!("Error serializing ParticipantEntitiesInfo: {e}"))?;

// create sertype (Unfortunatelly cdds_ddsi_payload_create() takes *mut ddsi_sertype. And keeping it in Self would make it not Send)
let ctyn = CString::new(ROS_DISCOVERY_INFO_TOPIC_TYPE)
Expand All @@ -188,7 +188,7 @@ impl RosDiscoveryInfoMgr {
ddsi_serdata_kind_SDK_DATA,
ptr,
len.try_into().map_err(|e| {
format!("Error creating payload for ParticipantEntitiesInfo: {}", e)
format!("Error creating payload for ParticipantEntitiesInfo: {e}")
})?,
);
dds_writecdr(self.writer, fwdp as *mut ddsi_serdata);
Expand Down Expand Up @@ -253,7 +253,7 @@ impl std::fmt::Display for ParticipantEntitiesInfo {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "participant {} : [", self.gid)?;
for i in self.node_entities_info_seq.values() {
write!(f, "({}), ", i)?;
write!(f, "({i}), ")?;
}
write!(f, "]")?;
Ok(())
Expand Down Expand Up @@ -291,7 +291,7 @@ where
S: Serializer,
{
let mut buf = hex::decode(gid).map_err(|e| {
serde::ser::Error::custom(format!("Failed to decode gid {} as hex: {}", gid, e))
serde::ser::Error::custom(format!("Failed to decode gid {gid} as hex: {e}"))
})?;
// Gid size in ROS messages in 24 bytes (The DDS gid is usually 16 bytes). Resize the buffer
buf.resize(24, 0);
Expand All @@ -317,7 +317,7 @@ where
let mut seq = serializer.serialize_seq(Some(gids.len()))?;
for s in gids {
let mut buf = hex::decode(s).map_err(|e| {
serde::ser::Error::custom(format!("Failed to decode gid {} as hex: {}", s, e))
serde::ser::Error::custom(format!("Failed to decode gid {s} as hex: {e}"))
})?;
// Gid size in ROS messages in 24 bytes (The DDS gid is usually 16 bytes). Resize the buffer
buf.resize(24, 0);
Expand Down
10 changes: 2 additions & 8 deletions zplugin-dds/src/route_dds_zenoh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ impl RouteDDSZenoh<'_> {
.res()
.await
.map_err(|e| {
format!(
"Route Zenoh->DDS ({} -> {}): failed to declare KeyExpr: {}",
topic_name, ke, e
)
format!("Route Zenoh->DDS ({topic_name} -> {ke}): failed to declare KeyExpr: {e}")
})?;

// declare the zenoh Publisher
Expand Down Expand Up @@ -152,10 +149,7 @@ impl RouteDDSZenoh<'_> {
.res()
.await
.map_err(|e| {
format!(
"Failed create PublicationCache for key {} (rid={}): {}",
ke, declared_ke, e
)
format!("Failed create PublicationCache for key {ke} (rid={declared_ke}): {e}")
})?;
ZPublisher::PublicationCache(pub_cache)
} else {
Expand Down
Loading

0 comments on commit 0da4c5a

Please sign in to comment.