From 4e4c8c41e90989c1f732995511e0f9a77a33f650 Mon Sep 17 00:00:00 2001 From: LoGin Date: Fri, 22 Mar 2024 23:56:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0clippy=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E7=9A=84=E8=87=AA=E5=8A=A8=E5=8C=96=E5=B7=A5=E4=BD=9C=E6=B5=81?= =?UTF-8?q?=20(#649)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 添加clippy检测的自动化工作流 * fmt * 1 --- kernel/Makefile | 3 ++- kernel/src/filesystem/vfs/syscall.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/kernel/Makefile b/kernel/Makefile index cdb1751f..4b74abfe 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -25,7 +25,8 @@ clean: .PHONY: fmt fmt: - cargo fmt --all $(FMT_CHECK) + @cargo fmt --all $(FMT_CHECK) + @cargo clippy --all-features .PHONY: check check: ECHO diff --git a/kernel/src/filesystem/vfs/syscall.rs b/kernel/src/filesystem/vfs/syscall.rs index 871cd8c8..686e5a34 100644 --- a/kernel/src/filesystem/vfs/syscall.rs +++ b/kernel/src/filesystem/vfs/syscall.rs @@ -762,7 +762,7 @@ impl Syscall { } // TODO AT_EMPTY_PATH标志启用时,进行调用者CAP_DAC_READ_SEARCH或相似的检查 let symlink_times = if flags.contains(AtFlags::AT_SYMLINK_FOLLOW) { - 0 as usize + 0_usize } else { VFS_MAX_FOLLOW_SYMLINK_TIMES }; @@ -795,11 +795,11 @@ impl Syscall { // 得到新创建节点的父节点 let (new_begin_inode, new_remain_path) = user_path_at(&pcb, newfd, new)?; let (new_name, new_parent_path) = rsplit_path(&new_remain_path); - let new_parent = new_begin_inode - .lookup_follow_symlink(&new_parent_path.unwrap_or("/"), symlink_times)?; + let new_parent = + new_begin_inode.lookup_follow_symlink(new_parent_path.unwrap_or("/"), symlink_times)?; // 被调用者利用downcast_ref判断两inode是否为同一文件系统 - return new_parent.link(&new_name, &old_inode).map(|_| 0); + return new_parent.link(new_name, &old_inode).map(|_| 0); } pub fn link(old: *const u8, new: *const u8) -> Result { @@ -816,9 +816,9 @@ impl Syscall { let old = get_path(old)?; let new = get_path(new)?; return Self::do_linkat( - AtFlags::AT_FDCWD.bits() as i32, + AtFlags::AT_FDCWD.bits(), &old, - AtFlags::AT_FDCWD.bits() as i32, + AtFlags::AT_FDCWD.bits(), &new, AtFlags::empty(), );