diff --git a/src/header/assert/mod.rs b/src/header/assert/mod.rs index 838050f9ac752c4399d24213372f5aa8ba196b76..ffbcecffda964e2ed72c1503745159c02f62b296 100644 --- a/src/header/assert/mod.rs +++ b/src/header/assert/mod.rs @@ -3,7 +3,6 @@ use c_str::CStr; use core::fmt::Write; use header::{stdio, stdlib}; -use platform; use platform::types::*; #[no_mangle] diff --git a/src/header/netdb/linux.rs b/src/header/netdb/linux.rs index 400c07a6c7d70dea136c09b85abcdc25f1d05d8d..5eb07b3336a2a9edf90923e73bc439b75bb2b6fa 100644 --- a/src/header/netdb/linux.rs +++ b/src/header/netdb/linux.rs @@ -12,7 +12,7 @@ pub fn get_dns_server() -> String { Ok(file) => file, Err(_) => return String::new(), // TODO: better error handling }; - let mut file = BufReader::new(file); + let file = BufReader::new(file); for line in file.split(b'\n') { let mut line = match line { diff --git a/src/header/netdb/mod.rs b/src/header/netdb/mod.rs index 0f81980ca9316fa4f12e9d81f14fadfc8639a970..485b83383d699a4811f3ef9d42a22be256728c1d 100644 --- a/src/header/netdb/mod.rs +++ b/src/header/netdb/mod.rs @@ -227,15 +227,11 @@ fn lookup_host(host: &str) -> Result<LookupHost, c_int> { Box::from_raw(packet_data_ptr); } - let mut i = 0 as socklen_t; + let i = 0 as socklen_t; let mut buf = [0u8; 65536]; let buf_ptr = buf.as_mut_ptr() as *mut c_void; - let mut count = -1; - - unsafe { - count = sys_socket::recv(sock, buf_ptr, 65536, 0); - } + let count = unsafe { sys_socket::recv(sock, buf_ptr, 65536, 0) }; if count < 0 { return Err(EIO); } @@ -347,15 +343,11 @@ fn lookup_addr(addr: in_addr) -> Result<Vec<Vec<u8>>, c_int> { Box::from_raw(packet_data_ptr); } - let mut i = mem::size_of::<sockaddr_in>() as socklen_t; + let i = mem::size_of::<sockaddr_in>() as socklen_t; let mut buf = [0u8; 65536]; let buf_ptr = buf.as_mut_ptr() as *mut c_void; - let mut count = -1; - - unsafe { - count = sys_socket::recv(sock, buf_ptr, 65536, 0); - } + let count = unsafe { sys_socket::recv(sock, buf_ptr, 65536, 0) }; if count < 0 { return Err(EIO); } @@ -385,11 +377,10 @@ fn lookup_addr(addr: in_addr) -> Result<Vec<Vec<u8>>, c_int> { fn parse_revdns_answer(data: Vec<u8>) -> Vec<u8> { let mut cursor = 0; - let mut offset = 0; let mut index = 0; let mut output = data.clone(); while index < data.len() - 1 { - offset = data[index] as usize; + let offset = data[index] as usize; index = cursor + offset + 1; output[index] = '.' as u8; cursor = index; @@ -855,10 +846,10 @@ pub unsafe extern "C" fn getservent() -> *const servent { let mut rlb = RawLineBuffer::new(SERVDB); rlb.seek(S_POS); - let mut r: Box<str> = Box::default(); + let r: Box<str> = Box::default(); loop { - let mut r = match rlb.next() { + let r = match rlb.next() { Line::Some(s) => bytes_to_box_str(s), _ => { if SERV_STAYOPEN == 0 { diff --git a/src/header/regex/mod.rs b/src/header/regex/mod.rs index eedc462822bb1bba45ff3c0a27792ed0d3edad01..d3eab6c92c3bfc6e6b8930e5a2746175d5dc7b3c 100644 --- a/src/header/regex/mod.rs +++ b/src/header/regex/mod.rs @@ -1,7 +1,6 @@ //! regex.h implementation, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/regex.h.html use alloc::borrow::Cow; -use alloc::boxed::Box; use alloc::vec::Vec; use core::{mem, slice, ptr}; use header::string::strlen; @@ -116,7 +115,7 @@ pub extern "C" fn regexec(regex: *const regex_t, input: *const c_char, // Allow specifying a compiler argument to the executor and vise versa // because why not? - let mut flags = regex.cflags | eflags; + let flags = regex.cflags | eflags; let input = unsafe { slice::from_raw_parts(input as *const u8, strlen(input)) }; diff --git a/src/header/stdio/default.rs b/src/header/stdio/default.rs index 5d3fe1e0a296319dab0f068767c6970858fe5cec..952ac55622c90e86c4b48c7e0e8c3f252e1e3ae9 100644 --- a/src/header/stdio/default.rs +++ b/src/header/stdio/default.rs @@ -1,7 +1,6 @@ -use super::{constants, Buffer, BUFSIZ, FILE, UNGET}; +use super::{constants, Buffer, BUFSIZ, FILE}; use core::cell::UnsafeCell; use core::ptr; -use core::sync::atomic::AtomicBool; use fs::File; use io::LineWriter; diff --git a/src/header/stdio/helpers.rs b/src/header/stdio/helpers.rs index 3fff7993573353808e3fc610dff1558ee5552ff1..126c009a0375237fe55d9ca35057e08a4509c9ac 100644 --- a/src/header/stdio/helpers.rs +++ b/src/header/stdio/helpers.rs @@ -1,6 +1,4 @@ use alloc::boxed::Box; -use core::sync::atomic::AtomicBool; -use core::{mem, ptr}; use fs::File; use header::errno; diff --git a/src/header/stdio/mod.rs b/src/header/stdio/mod.rs index 0653c1d6e9aa07a1338bc95368971190038c7685..e94884a901ee5095cd172d6e30a295d82a62f68c 100644 --- a/src/header/stdio/mod.rs +++ b/src/header/stdio/mod.rs @@ -3,10 +3,9 @@ use alloc::borrow::{Borrow, BorrowMut}; use alloc::boxed::Box; use alloc::vec::Vec; +use core::fmt; use core::fmt::Write as WriteFmt; -use core::fmt::{self, Error}; use core::ops::{Deref, DerefMut}; -use core::sync::atomic::{self, AtomicBool, Ordering}; use core::{ptr, str, slice}; use va_list::VaList as va_list; @@ -16,7 +15,7 @@ use header::errno::{self, STR_ERROR}; use header::fcntl; use header::stdlib::mkstemp; use header::string::strlen; -use io::{self, BufRead, LineWriter, SeekFrom, Read, Write}; +use io::{self, BufRead, LineWriter, Read, Write}; use mutex::Mutex; use platform::types::*; use platform::{Pal, Sys}; @@ -513,7 +512,7 @@ pub extern "C" fn ftell(stream: *mut FILE) -> c_long { /// Get the current position of the cursor in the file #[no_mangle] pub extern "C" fn ftello(stream: *mut FILE) -> off_t { - let mut stream = unsafe { &mut *stream }.lock(); + let stream = unsafe { &mut *stream }.lock(); let pos = Sys::lseek(*stream.file, 0, SEEK_CUR); if pos < 0 { return -1; diff --git a/src/header/stdio/printf.rs b/src/header/stdio/printf.rs index 00d7153621996a25874760a8fe250c662d24cac8..2664b7f0cfd4592dcd07ea1dfc92455bb36c6080 100644 --- a/src/header/stdio/printf.rs +++ b/src/header/stdio/printf.rs @@ -1,14 +1,12 @@ use alloc::string::String; use alloc::string::ToString; use alloc::vec::Vec; -use core::fmt::Write as CoreWrite; use core::ops::Range; -use core::{fmt, ptr, slice, str}; +use core::{fmt, slice}; -use c_str::CStr; use io::{self, Write}; +use platform; use platform::types::*; -use platform::{self, WriteByte}; use va_list::{VaList, VaPrimitive}; #[derive(PartialEq, Eq)] @@ -221,7 +219,7 @@ fn fmt_float_exp<W: Write>( } let string = float_string(float, precision, trim); - let mut len = string.len() + 2 + 2.max(exp_len); + let len = string.len() + 2 + 2.max(exp_len); pad(w, !left, b' ', len..pad_space)?; let bytes = if string.starts_with('-') { @@ -261,8 +259,8 @@ fn fmt_float_normal<W: Write>( Ok(string.len()) } -unsafe fn inner_printf<W: Write>(w: W, format: *const c_char, mut ap: VaList) -> io::Result<c_int> { - let mut w = &mut platform::CountingWriter::new(w); +unsafe fn inner_printf<W: Write>(w: W, format: *const c_char, ap: VaList) -> io::Result<c_int> { + let w = &mut platform::CountingWriter::new(w); let mut ap = BufferedVaList::new(ap); let mut format = format as *const u8; diff --git a/src/header/string/mod.rs b/src/header/string/mod.rs index 879fb89309d7a85b7e504656339d97073ca73207..9f0ce210f2c25f35a35003c057f31e9b7334c22e 100644 --- a/src/header/string/mod.rs +++ b/src/header/string/mod.rs @@ -366,7 +366,7 @@ pub unsafe extern "C" fn strspn(s1: *const c_char, s2: *const c_char) -> size_t inner_strspn(s1, s2, true) } -unsafe fn inner_strstr(mut haystack: *const c_char, mut needle: *const c_char, mask: c_char) -> *mut c_char { +unsafe fn inner_strstr(mut haystack: *const c_char, needle: *const c_char, mask: c_char) -> *mut c_char { while *haystack != 0 { let mut i = 0; loop { diff --git a/src/header/strings/mod.rs b/src/header/strings/mod.rs index 5443ebc738b322b19913916f6c4742d1ce828a22..562f5d805721a427b0c2b43545ffb4583898bb52 100644 --- a/src/header/strings/mod.rs +++ b/src/header/strings/mod.rs @@ -1,6 +1,5 @@ //! strings implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/strings.h.html -use alloc::vec::Vec; use core::ptr; use platform::types::*; @@ -66,7 +65,7 @@ pub unsafe extern "C" fn rindex(mut s: *const c_char, c: c_int) -> *mut c_char { } #[no_mangle] -pub unsafe extern "C" fn strcasecmp(mut first: *const c_char, mut second: *const c_char) -> c_int { +pub unsafe extern "C" fn strcasecmp(first: *const c_char, second: *const c_char) -> c_int { strncasecmp(first, second, size_t::max_value()) } diff --git a/src/header/sys_ioctl/mod.rs b/src/header/sys_ioctl/mod.rs index fe72041e0e688cdd6feba352a432787811b89270..bf3b8d69a7ef85943000f27e2004b885afe411ca 100644 --- a/src/header/sys_ioctl/mod.rs +++ b/src/header/sys_ioctl/mod.rs @@ -24,7 +24,7 @@ pub struct winsize { #[cfg(target_os = "linux")] pub mod inner { use platform::types::*; - use platform::{Pal, Sys}; + use platform::Sys; #[no_mangle] pub extern "C" fn ioctl(fd: c_int, request: c_ulong, out: *mut c_void) -> c_int { diff --git a/src/header/sys_stat/mod.rs b/src/header/sys_stat/mod.rs index 2c3208e83b00cb6bd4cfa73d09d81e058ede557f..fe0ea6954dbe643f9480c018147491a5e1f20361 100644 --- a/src/header/sys_stat/mod.rs +++ b/src/header/sys_stat/mod.rs @@ -3,7 +3,6 @@ use c_str::CStr; use header::fcntl::{O_NOFOLLOW, O_PATH}; use header::time::timespec; -use platform; use platform::types::*; use platform::{Pal, Sys}; diff --git a/src/header/sys_utsname/mod.rs b/src/header/sys_utsname/mod.rs index 3a6b766d4a0c36e0d8c37c8af64ee6466a69fc14..9e74d6f181fb56d229773d67a1f2e661687a9f36 100644 --- a/src/header/sys_utsname/mod.rs +++ b/src/header/sys_utsname/mod.rs @@ -17,7 +17,7 @@ pub struct utsname { #[cfg(target_os = "linux")] mod inner { use super::*; - use platform::{Pal, Sys}; + use platform::Sys; #[no_mangle] pub unsafe extern "C" fn uname(uts: *mut utsname) -> c_int { diff --git a/src/header/unistd/getopt.rs b/src/header/unistd/getopt.rs index b58186ea2a03eda9714f51f051d68f618c8db439..d19ba5b410bcaf69dcd49f62d7b997d4ac527bfc 100644 --- a/src/header/unistd/getopt.rs +++ b/src/header/unistd/getopt.rs @@ -2,7 +2,7 @@ use core::ptr; -use header::{getopt, stdio, string}; +use header::getopt; use platform::types::*; #[allow(non_upper_case_globals)] diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index 80a6385544f4526ef95d3f35a8ec1c1ec52c7030..ab0373722ee333b7eadcae7efde13524ab600644 100644 --- a/src/header/unistd/mod.rs +++ b/src/header/unistd/mod.rs @@ -3,7 +3,7 @@ use core::{ptr, slice}; use c_str::CStr; -use header::{limits, sys_time}; +use header::limits; use header::time::timespec; use platform; use platform::types::*; diff --git a/src/lib.rs b/src/lib.rs index 189cca34fd6f8400909bb1fddb47e823efed63f9..a9f19ab240204e725fe5731dc4ffa682c697c791 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,6 @@ #![feature(const_fn)] #![feature(const_vec_new)] #![feature(core_intrinsics)] -#![feature(extern_prelude)] #![feature(global_asm)] #![feature(lang_items)] #![feature(linkage)] diff --git a/src/platform/linux/mod.rs b/src/platform/linux/mod.rs index a2df0e66d9775b501bd6efc2f49830ef4a3e1a3d..ba223144d5eb85fef1f9e18c1082a56ea72021a8 100644 --- a/src/platform/linux/mod.rs +++ b/src/platform/linux/mod.rs @@ -1,14 +1,12 @@ -use alloc::vec::Vec; -use core::fmt::Write as _WriteFmt; use core::{mem, ptr}; use core_io::Write; use super::types::*; -use super::{errno, FileWriter, Pal}; +use super::{errno, Pal}; use c_str::CStr; use fs::File; use header::dirent::dirent; -use header::errno::{EINVAL, ENOSYS}; +use header::errno::EINVAL; use header::fcntl; use header::signal::SIGCHLD; use header::sys_ioctl::{winsize, TCGETS, TCSETS, TIOCGWINSZ}; diff --git a/src/platform/pal/mod.rs b/src/platform/pal/mod.rs index caea5473e8ca99187f3bb864ade7325e06d7436b..f2df15baf443b7703d68c39df70bc3874301f86b 100644 --- a/src/platform/pal/mod.rs +++ b/src/platform/pal/mod.rs @@ -1,12 +1,9 @@ use super::types::*; use c_str::CStr; use header::dirent::dirent; -//use header::sys_resource::rusage; use header::sys_select::fd_set; use header::sys_stat::stat; -use header::sys_time::{itimerval, timeval, timezone}; -//use header::sys_times::tms; -use header::sys_utsname::utsname; +use header::sys_time::{timeval, timezone}; use header::termios::termios; use header::time::timespec; diff --git a/src/platform/pal/signal.rs b/src/platform/pal/signal.rs index b6ffa526dafe1fbd72a9b186027319fa9d752855..644012e8bec74472a8af2377538611a790571e23 100644 --- a/src/platform/pal/signal.rs +++ b/src/platform/pal/signal.rs @@ -1,6 +1,6 @@ use super::super::types::*; use super::super::Pal; -use header::signal::{sigaction, sigset_t}; +use header::signal::sigaction; pub trait PalSignal: Pal { fn kill(pid: pid_t, sig: c_int) -> c_int; diff --git a/src/start.rs b/src/start.rs index 0d7d832e0de86e47f6e560f623e8ac119601f33c..7de69a57efaf00ad642127ee7a84bb1ac01e5a37 100644 --- a/src/start.rs +++ b/src/start.rs @@ -4,7 +4,6 @@ use core::ptr; use header::{stdio, stdlib}; use platform; use platform::types::*; -use platform::{Pal, Sys}; #[repr(C)] pub struct Stack {