소스 검색

Clippy fixes

Mateusz Mikuła 5 년 전
부모
커밋
6742e41948
5개의 변경된 파일10개의 추가작업 그리고 14개의 파일을 삭제
  1. 1 2
      src/header/poll/mod.rs
  2. 4 5
      src/header/sys_select/mod.rs
  3. 1 3
      src/header/time/mod.rs
  4. 3 4
      src/ld_so/linker.rs
  5. 1 0
      src/platform/rlb.rs

+ 1 - 2
src/header/poll/mod.rs

@@ -70,8 +70,7 @@ pub fn poll_epoll(fds: &mut [pollfd], timeout: c_int) -> c_int {
         return -1;
     }
 
-    for i in 0..res as usize {
-        let event = &events[i];
+    for event in events.iter().take(res as usize) {
         let pi = unsafe { event.data.u64 as usize };
         // TODO: Error status when fd does not match?
         if let Some(pfd) = fds.get_mut(pi) {

+ 4 - 5
src/header/sys_select/mod.rs

@@ -42,9 +42,9 @@ pub fn select_epoll(
         File::new(epfd)
     };
 
-    let mut read_bitset : Option<&mut bitset> = readfds.map(|fd_set| &mut fd_set.fds_bits);
-    let mut write_bitset : Option<&mut bitset> = writefds.map(|fd_set| &mut fd_set.fds_bits);
-    let mut except_bitset : Option<&mut bitset> = exceptfds.map(|fd_set| &mut fd_set.fds_bits);
+    let mut read_bitset: Option<&mut bitset> = readfds.map(|fd_set| &mut fd_set.fds_bits);
+    let mut write_bitset: Option<&mut bitset> = writefds.map(|fd_set| &mut fd_set.fds_bits);
+    let mut except_bitset: Option<&mut bitset> = exceptfds.map(|fd_set| &mut fd_set.fds_bits);
 
     // Keep track of the number of file descriptors that do not support epoll
     let mut not_epoll = 0;
@@ -129,8 +129,7 @@ pub fn select_epoll(
     }
 
     let mut count = not_epoll;
-    for i in 0..res as usize {
-        let event = &events[i];
+    for event in events.iter().take(res as usize) {
         let fd = unsafe { event.data.fd };
         // TODO: Error status when fd does not match?
         if fd >= 0 && fd < FD_SETSIZE as c_int {

+ 1 - 3
src/header/time/mod.rs

@@ -1,7 +1,5 @@
 //! time implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/time.h.html
 
-use core::mem::transmute;
-
 use header::errno::EIO;
 use platform;
 use platform::types::*;
@@ -74,7 +72,7 @@ pub struct sigevent;
 
 #[no_mangle]
 pub unsafe extern "C" fn asctime(timeptr: *const tm) -> *mut c_char {
-    asctime_r(timeptr, transmute::<&mut _, *mut c_char>(&mut ASCTIME))
+    asctime_r(timeptr, &mut ASCTIME as *mut [i8; 26] as *mut i8)
 }
 
 #[no_mangle]

+ 3 - 4
src/ld_so/linker.rs

@@ -480,12 +480,11 @@ impl Linker {
                     }
                 };
 
-                match rel.r_type {
-                    reloc::R_X86_64_IRELATIVE => unsafe {
+                if rel.r_type == reloc::R_X86_64_IRELATIVE {
+                    unsafe {
                         let f: unsafe extern "C" fn() -> u64 = mem::transmute(b + a);
                         set_u64(f());
-                    },
-                    _ => (),
+                    }
                 }
             }
 

+ 1 - 0
src/platform/rlb.rs

@@ -32,6 +32,7 @@ impl RawLineBuffer {
 
     // Can't use iterators because we want to return a reference.
     // See https://stackoverflow.com/a/30422716/5069285
+    #[allow(clippy::should_implement_trait)]
     pub fn next(&mut self) -> Line {
         // Remove last line
         if let Some(newline) = self.newline {