From e10b4b3bcab6db7cfa69845d9e551cb31784da52 Mon Sep 17 00:00:00 2001 From: lucasliang Date: Tue, 16 Apr 2024 21:49:34 +0800 Subject: [PATCH] Fix clippy errors. Signed-off-by: lucasliang --- src/env/log_fd/unix.rs | 4 ++-- src/file_pipe_log/pipe.rs | 2 +- src/swappy_allocator.rs | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/env/log_fd/unix.rs b/src/env/log_fd/unix.rs index 608cca70..e9b75542 100644 --- a/src/env/log_fd/unix.rs +++ b/src/env/log_fd/unix.rs @@ -83,7 +83,7 @@ impl LogFd { while readed < buf.len() { let bytes = match pread(self.0, &mut buf[readed..], offset as i64) { Ok(bytes) => bytes, - Err(e) if e == Errno::EINTR => continue, + Err(Errno::EINTR) => continue, Err(e) => return Err(from_nix_error(e, "pread")), }; // EOF @@ -106,7 +106,7 @@ impl LogFd { while written < content.len() { let bytes = match pwrite(self.0, &content[written..], offset as i64) { Ok(bytes) => bytes, - Err(e) if e == Errno::EINTR => continue, + Err(Errno::EINTR) => continue, Err(e) if e == Errno::ENOSPC => return Err(from_nix_error(e, "nospace")), Err(e) => return Err(from_nix_error(e, "pwrite")), }; diff --git a/src/file_pipe_log/pipe.rs b/src/file_pipe_log/pipe.rs index 43b3483a..27ea8267 100644 --- a/src/file_pipe_log/pipe.rs +++ b/src/file_pipe_log/pipe.rs @@ -713,7 +713,7 @@ mod tests { // Retire files. assert_eq!(pipe_log.purge_to(last).unwrap() as u64, last - first); // Try to read recycled file. - for (_, handle) in handles.into_iter().enumerate() { + for handle in handles.into_iter() { assert!(pipe_log.read_bytes(handle).is_err()); } // Try to reuse. diff --git a/src/swappy_allocator.rs b/src/swappy_allocator.rs index 8baa4835..0cb8db9b 100644 --- a/src/swappy_allocator.rs +++ b/src/swappy_allocator.rs @@ -288,6 +288,7 @@ impl Page { .read(true) .write(true) .create(true) + .truncate(true) .open(path) .map_err(|e| error!("Failed to open swap file: {e}")) .ok()?;