Clippy fixes
This commit is contained in:
@@ -21,7 +21,7 @@ pub unsafe extern "C" fn brk(addr: *mut c_void) -> c_int {
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sbrk(incr: intptr_t) -> *mut c_void {
|
||||
if BRK == ptr::null_mut() {
|
||||
if BRK.is_null() {
|
||||
BRK = Sys::brk(ptr::null_mut());
|
||||
}
|
||||
|
||||
|
||||
+21
-21
@@ -43,8 +43,8 @@ pub extern "C" fn _exit(status: c_int) {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn access(path: *const c_char, mode: c_int) -> c_int {
|
||||
let path = unsafe { CStr::from_ptr(path) };
|
||||
pub unsafe extern "C" fn access(path: *const c_char, mode: c_int) -> c_int {
|
||||
let path = CStr::from_ptr(path);
|
||||
Sys::access(path, mode)
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ pub extern "C" fn alarm(seconds: c_uint) -> c_uint {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn chdir(path: *const c_char) -> c_int {
|
||||
let path = unsafe { CStr::from_ptr(path) };
|
||||
pub unsafe extern "C" fn chdir(path: *const c_char) -> c_int {
|
||||
let path = CStr::from_ptr(path);
|
||||
Sys::chdir(path)
|
||||
}
|
||||
|
||||
@@ -83,8 +83,8 @@ pub extern "C" fn chroot(path: *const c_char) -> c_int {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn chown(path: *const c_char, owner: uid_t, group: gid_t) -> c_int {
|
||||
let path = unsafe { CStr::from_ptr(path) };
|
||||
pub unsafe extern "C" fn chown(path: *const c_char, owner: uid_t, group: gid_t) -> c_int {
|
||||
let path = CStr::from_ptr(path);
|
||||
Sys::chown(path, owner, group)
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ pub extern "C" fn getcwd(mut buf: *mut c_char, mut size: size_t) -> *mut c_char
|
||||
}
|
||||
|
||||
let ret = Sys::getcwd(buf, size);
|
||||
if ret == ptr::null_mut() {
|
||||
if ret.is_null() {
|
||||
return ptr::null_mut();
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ pub extern "C" fn getcwd(mut buf: *mut c_char, mut size: size_t) -> *mut c_char
|
||||
let heap_buf = unsafe { platform::alloc(len) as *mut c_char };
|
||||
for i in 0..len {
|
||||
unsafe {
|
||||
*heap_buf.offset(i as isize) = stack_buf[i];
|
||||
*heap_buf.add(i) = stack_buf[i];
|
||||
}
|
||||
}
|
||||
heap_buf
|
||||
@@ -356,9 +356,9 @@ pub extern "C" fn lchown(path: *const c_char, owner: uid_t, group: gid_t) -> c_i
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn link(path1: *const c_char, path2: *const c_char) -> c_int {
|
||||
let path1 = unsafe { CStr::from_ptr(path1) };
|
||||
let path2 = unsafe { CStr::from_ptr(path2) };
|
||||
pub unsafe extern "C" fn link(path1: *const c_char, path2: *const c_char) -> c_int {
|
||||
let path1 = CStr::from_ptr(path1);
|
||||
let path2 = CStr::from_ptr(path2);
|
||||
Sys::link(path1, path2)
|
||||
}
|
||||
|
||||
@@ -456,15 +456,15 @@ pub extern "C" fn read(fildes: c_int, buf: *const c_void, nbyte: size_t) -> ssiz
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn readlink(path: *const c_char, buf: *mut c_char, bufsize: size_t) -> ssize_t {
|
||||
let path = unsafe { CStr::from_ptr(path) };
|
||||
let buf = unsafe { slice::from_raw_parts_mut(buf as *mut u8, bufsize as usize) };
|
||||
pub unsafe extern "C" fn readlink(path: *const c_char, buf: *mut c_char, bufsize: size_t) -> ssize_t {
|
||||
let path = CStr::from_ptr(path);
|
||||
let buf = slice::from_raw_parts_mut(buf as *mut u8, bufsize as usize);
|
||||
Sys::readlink(path, buf)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn rmdir(path: *const c_char) -> c_int {
|
||||
let path = unsafe { CStr::from_ptr(path) };
|
||||
pub unsafe extern "C" fn rmdir(path: *const c_char) -> c_int {
|
||||
let path = CStr::from_ptr(path);
|
||||
Sys::rmdir(path)
|
||||
}
|
||||
|
||||
@@ -520,9 +520,9 @@ pub extern "C" fn swab(src: *const c_void, dest: *mut c_void, nbytes: ssize_t) {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn symlink(path1: *const c_char, path2: *const c_char) -> c_int {
|
||||
let path1 = unsafe { CStr::from_ptr(path1) };
|
||||
let path2 = unsafe { CStr::from_ptr(path2) };
|
||||
pub unsafe extern "C" fn symlink(path1: *const c_char, path2: *const c_char) -> c_int {
|
||||
let path1 = CStr::from_ptr(path1);
|
||||
let path2 = CStr::from_ptr(path2);
|
||||
Sys::symlink(path1, path2)
|
||||
}
|
||||
|
||||
@@ -587,8 +587,8 @@ pub extern "C" fn ttyname_r(fildes: c_int, name: *mut c_char, namesize: size_t)
|
||||
// }
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn unlink(path: *const c_char) -> c_int {
|
||||
let path = unsafe { CStr::from_ptr(path) };
|
||||
pub unsafe extern "C" fn unlink(path: *const c_char) -> c_int {
|
||||
let path = CStr::from_ptr(path);
|
||||
Sys::unlink(path)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user