diff --git a/kernel/rustkernel/src/fs/file.rs b/kernel/rustkernel/src/fs/file.rs index 2db3215..dbdf4e0 100644 --- a/kernel/rustkernel/src/fs/file.rs +++ b/kernel/rustkernel/src/fs/file.rs @@ -325,7 +325,7 @@ pub unsafe extern "C" fn filewrite(file: *mut File, addr: u64, num_bytes: i32) - } } if i == num_bytes { - num_bytes as i32 + num_bytes } else { -1 } diff --git a/kernel/rustkernel/src/io/pipe.rs b/kernel/rustkernel/src/io/pipe.rs index 0dda3c3..9d0405d 100644 --- a/kernel/rustkernel/src/io/pipe.rs +++ b/kernel/rustkernel/src/io/pipe.rs @@ -33,6 +33,7 @@ pub struct Pipe { pub is_write_open: i32, } impl Pipe { + #[allow(clippy::new_ret_no_self)] pub unsafe fn new(a: *mut *mut File, b: *mut *mut File) -> Result<()> { *a = filealloc(); *b = filealloc(); @@ -66,6 +67,7 @@ impl Pipe { /// Unsafely get a reference to `self`. /// /// `self.lock` must be held beforehand. + #[allow(clippy::mut_from_ref)] unsafe fn as_mut(&self) -> &mut Self { &mut *addr_of!(*self).cast_mut() } diff --git a/kernel/rustkernel/src/syscall.rs b/kernel/rustkernel/src/syscall.rs index dc279da..5827187 100644 --- a/kernel/rustkernel/src/syscall.rs +++ b/kernel/rustkernel/src/syscall.rs @@ -2,8 +2,8 @@ use crate::{ arch::riscv::memlayout::QEMU_POWER, fs::{ self, - file::{self, File, Inode}, - log::{self, LogOperation}, + file::{self, File}, + log::LogOperation, stat::KIND_DIR, }, mem::virtual_memory::{copyin, copyinstr}, @@ -102,15 +102,14 @@ impl Syscall { } Syscall::Chdir => { let mut path = [0u8; crate::MAXPATH]; - let mut inode: *mut Inode = null_mut(); - let mut p = myproc(); + let p = myproc(); let _operation = LogOperation::new(); if argstr(0, addr_of_mut!(path).cast(), path.len() as i32) < 0 { return -1i64 as u64; } - inode = fs::namei(addr_of_mut!(path).cast()); + let inode = fs::namei(addr_of_mut!(path).cast()); if inode.is_null() { return -1i64 as u64; }