Jeremy Soller %!s(int64=6) %!d(string=hai) anos
pai
achega
4c4ce80fcd

+ 0 - 2
src/crt0/src/lib.rs

@@ -52,8 +52,6 @@ impl Stack {
 #[inline(never)]
 #[no_mangle]
 pub unsafe extern "C" fn _start_rust(sp: &'static Stack) -> ! {
-    use core::fmt::Write;
-
     extern "C" {
         fn main(argc: isize, argv: *const *const u8) -> c_int;
     }

+ 1 - 1
src/platform/src/allocator/dlmalloc.rs

@@ -16,7 +16,7 @@ unsafe impl<'a> GlobalAlloc for Allocator {
         dlmemalign(layout.align(), layout.size()) as *mut u8
     }
 
-    unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
+    unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
         dlfree(ptr as *mut c_void)
     }
 }

+ 3 - 3
src/stdio/src/default.rs

@@ -16,17 +16,17 @@ unsafe impl Sync for GlobalFile {}
 
 #[no_mangle]
 pub extern "C" fn __stdin() -> *mut FILE {
-    unsafe { default_stdin.get() }
+    default_stdin.get()
 }
 
 #[no_mangle]
 pub extern "C" fn __stdout() -> *mut FILE {
-    unsafe { default_stdout.get() }
+    default_stdout.get()
 }
 
 #[no_mangle]
 pub extern "C" fn __stderr() -> *mut FILE {
-    unsafe { default_stderr.get() }
+    default_stderr.get()
 }
 
 lazy_static! {

+ 2 - 3
src/stdio/src/helpers.rs

@@ -1,7 +1,7 @@
 use super::constants::*;
-use super::{internal, BUFSIZ, FILE, UNGET};
+use super::{BUFSIZ, FILE, UNGET};
 use core::sync::atomic::AtomicBool;
-use core::{mem, ptr};
+use core::mem;
 use errno;
 use fcntl::*;
 use platform;
@@ -38,7 +38,6 @@ pub unsafe fn parse_mode_flags(mode_str: *const c_char) -> i32 {
 
 /// Open a file with the file descriptor `fd` in the mode `mode`
 pub unsafe fn _fdopen(fd: c_int, mode: *const c_char) -> Option<*mut FILE> {
-    use core::mem::size_of;
     use string::strchr;
     if *mode != b'r' as i8 && *mode != b'w' as i8 && *mode != b'a' as i8 {
         platform::errno = errno::EINVAL;

+ 2 - 2
src/stdio/src/lib.rs

@@ -899,7 +899,7 @@ pub unsafe extern "C" fn vfprintf(file: &mut FILE, format: *const c_char, ap: va
 
 #[no_mangle]
 pub unsafe extern "C" fn vprintf(format: *const c_char, ap: va_list) -> c_int {
-    vfprintf(unsafe { &mut *__stdout() }, format, ap)
+    vfprintf(&mut *__stdout(), format, ap)
 }
 
 #[no_mangle]
@@ -928,7 +928,7 @@ pub unsafe extern "C" fn vfscanf(file: &mut FILE, format: *const c_char, ap: va_
 
 #[no_mangle]
 pub unsafe extern "C" fn vscanf(format: *const c_char, ap: va_list) -> c_int {
-    vfscanf(unsafe { &mut *__stdin() }, format, ap)
+    vfscanf(&mut *__stdin(), format, ap)
 }
 
 #[no_mangle]

+ 3 - 4
src/stdlib/src/lib.rs

@@ -369,7 +369,6 @@ pub unsafe extern "C" fn mbtowc(pwc: *mut wchar_t, s: *const c_char, n: size_t)
 pub extern "C" fn mktemp(name: *mut c_char) -> *mut c_char {
     use core::iter;
     use core::mem;
-    use core::slice;
     let len = unsafe { strlen(name) };
     if len < 6 {
         unsafe { platform::errno = errno::EINVAL };
@@ -389,7 +388,7 @@ pub extern "C" fn mktemp(name: *mut c_char) -> *mut c_char {
 
     let mut retries = 100;
     loop {
-        let mut char_iter = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(6);
+        let char_iter = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(6);
         unsafe {
             for (i, c) in char_iter.enumerate() {
                 *name.offset(len as isize - i as isize - 1) = c as c_char
@@ -421,7 +420,7 @@ fn get_nstime() -> u64 {
     use time::constants::CLOCK_MONOTONIC;
     let mut ts: timespec = unsafe { mem::uninitialized() };
     platform::clock_gettime(CLOCK_MONOTONIC, &mut ts);
-    unsafe { ts.tv_nsec as u64 }
+    ts.tv_nsec as u64
 }
 
 // #[no_mangle]
@@ -811,7 +810,7 @@ pub unsafe extern "C" fn system(command: *const c_char) -> c_int {
         unreachable!();
     } else {
         let mut wstatus = 0;
-        if platform::waitpid(child_pid, &mut wstatus, 0) < 0 {
+        if platform::waitpid(child_pid, &mut wstatus, 0) == !0 {
             return -1;
         }
 

+ 0 - 2
src/sys_utsname/src/lib.rs

@@ -7,11 +7,9 @@ mod inner {
     extern crate platform;
 
     use self::platform::types::*;
-    use core::ptr;
 
     const LENGTH: usize = 65;
 
-    #[allow(non_camel_case)]
     #[no_mangle]
     #[repr(C)]
     pub struct utsname {

+ 4 - 4
src/unistd/src/lib.rs

@@ -309,9 +309,9 @@ pub extern "C" fn getuid() -> uid_t {
     platform::getuid()
 }
 
-// #[no_mangle]
+#[no_mangle]
 pub extern "C" fn getwd(path_name: *mut c_char) -> *mut c_char {
-    unimplemented!();
+    getcwd(path_name, 4096 /* PATH_MAX */)
 }
 
 // #[no_mangle]
@@ -334,9 +334,9 @@ pub extern "C" fn lockf(fildes: c_int, function: c_int, size: off_t) -> c_int {
     unimplemented!();
 }
 
-// #[no_mangle]
+#[no_mangle]
 pub extern "C" fn lseek(fildes: c_int, offset: off_t, whence: c_int) -> off_t {
-    unimplemented!();
+    platform::lseek(fildes, offset, whence)
 }
 
 // #[no_mangle]