fix warnings

master
WangRunji 6 years ago
parent b2de8dc9e6
commit 3af0cf7e16

@ -200,7 +200,7 @@ pub fn detach_driver(loc: &Location) -> bool {
} }
pub fn init() { pub fn init() {
let mut pci_iter = unsafe { scan_bus(&PortOpsImpl, CSpaceAccessMethod::IO) }; let pci_iter = unsafe { scan_bus(&PortOpsImpl, CSpaceAccessMethod::IO) };
for dev in pci_iter { for dev in pci_iter {
info!( info!(
"pci: {:02x}:{:02x}.{} {:#x} {:#x} ({} {}) irq: {}:{:?}", "pci: {:02x}:{:02x}.{} {:#x} {:#x} ({} {}) irq: {}:{:?}",
@ -219,7 +219,7 @@ pub fn init() {
} }
pub fn find_device(vendor: u16, product: u16) -> Option<Location> { pub fn find_device(vendor: u16, product: u16) -> Option<Location> {
let mut pci_iter = unsafe { scan_bus(&PortOpsImpl, CSpaceAccessMethod::IO) }; let pci_iter = unsafe { scan_bus(&PortOpsImpl, CSpaceAccessMethod::IO) };
for dev in pci_iter { for dev in pci_iter {
if dev.id.vendor_id == vendor && dev.id.device_id == product { if dev.id.vendor_id == vendor && dev.id.device_id == product {
return Some(dev.loc); return Some(dev.loc);

@ -202,7 +202,7 @@ pub fn ixgbe_init(
let ip_addrs = [IpCidr::new(IpAddress::v4(10, 0, index as u8, 2), 24)]; let ip_addrs = [IpCidr::new(IpAddress::v4(10, 0, index as u8, 2), 24)];
let neighbor_cache = NeighborCache::new(BTreeMap::new()); let neighbor_cache = NeighborCache::new(BTreeMap::new());
let routes = Routes::new(BTreeMap::new()); let routes = Routes::new(BTreeMap::new());
let mut iface = EthernetInterfaceBuilder::new(net_driver.clone()) let iface = EthernetInterfaceBuilder::new(net_driver.clone())
.ethernet_addr(ethernet_addr) .ethernet_addr(ethernet_addr)
.ip_addrs(ip_addrs) .ip_addrs(ip_addrs)
.neighbor_cache(neighbor_cache) .neighbor_cache(neighbor_cache)

@ -285,7 +285,7 @@ impl Socket for TcpSocketState {
} }
} }
fn bind(&mut self, mut endpoint: Endpoint) -> SysResult { fn bind(&mut self, endpoint: Endpoint) -> SysResult {
if let Endpoint::Ip(mut ip) = endpoint { if let Endpoint::Ip(mut ip) = endpoint {
if ip.port == 0 { if ip.port == 0 {
ip.port = get_ephemeral_port(); ip.port = get_ephemeral_port();
@ -936,7 +936,7 @@ impl Socket for NetlinkSocketState {
let ifaces = NET_DRIVERS.read(); let ifaces = NET_DRIVERS.read();
for i in 0..ifaces.len() { for i in 0..ifaces.len() {
let mut msg = Vec::new(); let mut msg = Vec::new();
let mut new_header = NetlinkMessageHeader { let new_header = NetlinkMessageHeader {
nlmsg_len: 0, // to be determined later nlmsg_len: 0, // to be determined later
nlmsg_type: NetlinkMessageType::NewLink.into(), nlmsg_type: NetlinkMessageType::NewLink.into(),
nlmsg_flags: NetlinkMessageFlags::MULTI, nlmsg_flags: NetlinkMessageFlags::MULTI,
@ -994,7 +994,7 @@ impl Socket for NetlinkSocketState {
let ip_addrs = ifaces[i].get_ip_addresses(); let ip_addrs = ifaces[i].get_ip_addresses();
for j in 0..ip_addrs.len() { for j in 0..ip_addrs.len() {
let mut msg = Vec::new(); let mut msg = Vec::new();
let mut new_header = NetlinkMessageHeader { let new_header = NetlinkMessageHeader {
nlmsg_len: 0, // to be determined later nlmsg_len: 0, // to be determined later
nlmsg_type: NetlinkMessageType::NewAddr.into(), nlmsg_type: NetlinkMessageType::NewAddr.into(),
nlmsg_flags: NetlinkMessageFlags::MULTI, nlmsg_flags: NetlinkMessageFlags::MULTI,
@ -1040,7 +1040,7 @@ impl Socket for NetlinkSocketState {
_ => {} _ => {}
} }
let mut msg = Vec::new(); let mut msg = Vec::new();
let mut new_header = NetlinkMessageHeader { let new_header = NetlinkMessageHeader {
nlmsg_len: 0, // to be determined later nlmsg_len: 0, // to be determined later
nlmsg_type: NetlinkMessageType::Done.into(), nlmsg_type: NetlinkMessageType::Done.into(),
nlmsg_flags: NetlinkMessageFlags::MULTI, nlmsg_flags: NetlinkMessageFlags::MULTI,

@ -170,7 +170,7 @@ impl Thread {
header::Machine::Other(243) => {} header::Machine::Other(243) => {}
#[cfg(target_arch = "mips")] #[cfg(target_arch = "mips")]
header::Machine::Mips => {} header::Machine::Mips => {}
machine @ _ => return Err("invalid ELF arch"), _ => return Err("invalid ELF arch"),
} }
// Check interpreter (for dynamic link) // Check interpreter (for dynamic link)
@ -242,7 +242,7 @@ impl Thread {
pub fn new_user( pub fn new_user(
inode: &Arc<INode>, inode: &Arc<INode>,
exec_path: &str, exec_path: &str,
mut args: Vec<String>, args: Vec<String>,
envs: Vec<String>, envs: Vec<String>,
) -> Box<Thread> { ) -> Box<Thread> {
let (vm, entry_addr, ustack_top) = Self::new_user_vm(inode, exec_path, args, envs).unwrap(); let (vm, entry_addr, ustack_top) = Self::new_user_vm(inode, exec_path, args, envs).unwrap();

@ -22,7 +22,6 @@ impl Syscall<'_> {
// Get BAR0 memory // Get BAR0 memory
let (base, len) = pci::get_bar0_mem(tag).ok_or(SysError::ENOENT)?; let (base, len) = pci::get_bar0_mem(tag).ok_or(SysError::ENOENT)?;
let mut proc = self.process();
let virt_addr = self.vm().find_free_area(0, len); let virt_addr = self.vm().find_free_area(0, len);
let attr = MemoryAttr::default().user(); let attr = MemoryAttr::default().user();
self.vm().push( self.vm().push(
@ -48,7 +47,6 @@ impl Syscall<'_> {
paddrs: *mut u64, paddrs: *mut u64,
count: usize, count: usize,
) -> SysResult { ) -> SysResult {
let mut proc = self.process();
let vaddrs = unsafe { self.vm().check_read_array(vaddrs, count)? }; let vaddrs = unsafe { self.vm().check_read_array(vaddrs, count)? };
let paddrs = unsafe { self.vm().check_write_array(paddrs, count)? }; let paddrs = unsafe { self.vm().check_write_array(paddrs, count)? };
for i in 0..count { for i in 0..count {

@ -252,8 +252,6 @@ impl Syscall<'_> {
let iovs = unsafe { IoVecs::check_and_new(iov_ptr, iov_count, &self.vm(), false)? }; let iovs = unsafe { IoVecs::check_and_new(iov_ptr, iov_count, &self.vm(), false)? };
let buf = iovs.read_all_to_vec(); let buf = iovs.read_all_to_vec();
let len = buf.len();
let file_like = proc.get_file_like(fd)?; let file_like = proc.get_file_like(fd)?;
let len = file_like.write(buf.as_slice())?; let len = file_like.write(buf.as_slice())?;
Ok(len) Ok(len)
@ -298,7 +296,7 @@ impl Syscall<'_> {
proc.lookup_inode_at(dir_fd, &path, true)? proc.lookup_inode_at(dir_fd, &path, true)?
}; };
let mut file = FileHandle::new(inode, flags.to_options(), String::from(path)); let file = FileHandle::new(inode, flags.to_options(), String::from(path));
// for debugging // for debugging
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
@ -588,7 +586,7 @@ impl Syscall<'_> {
newdirfd: usize, newdirfd: usize,
newpath: *const u8, newpath: *const u8,
) -> SysResult { ) -> SysResult {
let mut proc = self.process(); let proc = self.process();
let oldpath = unsafe { self.vm().check_and_clone_cstr(oldpath)? }; let oldpath = unsafe { self.vm().check_and_clone_cstr(oldpath)? };
let newpath = unsafe { self.vm().check_and_clone_cstr(newpath)? }; let newpath = unsafe { self.vm().check_and_clone_cstr(newpath)? };
info!( info!(
@ -948,7 +946,6 @@ impl OpenFlags {
} }
} }
#[derive(Debug)]
#[repr(packed)] // Don't use 'C'. Or its size will align up to 8 bytes. #[repr(packed)] // Don't use 'C'. Or its size will align up to 8 bytes.
pub struct LinuxDirent64 { pub struct LinuxDirent64 {
/// Inode number /// Inode number

@ -77,8 +77,6 @@ impl Syscall<'_> {
"mprotect: addr={:#x}, size={:#x}, prot={:?}", "mprotect: addr={:#x}, size={:#x}, prot={:?}",
addr, len, prot addr, len, prot
); );
let mut proc = self.process();
let attr = prot.to_attr(); let attr = prot.to_attr();
// FIXME: properly set the attribute of the area // FIXME: properly set the attribute of the area
@ -95,7 +93,6 @@ impl Syscall<'_> {
pub fn sys_munmap(&mut self, addr: usize, len: usize) -> SysResult { pub fn sys_munmap(&mut self, addr: usize, len: usize) -> SysResult {
info!("munmap addr={:#x}, size={:#x}", addr, len); info!("munmap addr={:#x}, size={:#x}", addr, len);
let mut proc = self.process();
self.vm().pop_with_split(addr, addr + len); self.vm().pop_with_split(addr, addr + len);
Ok(0) Ok(0)
} }

@ -23,7 +23,6 @@ impl Syscall<'_> {
let offset = 65; let offset = 65;
let strings = ["rCore", "orz", "0.1.0", "1", "machine", "domain"]; let strings = ["rCore", "orz", "0.1.0", "1", "machine", "domain"];
let proc = self.process();
let buf = unsafe { self.vm().check_write_array(buf, strings.len() * offset)? }; let buf = unsafe { self.vm().check_write_array(buf, strings.len() * offset)? };
for i in 0..strings.len() { for i in 0..strings.len() {
@ -39,7 +38,6 @@ impl Syscall<'_> {
"sched_getaffinity: pid: {}, size: {}, mask: {:?}", "sched_getaffinity: pid: {}, size: {}, mask: {:?}",
pid, size, mask pid, size, mask
); );
let proc = self.process();
let mask = unsafe { self.vm().check_write_array(mask, size / size_of::<u32>())? }; let mask = unsafe { self.vm().check_write_array(mask, size / size_of::<u32>())? };
// we only have 4 cpu at most. // we only have 4 cpu at most.
@ -49,7 +47,6 @@ impl Syscall<'_> {
} }
pub fn sys_sysinfo(&mut self, sys_info: *mut SysInfo) -> SysResult { pub fn sys_sysinfo(&mut self, sys_info: *mut SysInfo) -> SysResult {
let proc = self.process();
let sys_info = unsafe { self.vm().check_write_ptr(sys_info)? }; let sys_info = unsafe { self.vm().check_write_ptr(sys_info)? };
let sysinfo = SysInfo::default(); let sysinfo = SysInfo::default();
@ -90,7 +87,8 @@ impl Syscall<'_> {
const OP_WAKE: u32 = 1; const OP_WAKE: u32 = 1;
const OP_PRIVATE: u32 = 128; const OP_PRIVATE: u32 = 128;
let queue = self.process().get_futex(uaddr); let mut proc = self.process();
let queue = proc.get_futex(uaddr);
match op & 0xf { match op & 0xf {
OP_WAIT => { OP_WAIT => {
@ -98,8 +96,7 @@ impl Syscall<'_> {
return Err(SysError::EAGAIN); return Err(SysError::EAGAIN);
} }
// FIXME: support timeout // FIXME: support timeout
// FIXME: fix racing queue.wait(proc);
queue._wait();
Ok(0) Ok(0)
} }
OP_WAKE => { OP_WAKE => {
@ -113,7 +110,7 @@ impl Syscall<'_> {
} }
} }
pub fn sys_reboot(&mut self, _magic: u32, magic2: u32, cmd: u32, _arg: *const u8) -> SysResult { pub fn sys_reboot(&mut self, _magic: u32, _magic2: u32, cmd: u32, _arg: *const u8) -> SysResult {
// we will skip verifying magic // we will skip verifying magic
if cmd == LINUX_REBOOT_CMD_HALT { if cmd == LINUX_REBOOT_CMD_HALT {
unsafe { unsafe {
@ -130,7 +127,6 @@ impl Syscall<'_> {
new_limit: *const RLimit, new_limit: *const RLimit,
old_limit: *mut RLimit, old_limit: *mut RLimit,
) -> SysResult { ) -> SysResult {
let proc = self.process();
info!( info!(
"prlimit64: pid: {}, resource: {}, new_limit: {:x?}, old_limit: {:x?}", "prlimit64: pid: {}, resource: {}, new_limit: {:x?}, old_limit: {:x?}",
pid, resource, new_limit, old_limit pid, resource, new_limit, old_limit
@ -171,9 +167,8 @@ impl Syscall<'_> {
} }
} }
pub fn sys_getrandom(&mut self, buf: *mut u8, len: usize, flag: u32) -> SysResult { pub fn sys_getrandom(&mut self, buf: *mut u8, len: usize, _flag: u32) -> SysResult {
//info!("getrandom: buf: {:?}, len: {:?}, falg {:?}", buf, len,flag); //info!("getrandom: buf: {:?}, len: {:?}, falg {:?}", buf, len,flag);
let mut proc = self.process();
let slice = unsafe { self.vm().check_write_array(buf, len)? }; let slice = unsafe { self.vm().check_write_array(buf, len)? };
let mut i = 0; let mut i = 0;
for elm in slice { for elm in slice {

@ -8,7 +8,6 @@ use crate::net::{
Endpoint, LinkLevelEndpoint, NetlinkEndpoint, NetlinkSocketState, PacketSocketState, Endpoint, LinkLevelEndpoint, NetlinkEndpoint, NetlinkSocketState, PacketSocketState,
RawSocketState, Socket, TcpSocketState, UdpSocketState, SOCKETS, RawSocketState, Socket, TcpSocketState, UdpSocketState, SOCKETS,
}; };
use crate::sync::{MutexGuard, SpinNoIrq, SpinNoIrqLock as Mutex};
use alloc::boxed::Box; use alloc::boxed::Box;
use core::cmp::min; use core::cmp::min;
use core::mem::size_of; use core::mem::size_of;
@ -74,7 +73,6 @@ impl Syscall<'_> {
"getsockopt: fd: {}, level: {}, optname: {} optval: {:?} optlen: {:?}", "getsockopt: fd: {}, level: {}, optname: {} optval: {:?} optlen: {:?}",
fd, level, optname, optval, optlen fd, level, optname, optval, optlen
); );
let proc = self.process();
let optlen = unsafe { self.vm().check_write_ptr(optlen)? }; let optlen = unsafe { self.vm().check_write_ptr(optlen)? };
match level { match level {
SOL_SOCKET => match optname { SOL_SOCKET => match optname {
@ -197,7 +195,7 @@ impl Syscall<'_> {
info!("sys_bind: fd: {} addr: {:?} len: {}", fd, addr, addr_len); info!("sys_bind: fd: {} addr: {:?} len: {}", fd, addr, addr_len);
let mut proc = self.process(); let mut proc = self.process();
let mut endpoint = sockaddr_to_endpoint(&mut self.vm(), addr, addr_len)?; let endpoint = sockaddr_to_endpoint(&mut self.vm(), addr, addr_len)?;
info!("sys_bind: fd: {} bind to {:?}", fd, endpoint); info!("sys_bind: fd: {} bind to {:?}", fd, endpoint);
let socket = proc.get_socket(fd)?; let socket = proc.get_socket(fd)?;

@ -12,7 +12,6 @@ impl Syscall<'_> {
return Err(SysError::EINVAL); return Err(SysError::EINVAL);
} }
let proc = self.process();
let tv = unsafe { self.vm().check_write_ptr(tv)? }; let tv = unsafe { self.vm().check_write_ptr(tv)? };
let timeval = TimeVal::get_epoch(); let timeval = TimeVal::get_epoch();
@ -23,7 +22,6 @@ impl Syscall<'_> {
pub fn sys_clock_gettime(&mut self, clock: usize, ts: *mut TimeSpec) -> SysResult { pub fn sys_clock_gettime(&mut self, clock: usize, ts: *mut TimeSpec) -> SysResult {
info!("clock_gettime: clock: {:?}, ts: {:?}", clock, ts); info!("clock_gettime: clock: {:?}, ts: {:?}", clock, ts);
let proc = self.process();
let ts = unsafe { self.vm().check_write_ptr(ts)? }; let ts = unsafe { self.vm().check_write_ptr(ts)? };
let timespec = TimeSpec::get_epoch(); let timespec = TimeSpec::get_epoch();
@ -34,7 +32,6 @@ impl Syscall<'_> {
pub fn sys_time(&mut self, time: *mut u64) -> SysResult { pub fn sys_time(&mut self, time: *mut u64) -> SysResult {
let sec = get_epoch_usec() / USEC_PER_SEC; let sec = get_epoch_usec() / USEC_PER_SEC;
if time as usize != 0 { if time as usize != 0 {
let proc = self.process();
let time = unsafe { self.vm().check_write_ptr(time)? }; let time = unsafe { self.vm().check_write_ptr(time)? };
*time = sec as u64; *time = sec as u64;
} }
@ -43,7 +40,6 @@ impl Syscall<'_> {
pub fn sys_getrusage(&mut self, who: usize, rusage: *mut RUsage) -> SysResult { pub fn sys_getrusage(&mut self, who: usize, rusage: *mut RUsage) -> SysResult {
info!("getrusage: who: {}, rusage: {:?}", who, rusage); info!("getrusage: who: {}, rusage: {:?}", who, rusage);
let proc = self.process();
let rusage = unsafe { self.vm().check_write_ptr(rusage)? }; let rusage = unsafe { self.vm().check_write_ptr(rusage)? };
let tick_base = *TICK_BASE; let tick_base = *TICK_BASE;
@ -66,7 +62,6 @@ impl Syscall<'_> {
pub fn sys_times(&mut self, buf: *mut Tms) -> SysResult { pub fn sys_times(&mut self, buf: *mut Tms) -> SysResult {
info!("times: buf: {:?}", buf); info!("times: buf: {:?}", buf);
let proc = self.process();
let buf = unsafe { self.vm().check_write_ptr(buf)? }; let buf = unsafe { self.vm().check_write_ptr(buf)? };
let tick_base = *TICK_BASE; let tick_base = *TICK_BASE;

@ -1,3 +1,4 @@
#[allow(dead_code)]
#[derive(Debug, Clone, Copy, Eq, PartialEq)] #[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum ConsoleColor { pub enum ConsoleColor {
Black, Black,

@ -1,6 +1,8 @@
//! ANSI escape sequences parser //! ANSI escape sequences parser
//! (ref: https://en.wikipedia.org/wiki/ANSI_escape_code) //! (ref: https://en.wikipedia.org/wiki/ANSI_escape_code)
#![allow(dead_code)]
use super::color::ConsoleColor; use super::color::ConsoleColor;
use heapless::consts::U8; use heapless::consts::U8;
use heapless::Vec; use heapless::Vec;

Loading…
Cancel
Save