From 95a31a369cccf2d831991a6c4aefbcf85b5b0dd6 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 22 Sep 2024 21:55:20 +0800 Subject: [PATCH] fix Copy derive and related issues in net --- services/net/src/api.rs | 2 +- services/net/src/api/ping.rs | 2 +- services/net/src/api/rkyv_enum.rs | 2 +- services/net/src/lib.rs | 2 +- services/net/src/protocols/ping.rs | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/services/net/src/api.rs b/services/net/src/api.rs index 8a76121c4..6b1beb707 100644 --- a/services/net/src/api.rs +++ b/services/net/src/api.rs @@ -375,7 +375,7 @@ pub enum ScanState { /// Indicates that the wifi susbsystem is off Off, } -#[derive(Debug, Archive, Serialize, Deserialize, Copy, Clone, Default)] +#[derive(Debug, Archive, Serialize, Deserialize, Clone, Default)] pub(crate) struct SsidList { /// IPC memory structures have to pre-allocate all their memory, but are always allocated in 4096-byte /// chunks. We could allocate up to maybe 100+ return values, but then we'd have to write a default diff --git a/services/net/src/api/ping.rs b/services/net/src/api/ping.rs index 59beb7e89..2527e40fa 100644 --- a/services/net/src/api/ping.rs +++ b/services/net/src/api/ping.rs @@ -22,7 +22,7 @@ pub enum NetPingCallback { } //////// Intra-crate Ping structures -#[derive(Debug, Archive, Serialize, Deserialize, Copy, Clone)] +#[derive(Debug, Archive, Serialize, Deserialize, Clone)] pub(crate) struct NetPingPacket { /// the address we are pinging pub endpoint: NetIpAddr, diff --git a/services/net/src/api/rkyv_enum.rs b/services/net/src/api/rkyv_enum.rs index 7e566b503..a5c5cd837 100644 --- a/services/net/src/api/rkyv_enum.rs +++ b/services/net/src/api/rkyv_enum.rs @@ -19,7 +19,7 @@ use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; use rkyv::{Archive, Deserialize, Serialize}; use smoltcp::wire::IpAddress; -#[derive(Debug, Archive, Serialize, Deserialize, Copy, Clone)] +#[derive(Debug, Archive, Serialize, Deserialize, Clone)] pub enum XousServerId { /// A SID that is shared directly with the Net crate; a private, single-use SID for best security PrivateSid([u32; 4]), diff --git a/services/net/src/lib.rs b/services/net/src/lib.rs index 45ab00dc1..723479404 100644 --- a/services/net/src/lib.rs +++ b/services/net/src/lib.rs @@ -184,7 +184,7 @@ impl NetManager { let mut ret = Vec::::new(); for maybe_item in ssid_list.list.iter() { if let Some(item) = maybe_item { - ret.push(*item); + ret.push(item.clone()); } } Ok((ret, ssid_list.state)) diff --git a/services/net/src/protocols/ping.rs b/services/net/src/protocols/ping.rs index c7ea097b3..34e239720 100644 --- a/services/net/src/protocols/ping.rs +++ b/services/net/src/protocols/ping.rs @@ -81,11 +81,11 @@ impl Ping { /// Send a single ping immediately, with the result going to an asynchronous callback pub fn ping(&self, remote: IpAddr) -> bool { - if let Some(cbs) = self.callback_server { + if let Some(cbs) = self.callback_server.as_ref() { if let Some(dispatch_op) = self.dispatch_opcode { let ping = NetPingPacket { endpoint: NetIpAddr::from(remote), - server: cbs, + server: cbs.clone(), return_opcode: dispatch_op, sent_ok: None, }; @@ -113,7 +113,7 @@ impl Ping { /// Send multiple pings by spawning a helper thread. Results go to the asynchronous callback /// specified during the creation of the Ping object. pub fn ping_spawn_thread(&self, remote: IpAddr, count: usize, delay_ms: usize) -> Option> { - if let Some(cbs) = self.callback_server { + if let Some(cbs) = &self.callback_server { if let Some(dispatch_op) = self.dispatch_opcode { let handle = thread::spawn({ let cbs = cbs.clone(); @@ -125,7 +125,7 @@ impl Ping { while cur_count < count { let ping = NetPingPacket { endpoint: NetIpAddr::from(remote), - server: cbs, + server: cbs.clone(), return_opcode: dispatch_op, sent_ok: None, };