diff --git a/Cargo.toml b/Cargo.toml index a44597032c..b667e55a2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "redox_netstack" version = "0.1.0" +edition = "2021" [[bin]] name = "dnsd" diff --git a/src/dnsd/main.rs b/src/dnsd/main.rs index b52090b3a5..0fb01f491b 100644 --- a/src/dnsd/main.rs +++ b/src/dnsd/main.rs @@ -1,5 +1,3 @@ -#![feature(nll)] - extern crate dns_parser; extern crate event; #[macro_use] @@ -17,8 +15,6 @@ use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::process; use std::rc::Rc; -use syscall::{CloneFlags, EventFlags}; - mod scheme; fn run(daemon: redox_daemon::Daemon) -> Result<()> { diff --git a/src/smolnetd/device.rs b/src/smolnetd/device.rs index 9385a6c93a..63919c2be4 100644 --- a/src/smolnetd/device.rs +++ b/src/smolnetd/device.rs @@ -7,7 +7,7 @@ use std::rc::Rc; use smoltcp::time::Instant; use smoltcp::wire::EthernetAddress; -use buffer_pool::{Buffer, BufferPool}; +use crate::buffer_pool::{Buffer, BufferPool}; struct NetworkDeviceData { network_file: Rc>, diff --git a/src/smolnetd/main.rs b/src/smolnetd/main.rs index 79da5ee7f7..b359245ec3 100644 --- a/src/smolnetd/main.rs +++ b/src/smolnetd/main.rs @@ -15,8 +15,6 @@ use std::os::unix::io::{FromRawFd, RawFd}; use std::process; use std::rc::Rc; -use syscall::flag::{CloneFlags, EventFlags}; - use redox_netstack::error::{Error, Result}; use redox_netstack::logger; use event::EventQueue; diff --git a/src/smolnetd/scheme/icmp.rs b/src/smolnetd/scheme/icmp.rs index ddb31bc030..cd65926f81 100644 --- a/src/smolnetd/scheme/icmp.rs +++ b/src/smolnetd/scheme/icmp.rs @@ -6,8 +6,8 @@ use syscall::{Error as SyscallError, Result as SyscallResult}; use syscall; use byteorder::{ByteOrder, NetworkEndian}; -use device::NetworkDevice; -use port_set::PortSet; +use crate::device::NetworkDevice; +use crate::port_set::PortSet; use super::socket::{DupResult, SchemeFile, SchemeSocket, SocketFile, SocketScheme}; use super::{Smolnetd, SocketSet}; diff --git a/src/smolnetd/scheme/ip.rs b/src/smolnetd/scheme/ip.rs index 97a83cad32..b13cbc2720 100644 --- a/src/smolnetd/scheme/ip.rs +++ b/src/smolnetd/scheme/ip.rs @@ -4,7 +4,7 @@ use std::str; use syscall::{Error as SyscallError, Result as SyscallResult}; use syscall; -use device::NetworkDevice; +use crate::device::NetworkDevice; use super::{Smolnetd, SocketSet}; use super::socket::{DupResult, SchemeFile, SchemeSocket, SocketFile, SocketScheme}; diff --git a/src/smolnetd/scheme/mod.rs b/src/smolnetd/scheme/mod.rs index 3a194410cf..eab5942b29 100644 --- a/src/smolnetd/scheme/mod.rs +++ b/src/smolnetd/scheme/mod.rs @@ -15,8 +15,8 @@ use std::str::FromStr; use syscall::data::TimeSpec; use syscall; -use buffer_pool::{Buffer, BufferPool}; -use device::NetworkDevice; +use crate::buffer_pool::{Buffer, BufferPool}; +use crate::device::NetworkDevice; use redox_netstack::error::{Error, Result}; use self::ip::IpScheme; use self::tcp::TcpScheme; diff --git a/src/smolnetd/scheme/netcfg/mod.rs b/src/smolnetd/scheme/netcfg/mod.rs index 7e91303322..c64b310092 100644 --- a/src/smolnetd/scheme/netcfg/mod.rs +++ b/src/smolnetd/scheme/netcfg/mod.rs @@ -284,7 +284,7 @@ struct NetCfgFile { is_dir: bool, is_writable: bool, is_readable: bool, - node_writer: Option>, + node_writer: Option>, read_buf: Vec, write_buf: Vec, pos: usize, diff --git a/src/smolnetd/scheme/netcfg/nodes.rs b/src/smolnetd/scheme/netcfg/nodes.rs index 398a4e7c38..16bacb6242 100644 --- a/src/smolnetd/scheme/netcfg/nodes.rs +++ b/src/smolnetd/scheme/netcfg/nodes.rs @@ -3,10 +3,10 @@ use std::rc::Rc; use std::collections::BTreeMap; use syscall::Result as SyscallResult; -pub type CfgNodeRef = Rc>; +pub type CfgNodeRef = Rc>; pub trait NodeWriter { - fn write_line(&mut self, &str) -> SyscallResult<()> { + fn write_line(&mut self, _: &str) -> SyscallResult<()> { Ok(()) } @@ -74,7 +74,7 @@ pub trait CfgNode { None } - fn new_writer(&self) -> Option> { + fn new_writer(&self) -> Option> { None } } @@ -106,14 +106,14 @@ where pub struct WONode where - W: 'static + Fn() -> Box, + W: 'static + Fn() -> Box, { new_writer: W, } impl CfgNode for WONode where - W: 'static + Fn() -> Box, + W: 'static + Fn() -> Box, { fn is_readable(&self) -> bool { false @@ -123,14 +123,14 @@ where true } - fn new_writer(&self) -> Option> { + fn new_writer(&self) -> Option> { Some((self.new_writer)()) } } impl WONode where - W: 'static + Fn() -> Box, + W: 'static + Fn() -> Box, { pub fn new_ref(new_writer: W) -> CfgNodeRef { Rc::new(RefCell::new(WONode { new_writer })) @@ -140,7 +140,7 @@ where pub struct RWNode where F: Fn() -> String, - W: 'static + Fn() -> Box, + W: 'static + Fn() -> Box, { read_fun: F, new_writer: W, @@ -149,7 +149,7 @@ where impl CfgNode for RWNode where F: Fn() -> String, - W: 'static + Fn() -> Box, + W: 'static + Fn() -> Box, { fn read(&self) -> String { (self.read_fun)() @@ -159,7 +159,7 @@ where true } - fn new_writer(&self) -> Option> { + fn new_writer(&self) -> Option> { Some((self.new_writer)()) } } @@ -167,7 +167,7 @@ where impl RWNode where F: 'static + Fn() -> String, - W: 'static + Fn() -> Box, + W: 'static + Fn() -> Box, { pub fn new_ref(read_fun: F, new_writer: W) -> CfgNodeRef { Rc::new(RefCell::new(RWNode { @@ -221,14 +221,14 @@ macro_rules! cfg_node { (wo [ $($c:ident),* ] ( $et:ty , $e:expr ) |$data_i:ident, $line_i:ident| $write_line:block |$data_i2:ident| $commit:block) => { { - $(#[allow(unused_variables)] let $c = $c.clone();)*; - let new_writer = move || -> Box { + $(#[allow(unused_variables)] let $c = $c.clone();)* + let new_writer = move || -> Box { let write_line = { - $(#[allow(unused_variables)] let $c = $c.clone();)*; + $(#[allow(unused_variables)] let $c = $c.clone();)* move |$data_i: &mut $et, $line_i: &str| $write_line }; let commit = { - $(#[allow(unused_variables)] let $c = $c.clone();)*; + $(#[allow(unused_variables)] let $c = $c.clone();)* move |$data_i2: &mut $et| $commit }; let data: $et = $e; @@ -241,17 +241,17 @@ macro_rules! cfg_node { $write_line:block |$data_i2:ident| $commit:block) => { { let read_fun = { - $(#[allow(unused_variables)] let $c = $c.clone();)*; + $(#[allow(unused_variables)] let $c = $c.clone();)* move || $read_fun }; - $(#[allow(unused_variables)] let $c = $c.clone();)*; - let new_writer = move || -> Box { + $(#[allow(unused_variables)] let $c = $c.clone();)* + let new_writer = move || -> Box { let write_line = { - $(#[allow(unused_variables)] let $c = $c.clone();)*; + $(#[allow(unused_variables)] let $c = $c.clone();)* move |$data_i: &mut $et, $line_i: &str| $write_line }; let commit = { - $(#[allow(unused_variables)] let $c = $c.clone();)*; + $(#[allow(unused_variables)] let $c = $c.clone();)* move |$data_i2: &mut $et| $commit }; let data: $et = $e; diff --git a/src/smolnetd/scheme/socket.rs b/src/smolnetd/scheme/socket.rs index 7dd3d665f1..b61ee1ce23 100644 --- a/src/smolnetd/scheme/socket.rs +++ b/src/smolnetd/scheme/socket.rs @@ -160,31 +160,31 @@ where fn may_recv(&self) -> bool; fn hop_limit(&self) -> u8; - fn set_hop_limit(&mut self, u8); + fn set_hop_limit(&mut self, hop_limit: u8); - fn get_setting(&SocketFile, Self::SettingT, &mut [u8]) -> SyscallResult; - fn set_setting(&mut SocketFile, Self::SettingT, &[u8]) -> SyscallResult; + fn get_setting(file: &SocketFile, setting: Self::SettingT, buf: &mut [u8]) -> SyscallResult; + fn set_setting(file: &mut SocketFile, setting: Self::SettingT, buf: &[u8]) -> SyscallResult; fn new_socket( - &mut SocketSet, - &str, - u32, - &mut Self::SchemeDataT, + sockets: &mut SocketSet, + path: &str, + uid: u32, + data: &mut Self::SchemeDataT, ) -> SyscallResult<(SocketHandle, Self::DataT)>; - fn close_file(&self, &SchemeFile, &mut Self::SchemeDataT) -> SyscallResult<()>; + fn close_file(&self, file: &SchemeFile, data: &mut Self::SchemeDataT) -> SyscallResult<()>; - fn write_buf(&mut self, &mut SocketFile, buf: &[u8]) -> SyscallResult>; + fn write_buf(&mut self, file: &mut SocketFile, buf: &[u8]) -> SyscallResult>; - fn read_buf(&mut self, &mut SocketFile, buf: &mut [u8]) -> SyscallResult>; + fn read_buf(&mut self, file: &mut SocketFile, buf: &mut [u8]) -> SyscallResult>; - fn fpath(&self, &SchemeFile, &mut [u8]) -> SyscallResult; + fn fpath(&self, file: &SchemeFile, buf: &mut [u8]) -> SyscallResult; fn dup( - &mut SocketSet, - &mut SchemeFile, - &str, - &mut Self::SchemeDataT, + sockets: &mut SocketSet, + file: &mut SchemeFile, + path: &str, + data: &mut Self::SchemeDataT, ) -> SyscallResult>; } @@ -242,7 +242,7 @@ where Ok(timeout) => { self.wait_queue.push(WaitHandle { until: timeout, - packet: packet, + packet, }); }, Err(err) => { @@ -442,8 +442,8 @@ where fn open(&mut self, path: &str, flags: usize, uid: u32, _gid: u32) -> SyscallResult> { if path.is_empty() { let null = NullFile { - flags: flags, - uid: uid, + flags, + uid, gid: _gid, }; diff --git a/src/smolnetd/scheme/tcp.rs b/src/smolnetd/scheme/tcp.rs index ab33ff3c9f..200ba42aa4 100644 --- a/src/smolnetd/scheme/tcp.rs +++ b/src/smolnetd/scheme/tcp.rs @@ -3,7 +3,7 @@ use std::str; use syscall::{Error as SyscallError, Result as SyscallResult}; use syscall; -use port_set::PortSet; +use crate::port_set::PortSet; use super::socket::{DupResult, SchemeFile, SchemeSocket, SocketFile, SocketScheme}; use super::{parse_endpoint, SocketSet}; diff --git a/src/smolnetd/scheme/udp.rs b/src/smolnetd/scheme/udp.rs index d253e1aa10..646821f625 100644 --- a/src/smolnetd/scheme/udp.rs +++ b/src/smolnetd/scheme/udp.rs @@ -4,8 +4,8 @@ use std::str; use syscall::{Error as SyscallError, Result as SyscallResult}; use syscall; -use device::NetworkDevice; -use port_set::PortSet; +use crate::device::NetworkDevice; +use crate::port_set::PortSet; use super::socket::{DupResult, SchemeFile, SchemeSocket, SocketFile, SocketScheme}; use super::{parse_endpoint, Smolnetd, SocketSet};