diff --git a/ci/nostd-check/src/bin/nostd_check.rs b/ci/nostd-check/src/bin/nostd_check.rs index 74f85ae06c..b243c9d182 100644 --- a/ci/nostd-check/src/bin/nostd_check.rs +++ b/ci/nostd-check/src/bin/nostd_check.rs @@ -15,6 +15,7 @@ #![no_std] use core::panic::PanicInfo; + use getrandom::{register_custom_getrandom, Error}; use linked_list_allocator::LockedHeap; #[allow(unused_imports)] diff --git a/ci/valgrind-check/src/pub_sub/bin/z_pub_sub.rs b/ci/valgrind-check/src/pub_sub/bin/z_pub_sub.rs index 2091f833a1..7b1b017c7d 100644 --- a/ci/valgrind-check/src/pub_sub/bin/z_pub_sub.rs +++ b/ci/valgrind-check/src/pub_sub/bin/z_pub_sub.rs @@ -12,8 +12,8 @@ // ZettaScale Zenoh Team, // use std::time::Duration; -use zenoh::config::Config; -use zenoh::prelude::*; + +use zenoh::{config::Config, prelude::*}; #[tokio::main] async fn main() { diff --git a/ci/valgrind-check/src/queryable_get/bin/z_queryable_get.rs b/ci/valgrind-check/src/queryable_get/bin/z_queryable_get.rs index 43cb038f94..69335d674e 100644 --- a/ci/valgrind-check/src/queryable_get/bin/z_queryable_get.rs +++ b/ci/valgrind-check/src/queryable_get/bin/z_queryable_get.rs @@ -11,10 +11,9 @@ // Contributors: // ZettaScale Zenoh Team, // -use std::convert::TryFrom; -use std::time::Duration; -use zenoh::config::Config; -use zenoh::prelude::*; +use std::{convert::TryFrom, time::Duration}; + +use zenoh::{config::Config, prelude::*}; #[tokio::main] async fn main() { diff --git a/commons/zenoh-shm/src/header/storage.rs b/commons/zenoh-shm/src/header/storage.rs index c09fa83dba..36e004511a 100644 --- a/commons/zenoh-shm/src/header/storage.rs +++ b/commons/zenoh-shm/src/header/storage.rs @@ -11,12 +11,12 @@ // Contributors: // ZettaScale Zenoh Team, // -use lazy_static::lazy_static; use std::{ collections::LinkedList, sync::{Arc, Mutex}, }; +use lazy_static::lazy_static; use zenoh_result::{zerror, ZResult}; use super::{ diff --git a/commons/zenoh-shm/src/header/subscription.rs b/commons/zenoh-shm/src/header/subscription.rs index 49ad170aea..5efe54a7f7 100644 --- a/commons/zenoh-shm/src/header/subscription.rs +++ b/commons/zenoh-shm/src/header/subscription.rs @@ -11,12 +11,12 @@ // Contributors: // ZettaScale Zenoh Team, // -use lazy_static::lazy_static; use std::{ collections::BTreeMap, sync::{Arc, Mutex}, }; +use lazy_static::lazy_static; use zenoh_result::{zerror, ZResult}; use super::{ diff --git a/commons/zenoh-shm/src/posix_shm/segment.rs b/commons/zenoh-shm/src/posix_shm/segment.rs index ab79d0fcc1..5458ab3e3e 100644 --- a/commons/zenoh-shm/src/posix_shm/segment.rs +++ b/commons/zenoh-shm/src/posix_shm/segment.rs @@ -117,7 +117,7 @@ where unsafe { *(self.shmem.as_ptr() as *mut usize) } } - // TODO: dead code warning occurs because of `tested_crate_module!()` macro when feature `test` is not enabled. Better to fix that + // TODO: dead code warning occurs because of `tested_crate_module!()` macro when feature `test` is not enabled. Better to fix that #[allow(dead_code)] pub fn is_empty(&self) -> bool { unsafe { *(self.shmem.as_ptr() as *mut usize) == 0 } diff --git a/commons/zenoh-shm/src/watchdog/confirmator.rs b/commons/zenoh-shm/src/watchdog/confirmator.rs index 54c2d233dc..b84a76dc50 100644 --- a/commons/zenoh-shm/src/watchdog/confirmator.rs +++ b/commons/zenoh-shm/src/watchdog/confirmator.rs @@ -22,8 +22,8 @@ use lazy_static::lazy_static; use zenoh_result::{zerror, ZResult}; use super::{ - periodic_task::PeriodicTask, descriptor::{Descriptor, OwnedDescriptor, SegmentID}, + periodic_task::PeriodicTask, segment::Segment, }; @@ -117,7 +117,7 @@ pub struct WatchdogConfirmator { impl WatchdogConfirmator { fn new(interval: Duration) -> Self { let segment_transactions = Arc::>>::default(); - + let c_segment_transactions = segment_transactions.clone(); let mut segments: Vec<(Arc, BTreeMap)> = vec![]; let task = PeriodicTask::new("Watchdog Confirmator".to_owned(), interval, move || { diff --git a/commons/zenoh-shm/src/watchdog/periodic_task.rs b/commons/zenoh-shm/src/watchdog/periodic_task.rs index 98cf8fbba7..08a6ee18d3 100644 --- a/commons/zenoh-shm/src/watchdog/periodic_task.rs +++ b/commons/zenoh-shm/src/watchdog/periodic_task.rs @@ -23,7 +23,8 @@ use std::{ use thread_priority::ThreadBuilder; #[cfg(unix)] use thread_priority::{ - set_current_thread_priority, RealtimeThreadSchedulePolicy, ThreadPriority, ThreadPriorityValue, ThreadSchedulePolicy::Realtime + set_current_thread_priority, RealtimeThreadSchedulePolicy, ThreadPriority, ThreadPriorityValue, + ThreadSchedulePolicy::Realtime, }; pub struct PeriodicTask { @@ -44,7 +45,7 @@ impl PeriodicTask { let running = Arc::new(AtomicBool::new(true)); let c_running = running.clone(); - + #[cfg(unix)] let builder = ThreadBuilder::default() .name(name) @@ -54,7 +55,7 @@ impl PeriodicTask { // TODO: deal with windows realtime scheduling #[cfg(windows)] let builder = ThreadBuilder::default().name(name); - + let _ = builder.spawn(move |result| { if let Err(e) = result { #[cfg(windows)] @@ -79,7 +80,7 @@ impl PeriodicTask { let cycle_start = std::time::Instant::now(); f(); - + // sleep for next iteration let elapsed = cycle_start.elapsed(); if elapsed < interval { diff --git a/commons/zenoh-shm/src/watchdog/storage.rs b/commons/zenoh-shm/src/watchdog/storage.rs index 5744a273a0..1b04ad313c 100644 --- a/commons/zenoh-shm/src/watchdog/storage.rs +++ b/commons/zenoh-shm/src/watchdog/storage.rs @@ -11,12 +11,12 @@ // Contributors: // ZettaScale Zenoh Team, // -use lazy_static::lazy_static; use std::{ collections::BTreeSet, sync::{Arc, Mutex}, }; +use lazy_static::lazy_static; use zenoh_result::{zerror, ZResult}; use super::{allocated_watchdog::AllocatedWatchdog, descriptor::OwnedDescriptor, segment::Segment}; diff --git a/io/zenoh-transport/src/unicast/universal/reliability.rs b/io/zenoh-transport/src/unicast/universal/reliability.rs index b3637bee27..7aece8d077 100644 --- a/io/zenoh-transport/src/unicast/universal/reliability.rs +++ b/io/zenoh-transport/src/unicast/universal/reliability.rs @@ -11,15 +11,13 @@ // Contributors: // ZettaScale Zenoh Team, // -use std::convert::TryInto; -use std::fmt; - -use super::common::seq_num::SeqNum; -use super::core::u64; +use std::{convert::TryInto, fmt}; use zenoh_result::{ZError, ZErrorKind, ZResult}; use zenoh_util::zerror; +use super::{common::seq_num::SeqNum, core::u64}; + pub(super) struct ReliabilityQueue { sn: SeqNum, index: usize, @@ -249,9 +247,10 @@ impl fmt::Debug for ReliabilityQueue { #[cfg(test)] mod tests { - use super::*; use rand::{thread_rng, Rng}; + use super::*; + #[test] fn reliability_queue_simple() { let size = 2;