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() {
let mut pci_iter = unsafe { scan_bus(&PortOpsImpl, CSpaceAccessMethod::IO) };
let pci_iter = unsafe { scan_bus(&PortOpsImpl, CSpaceAccessMethod::IO) };
for dev in pci_iter {
info!(
"pci: {:02x}:{:02x}.{} {:#x} {:#x} ({} {}) irq: {}:{:?}",
@ -219,7 +219,7 @@ pub fn init() {
}
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 {
if dev.id.vendor_id == vendor && dev.id.device_id == product {
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 neighbor_cache = NeighborCache::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)
.ip_addrs(ip_addrs)
.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 ip.port == 0 {
ip.port = get_ephemeral_port();
@ -936,7 +936,7 @@ impl Socket for NetlinkSocketState {
let ifaces = NET_DRIVERS.read();
for i in 0..ifaces.len() {
let mut msg = Vec::new();
let mut new_header = NetlinkMessageHeader {
let new_header = NetlinkMessageHeader {
nlmsg_len: 0, // to be determined later
nlmsg_type: NetlinkMessageType::NewLink.into(),
nlmsg_flags: NetlinkMessageFlags::MULTI,
@ -994,7 +994,7 @@ impl Socket for NetlinkSocketState {
let ip_addrs = ifaces[i].get_ip_addresses();
for j in 0..ip_addrs.len() {
let mut msg = Vec::new();
let mut new_header = NetlinkMessageHeader {
let new_header = NetlinkMessageHeader {
nlmsg_len: 0, // to be determined later
nlmsg_type: NetlinkMessageType::NewAddr.into(),
nlmsg_flags: NetlinkMessageFlags::MULTI,
@ -1040,7 +1040,7 @@ impl Socket for NetlinkSocketState {
_ => {}
}
let mut msg = Vec::new();
let mut new_header = NetlinkMessageHeader {
let new_header = NetlinkMessageHeader {
nlmsg_len: 0, // to be determined later
nlmsg_type: NetlinkMessageType::Done.into(),
nlmsg_flags: NetlinkMessageFlags::MULTI,

@ -170,7 +170,7 @@ impl Thread {
header::Machine::Other(243) => {}
#[cfg(target_arch = "mips")]
header::Machine::Mips => {}
machine @ _ => return Err("invalid ELF arch"),
_ => return Err("invalid ELF arch"),
}
// Check interpreter (for dynamic link)
@ -242,7 +242,7 @@ impl Thread {
pub fn new_user(
inode: &Arc<INode>,
exec_path: &str,
mut args: Vec<String>,
args: Vec<String>,
envs: Vec<String>,
) -> Box<Thread> {
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
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 attr = MemoryAttr::default().user();
self.vm().push(
@ -48,7 +47,6 @@ impl Syscall<'_> {
paddrs: *mut u64,
count: usize,
) -> SysResult {
let mut proc = self.process();
let vaddrs = unsafe { self.vm().check_read_array(vaddrs, count)? };
let paddrs = unsafe { self.vm().check_write_array(paddrs, 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 buf = iovs.read_all_to_vec();
let len = buf.len();
let file_like = proc.get_file_like(fd)?;
let len = file_like.write(buf.as_slice())?;
Ok(len)
@ -298,7 +296,7 @@ impl Syscall<'_> {
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
if cfg!(debug_assertions) {
@ -588,7 +586,7 @@ impl Syscall<'_> {
newdirfd: usize,
newpath: *const u8,
) -> SysResult {
let mut proc = self.process();
let proc = self.process();
let oldpath = unsafe { self.vm().check_and_clone_cstr(oldpath)? };
let newpath = unsafe { self.vm().check_and_clone_cstr(newpath)? };
info!(
@ -948,7 +946,6 @@ impl OpenFlags {
}
}
#[derive(Debug)]
#[repr(packed)] // Don't use 'C'. Or its size will align up to 8 bytes.
pub struct LinuxDirent64 {
/// Inode number

@ -77,8 +77,6 @@ impl Syscall<'_> {
"mprotect: addr={:#x}, size={:#x}, prot={:?}",
addr, len, prot
);
let mut proc = self.process();
let attr = prot.to_attr();
// 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 {
info!("munmap addr={:#x}, size={:#x}", addr, len);
let mut proc = self.process();
self.vm().pop_with_split(addr, addr + len);
Ok(0)
}

@ -23,7 +23,6 @@ impl Syscall<'_> {
let offset = 65;
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)? };
for i in 0..strings.len() {
@ -39,7 +38,6 @@ impl Syscall<'_> {
"sched_getaffinity: pid: {}, size: {}, mask: {:?}",
pid, size, mask
);
let proc = self.process();
let mask = unsafe { self.vm().check_write_array(mask, size / size_of::<u32>())? };
// we only have 4 cpu at most.
@ -49,7 +47,6 @@ impl Syscall<'_> {
}
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 sysinfo = SysInfo::default();
@ -90,7 +87,8 @@ impl Syscall<'_> {
const OP_WAKE: u32 = 1;
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 {
OP_WAIT => {
@ -98,8 +96,7 @@ impl Syscall<'_> {
return Err(SysError::EAGAIN);
}
// FIXME: support timeout
// FIXME: fix racing
queue._wait();
queue.wait(proc);
Ok(0)
}
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
if cmd == LINUX_REBOOT_CMD_HALT {
unsafe {
@ -130,7 +127,6 @@ impl Syscall<'_> {
new_limit: *const RLimit,
old_limit: *mut RLimit,
) -> SysResult {
let proc = self.process();
info!(
"prlimit64: pid: {}, resource: {}, new_limit: {:x?}, old_limit: {:x?}",
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);
let mut proc = self.process();
let slice = unsafe { self.vm().check_write_array(buf, len)? };
let mut i = 0;
for elm in slice {

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

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

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

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

Loading…
Cancel
Save