From c63a15b19eeb8df882d10014a097474b01179a53 Mon Sep 17 00:00:00 2001 From: Eason <30045503+Eason0729@users.noreply.github.com> Date: Mon, 29 Apr 2024 22:27:14 +0800 Subject: [PATCH] cargo clippy --- judger/src/filesystem/tar/block.rs | 9 ++++----- judger/src/filesystem/tar/map.rs | 10 +++++----- judger/src/sandbox/mod.rs | 3 +-- judger/src/sandbox/monitor/mod.rs | 16 ++++++++-------- judger/src/sandbox/monitor/wrapper.rs | 2 +- judger/src/sandbox/process/mod.rs | 2 -- 6 files changed, 19 insertions(+), 23 deletions(-) diff --git a/judger/src/filesystem/tar/block.rs b/judger/src/filesystem/tar/block.rs index 1062e86..700009f 100644 --- a/judger/src/filesystem/tar/block.rs +++ b/judger/src/filesystem/tar/block.rs @@ -1,5 +1,4 @@ use std::{ - future::IntoFuture, io::SeekFrom, ops::DerefMut, pin::{pin, Pin}, @@ -14,7 +13,7 @@ use tokio::{ sync::{Mutex, OwnedMutexGuard}, }; -#[derive(Default,Debug)] +#[derive(Default, Debug)] enum Stage { Reading(OwnedMutexGuard), Seeking(OwnedMutexGuard), @@ -59,9 +58,9 @@ where fn clone(&self) -> Self { Self { file: self.file.clone(), - start: self.start.clone(), - size: self.size.clone(), - cursor: self.cursor.clone(), + start: self.start, + size: self.size, + cursor: self.cursor, stage: Stage::Done, } } diff --git a/judger/src/filesystem/tar/map.rs b/judger/src/filesystem/tar/map.rs index 26d1905..300f671 100644 --- a/judger/src/filesystem/tar/map.rs +++ b/judger/src/filesystem/tar/map.rs @@ -6,17 +6,17 @@ use std::{ sync::Arc, }; +#[cfg(test)] +use std::io::Cursor; use tar::*; +#[cfg(test)] +use tokio::io::BufReader; use tokio::{ fs::File, io::{AsyncRead, AsyncSeek}, sync::Mutex, task::spawn_blocking, }; -#[cfg(test)] -use std::io::Cursor; -#[cfg(test)] -use tokio::io::BufReader; use super::{block::TarBlock, entry::Entry}; @@ -106,9 +106,9 @@ where #[cfg(test)] mod test { + use super::*; use std::ffi::OsStr; use tokio::io::AsyncReadExt; - use super::*; macro_rules! assert_content { ($entry:expr, $content:expr) => { diff --git a/judger/src/sandbox/mod.rs b/judger/src/sandbox/mod.rs index 4253ada..1f3a463 100644 --- a/judger/src/sandbox/mod.rs +++ b/judger/src/sandbox/mod.rs @@ -4,8 +4,7 @@ mod process; use std::{ffi::OsStr, path::Path, time::Duration}; -pub use self::monitor::{Cpu, Memory, Stat}; -pub use process::*; +pub use self::monitor::{Cpu, Memory}; pub trait Context: Limit { type FS: Filesystem; diff --git a/judger/src/sandbox/monitor/mod.rs b/judger/src/sandbox/monitor/mod.rs index 0b50862..4f29b80 100644 --- a/judger/src/sandbox/monitor/mod.rs +++ b/judger/src/sandbox/monitor/mod.rs @@ -1,18 +1,18 @@ //! Provide ability to limit resource such as memory limit, cpu limit, walltime limit and output limit -pub(self) mod hier; -pub(self) mod mem_cpu; -pub(self) mod output; -pub(self) mod stat; -pub(self) mod walltime; -pub(self) mod wrapper; + mod hier; + mod mem_cpu; + mod output; + mod stat; + mod walltime; + mod wrapper; use std::{fmt::Display, sync::atomic::AtomicUsize, time::Duration}; pub use stat::*; use tokio::io::AsyncRead; -pub(self) use crate::Error; -pub(self) type Result = std::result::Result; + use crate::Error; + type Result = std::result::Result; use hier::*; use self::output::Output; diff --git a/judger/src/sandbox/monitor/wrapper.rs b/judger/src/sandbox/monitor/wrapper.rs index 6468954..b182aaf 100644 --- a/judger/src/sandbox/monitor/wrapper.rs +++ b/judger/src/sandbox/monitor/wrapper.rs @@ -36,7 +36,7 @@ impl<'a> CgroupWrapper<'a> { let controller = self.cgroup.controller_of::().unwrap(); let kusage = controller.kmem_stat(); - let kernel = kusage.max_usage_in_bytes as u64; + let kernel = kusage.max_usage_in_bytes; let user = controller.memory_stat().max_usage_in_bytes; let total = kernel + user; diff --git a/judger/src/sandbox/process/mod.rs b/judger/src/sandbox/process/mod.rs index bbbd4f1..47c8152 100644 --- a/judger/src/sandbox/process/mod.rs +++ b/judger/src/sandbox/process/mod.rs @@ -4,5 +4,3 @@ mod process; use super::*; -pub use corpse::Corpse; -pub use process::Process;