Finally, get rid of all rust warnings
Just a small step along the way to reduce the massive wall of spam every time you compile. This was done partly automagically with `cargo fix`. The rest was me deleting or commenting out a bunch of variables. Hope nothing was important...
This commit is contained in:
+6
-6
@@ -1,10 +1,12 @@
|
||||
use platform::types::*;
|
||||
|
||||
// TODO: Implement cxa_finalize and uncomment this
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct CxaAtExitFunc {
|
||||
func: extern "C" fn(*mut c_void),
|
||||
arg: *mut c_void,
|
||||
dso: *mut c_void,
|
||||
//func: extern "C" fn(*mut c_void),
|
||||
//arg: *mut c_void,
|
||||
//dso: *mut c_void,
|
||||
}
|
||||
|
||||
static mut CXA_ATEXIT_FUNCS: [Option<CxaAtExitFunc>; 32] = [None; 32];
|
||||
@@ -17,12 +19,10 @@ pub unsafe extern "C" fn __cxa_atexit(
|
||||
) -> c_int {
|
||||
for item in &mut CXA_ATEXIT_FUNCS {
|
||||
if item.is_none() {
|
||||
*item = func_opt.map(|func| CxaAtExitFunc { func, arg, dso });
|
||||
*item = func_opt.map(|func| CxaAtExitFunc {} /*{ func, arg, dso }*/);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
-1
|
||||
}
|
||||
|
||||
// TODO: cxa_finalize
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! dlfcn implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/dlfcn.h.html
|
||||
|
||||
use core::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
|
||||
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||
use core::{ptr, str};
|
||||
|
||||
use c_str::CStr;
|
||||
@@ -14,7 +14,7 @@ pub const RTLD_LOCAL: c_int = 0x0000;
|
||||
static ERROR_NOT_SUPPORTED: &'static CStr = c_str!("dlfcn not supported");
|
||||
|
||||
#[thread_local]
|
||||
static ERROR: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
static ERROR: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
#[repr(C)]
|
||||
pub struct Dl_info {
|
||||
|
||||
+4
-18
@@ -17,7 +17,7 @@ use header::fcntl::O_RDONLY;
|
||||
use header::netinet_in::{in_addr, sockaddr_in, sockaddr_in6};
|
||||
use header::stdlib::atoi;
|
||||
use header::strings::strcasecmp;
|
||||
use header::sys_socket::constants::{AF_UNSPEC, AF_INET};
|
||||
use header::sys_socket::constants::{AF_INET};
|
||||
use header::sys_socket::{sa_family_t, sockaddr, socklen_t};
|
||||
use header::unistd::SEEK_SET;
|
||||
use platform;
|
||||
@@ -39,9 +39,6 @@ pub mod host;
|
||||
pub use self::lookup::*;
|
||||
pub mod lookup;
|
||||
|
||||
const MAXADDRS: usize = 35;
|
||||
const MAXALIASES: usize = 35;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct hostent {
|
||||
h_name: *mut c_char,
|
||||
@@ -118,15 +115,6 @@ pub const NI_NAMEREQD: c_int = 0x0008;
|
||||
pub const NI_DGRAM: c_int = 0x0010;
|
||||
|
||||
static mut NETDB: c_int = 0;
|
||||
static mut NET_ENTRY: netent = netent {
|
||||
n_name: ptr::null_mut(),
|
||||
n_aliases: ptr::null_mut(),
|
||||
n_addrtype: 0,
|
||||
n_net: 0,
|
||||
};
|
||||
static mut NET_NAME: Option<Vec<u8>> = None;
|
||||
static mut NET_ALIASES: [*const c_char; MAXALIASES] = [ptr::null(); MAXALIASES];
|
||||
static mut NET_NUM: Option<u64> = None;
|
||||
static mut N_POS: usize = 0;
|
||||
static mut NET_STAYOPEN: c_int = 0;
|
||||
|
||||
@@ -164,8 +152,6 @@ static mut SERV_PROTO: Option<Vec<u8>> = None;
|
||||
static mut S_POS: usize = 0;
|
||||
static mut SERV_STAYOPEN: c_int = 0;
|
||||
|
||||
const NULL_ALIASES: [*mut c_char; 2] = [ptr::null_mut(); 2];
|
||||
|
||||
fn bytes_to_box_str(bytes: &[u8]) -> Box<str> {
|
||||
Box::from(core::str::from_utf8(bytes).unwrap_or(""))
|
||||
}
|
||||
@@ -680,9 +666,9 @@ pub unsafe extern "C" fn getaddrinfo(
|
||||
|
||||
//TODO: Use hints
|
||||
let mut ai_flags = hints_opt.map_or(0, |hints| hints.ai_flags);
|
||||
let mut ai_family = hints_opt.map_or(AF_UNSPEC, |hints| hints.ai_family);
|
||||
let mut ai_socktype = hints_opt.map_or(0, |hints| hints.ai_socktype);
|
||||
let mut ai_protocol = hints_opt.map_or(0, |hints| hints.ai_protocol);
|
||||
let mut ai_family;// = hints_opt.map_or(AF_UNSPEC, |hints| hints.ai_family);
|
||||
let ai_socktype = hints_opt.map_or(0, |hints| hints.ai_socktype);
|
||||
let mut ai_protocol;// = hints_opt.map_or(0, |hints| hints.ai_protocol);
|
||||
|
||||
*res = ptr::null_mut();
|
||||
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
//! sgtty implementation that won't work on redox because no ioctl
|
||||
|
||||
use core::fmt::Write;
|
||||
|
||||
use header::sys_ioctl::*;
|
||||
use platform;
|
||||
use platform::types::*;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn gtty(fd: c_int, out: *mut sgttyb) -> c_int {
|
||||
writeln!(
|
||||
platform::FileWriter(2),
|
||||
eprintln!(
|
||||
"unimplemented: gtty({}, {:p})",
|
||||
fd,
|
||||
out
|
||||
|
||||
@@ -189,7 +189,7 @@ fn float_string(float: c_double, precision: usize, trim: bool) -> String {
|
||||
let mut string = format!("{:.p$}", float, p = precision);
|
||||
if trim {
|
||||
let truncate = {
|
||||
let mut slice = string.trim_right_matches('0');
|
||||
let mut slice = string.trim_end_matches('0');
|
||||
if slice.ends_with('.') {
|
||||
slice.len() - 1
|
||||
} else {
|
||||
|
||||
@@ -458,7 +458,7 @@ where
|
||||
}
|
||||
|
||||
let mut rng = JitterRng::new_with_timer(get_nstime);
|
||||
rng.test_timer();
|
||||
let _ = rng.test_timer();
|
||||
|
||||
for _ in 0..100 {
|
||||
let char_iter = iter::repeat(())
|
||||
|
||||
@@ -217,9 +217,9 @@ pub unsafe extern "C" fn strerror(errnum: c_int) -> *mut c_char {
|
||||
let mut w = platform::StringWriter(strerror_buf.as_mut_ptr(), strerror_buf.len());
|
||||
|
||||
if errnum >= 0 && errnum < STR_ERROR.len() as c_int {
|
||||
w.write_str(STR_ERROR[errnum as usize]);
|
||||
let _ = w.write_str(STR_ERROR[errnum as usize]);
|
||||
} else {
|
||||
w.write_fmt(format_args!("Unknown error {}", errnum));
|
||||
let _ = w.write_fmt(format_args!("Unknown error {}", errnum));
|
||||
}
|
||||
|
||||
strerror_buf.as_mut_ptr() as *mut c_char
|
||||
|
||||
@@ -29,12 +29,12 @@ pub extern "C" fn ffs(i: c_int) -> c_int {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn index(mut s: *const c_char, c: c_int) -> *mut c_char {
|
||||
pub unsafe extern "C" fn index(s: *const c_char, c: c_int) -> *mut c_char {
|
||||
string::strchr(s, c)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn rindex(mut s: *const c_char, c: c_int) -> *mut c_char {
|
||||
pub unsafe extern "C" fn rindex(s: *const c_char, c: c_int) -> *mut c_char {
|
||||
string::strrchr(s, c)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -209,7 +209,7 @@ impl Linker {
|
||||
}
|
||||
|
||||
// Allocate TLS
|
||||
let mut tcb = unsafe { Tcb::new(tls_size)? };
|
||||
let tcb = unsafe { Tcb::new(tls_size)? };
|
||||
println!("tcb {:x?}", tcb);
|
||||
|
||||
// Copy data
|
||||
|
||||
+5
-5
@@ -22,7 +22,7 @@ pub extern "C" fn relibc_ld_so_start(sp: &'static mut Stack) -> usize {
|
||||
|
||||
// Some variables that will be overridden by environment and auxiliary vectors
|
||||
let mut library_path = "/lib";
|
||||
let mut page_size = 4096;
|
||||
//let mut page_size = 4096;
|
||||
|
||||
// Pop the first argument (path to ld_so), and get the path of the program
|
||||
let path_c = unsafe {
|
||||
@@ -85,10 +85,10 @@ pub extern "C" fn relibc_ld_so_start(sp: &'static mut Stack) -> usize {
|
||||
}
|
||||
|
||||
println!(" aux: {}={:#x}", kind, value);
|
||||
match kind {
|
||||
6 => page_size = value,
|
||||
_ => (),
|
||||
}
|
||||
//match kind {
|
||||
// 6 => page_size = value,
|
||||
// _ => (),
|
||||
//}
|
||||
}
|
||||
|
||||
sp.argc -= 1;
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ use core::{mem, ptr, slice};
|
||||
use core::ops::Range;
|
||||
use goblin::error::{Error, Result};
|
||||
|
||||
use header::{sys_mman, unistd};
|
||||
use header::sys_mman;
|
||||
|
||||
use super::PAGE_SIZE;
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ use super::super::PalSocket;
|
||||
use super::{e, Sys};
|
||||
use header::sys_socket::{sockaddr, socklen_t};
|
||||
|
||||
impl Sys {
|
||||
fn socketpair(domain: c_int, kind: c_int, protocol: c_int, socket_vector: *mut c_int) -> c_int {
|
||||
e(unsafe { syscall!(SOCKETPAIR, domain, kind, protocol, socket_vector) }) as c_int
|
||||
}
|
||||
}
|
||||
//impl Sys {
|
||||
// fn socketpair(domain: c_int, kind: c_int, protocol: c_int, socket_vector: *mut c_int) -> c_int {
|
||||
// e(unsafe { syscall!(SOCKETPAIR, domain, kind, protocol, socket_vector) }) as c_int
|
||||
// }
|
||||
//}
|
||||
|
||||
impl PalSocket for Sys {
|
||||
unsafe fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int {
|
||||
|
||||
+4
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use alloc::collections::BTreeMap;
|
||||
use core::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
|
||||
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||
use core::{intrinsics, ptr};
|
||||
|
||||
use header::sys_mman;
|
||||
@@ -24,6 +24,7 @@ type pte_osThreadEntryPoint = unsafe extern "C" fn(params: *mut c_void) -> c_int
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq)]
|
||||
#[allow(dead_code)]
|
||||
pub enum pte_osResult {
|
||||
PTE_OS_OK = 0,
|
||||
PTE_OS_NO_RESOURCES,
|
||||
@@ -44,7 +45,7 @@ static mut pid_stacks_lock: i32 = 0;
|
||||
#[thread_local]
|
||||
static mut LOCALS: *mut BTreeMap<c_uint, *mut c_void> = ptr::null_mut();
|
||||
|
||||
static NEXT_KEY: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
static NEXT_KEY: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
unsafe fn locals() -> &'static mut BTreeMap<c_uint, *mut c_void> {
|
||||
if LOCALS == ptr::null_mut() {
|
||||
@@ -71,7 +72,7 @@ unsafe extern "C" fn pte_osThreadShim(
|
||||
// The kernel allocated TLS does not have masters set, so do not attempt to copy it.
|
||||
// It will be copied by the kernel.
|
||||
if ! tls_masters_ptr.is_null() {
|
||||
let mut tcb = Tcb::new(tls_size).unwrap();
|
||||
let tcb = Tcb::new(tls_size).unwrap();
|
||||
tcb.masters_ptr = tls_masters_ptr;
|
||||
tcb.masters_len = tls_masters_len;
|
||||
tcb.copy_masters().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user