Fix warnings and bump Rust edition to 2021
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
[package]
|
||||
name = "redox_netstack"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "dnsd"
|
||||
|
||||
@@ -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<()> {
|
||||
|
||||
@@ -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<RefCell<File>>,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -284,7 +284,7 @@ struct NetCfgFile {
|
||||
is_dir: bool,
|
||||
is_writable: bool,
|
||||
is_readable: bool,
|
||||
node_writer: Option<Box<NodeWriter>>,
|
||||
node_writer: Option<Box<dyn NodeWriter>>,
|
||||
read_buf: Vec<u8>,
|
||||
write_buf: Vec<u8>,
|
||||
pos: usize,
|
||||
|
||||
@@ -3,10 +3,10 @@ use std::rc::Rc;
|
||||
use std::collections::BTreeMap;
|
||||
use syscall::Result as SyscallResult;
|
||||
|
||||
pub type CfgNodeRef = Rc<RefCell<CfgNode>>;
|
||||
pub type CfgNodeRef = Rc<RefCell<dyn CfgNode>>;
|
||||
|
||||
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<Box<NodeWriter>> {
|
||||
fn new_writer(&self) -> Option<Box<dyn NodeWriter>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -106,14 +106,14 @@ where
|
||||
|
||||
pub struct WONode<W>
|
||||
where
|
||||
W: 'static + Fn() -> Box<NodeWriter>,
|
||||
W: 'static + Fn() -> Box<dyn NodeWriter>,
|
||||
{
|
||||
new_writer: W,
|
||||
}
|
||||
|
||||
impl<W> CfgNode for WONode<W>
|
||||
where
|
||||
W: 'static + Fn() -> Box<NodeWriter>,
|
||||
W: 'static + Fn() -> Box<dyn NodeWriter>,
|
||||
{
|
||||
fn is_readable(&self) -> bool {
|
||||
false
|
||||
@@ -123,14 +123,14 @@ where
|
||||
true
|
||||
}
|
||||
|
||||
fn new_writer(&self) -> Option<Box<NodeWriter>> {
|
||||
fn new_writer(&self) -> Option<Box<dyn NodeWriter>> {
|
||||
Some((self.new_writer)())
|
||||
}
|
||||
}
|
||||
|
||||
impl<W> WONode<W>
|
||||
where
|
||||
W: 'static + Fn() -> Box<NodeWriter>,
|
||||
W: 'static + Fn() -> Box<dyn NodeWriter>,
|
||||
{
|
||||
pub fn new_ref(new_writer: W) -> CfgNodeRef {
|
||||
Rc::new(RefCell::new(WONode { new_writer }))
|
||||
@@ -140,7 +140,7 @@ where
|
||||
pub struct RWNode<F, W>
|
||||
where
|
||||
F: Fn() -> String,
|
||||
W: 'static + Fn() -> Box<NodeWriter>,
|
||||
W: 'static + Fn() -> Box<dyn NodeWriter>,
|
||||
{
|
||||
read_fun: F,
|
||||
new_writer: W,
|
||||
@@ -149,7 +149,7 @@ where
|
||||
impl<F, W> CfgNode for RWNode<F, W>
|
||||
where
|
||||
F: Fn() -> String,
|
||||
W: 'static + Fn() -> Box<NodeWriter>,
|
||||
W: 'static + Fn() -> Box<dyn NodeWriter>,
|
||||
{
|
||||
fn read(&self) -> String {
|
||||
(self.read_fun)()
|
||||
@@ -159,7 +159,7 @@ where
|
||||
true
|
||||
}
|
||||
|
||||
fn new_writer(&self) -> Option<Box<NodeWriter>> {
|
||||
fn new_writer(&self) -> Option<Box<dyn NodeWriter>> {
|
||||
Some((self.new_writer)())
|
||||
}
|
||||
}
|
||||
@@ -167,7 +167,7 @@ where
|
||||
impl<F, W> RWNode<F, W>
|
||||
where
|
||||
F: 'static + Fn() -> String,
|
||||
W: 'static + Fn() -> Box<NodeWriter>,
|
||||
W: 'static + Fn() -> Box<dyn NodeWriter>,
|
||||
{
|
||||
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<NodeWriter> {
|
||||
$(#[allow(unused_variables)] let $c = $c.clone();)*
|
||||
let new_writer = move || -> Box<dyn NodeWriter> {
|
||||
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<NodeWriter> {
|
||||
$(#[allow(unused_variables)] let $c = $c.clone();)*
|
||||
let new_writer = move || -> Box<dyn NodeWriter> {
|
||||
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;
|
||||
|
||||
@@ -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::DataT>, Self::SettingT, &mut [u8]) -> SyscallResult<usize>;
|
||||
fn set_setting(&mut SocketFile<Self::DataT>, Self::SettingT, &[u8]) -> SyscallResult<usize>;
|
||||
fn get_setting(file: &SocketFile<Self::DataT>, setting: Self::SettingT, buf: &mut [u8]) -> SyscallResult<usize>;
|
||||
fn set_setting(file: &mut SocketFile<Self::DataT>, setting: Self::SettingT, buf: &[u8]) -> SyscallResult<usize>;
|
||||
|
||||
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<Self>, &mut Self::SchemeDataT) -> SyscallResult<()>;
|
||||
fn close_file(&self, file: &SchemeFile<Self>, data: &mut Self::SchemeDataT) -> SyscallResult<()>;
|
||||
|
||||
fn write_buf(&mut self, &mut SocketFile<Self::DataT>, buf: &[u8]) -> SyscallResult<Option<usize>>;
|
||||
fn write_buf(&mut self, file: &mut SocketFile<Self::DataT>, buf: &[u8]) -> SyscallResult<Option<usize>>;
|
||||
|
||||
fn read_buf(&mut self, &mut SocketFile<Self::DataT>, buf: &mut [u8]) -> SyscallResult<Option<usize>>;
|
||||
fn read_buf(&mut self, file: &mut SocketFile<Self::DataT>, buf: &mut [u8]) -> SyscallResult<Option<usize>>;
|
||||
|
||||
fn fpath(&self, &SchemeFile<Self>, &mut [u8]) -> SyscallResult<usize>;
|
||||
fn fpath(&self, file: &SchemeFile<Self>, buf: &mut [u8]) -> SyscallResult<usize>;
|
||||
|
||||
fn dup(
|
||||
&mut SocketSet,
|
||||
&mut SchemeFile<Self>,
|
||||
&str,
|
||||
&mut Self::SchemeDataT,
|
||||
sockets: &mut SocketSet,
|
||||
file: &mut SchemeFile<Self>,
|
||||
path: &str,
|
||||
data: &mut Self::SchemeDataT,
|
||||
) -> SyscallResult<DupResult<Self>>;
|
||||
}
|
||||
|
||||
@@ -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<Option<usize>> {
|
||||
if path.is_empty() {
|
||||
let null = NullFile {
|
||||
flags: flags,
|
||||
uid: uid,
|
||||
flags,
|
||||
uid,
|
||||
gid: _gid,
|
||||
};
|
||||
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user