fix clippy lint errors

This commit is contained in:
Garen Tyler 2023-10-31 17:32:24 -06:00
parent 6e5520f481
commit 4cb940606c
Signed by: garentyler
GPG Key ID: D7A048C454CB7054
3 changed files with 7 additions and 6 deletions

View File

@ -325,7 +325,7 @@ pub unsafe extern "C" fn filewrite(file: *mut File, addr: u64, num_bytes: i32) -
} }
} }
if i == num_bytes { if i == num_bytes {
num_bytes as i32 num_bytes
} else { } else {
-1 -1
} }

View File

@ -33,6 +33,7 @@ pub struct Pipe {
pub is_write_open: i32, pub is_write_open: i32,
} }
impl Pipe { impl Pipe {
#[allow(clippy::new_ret_no_self)]
pub unsafe fn new(a: *mut *mut File, b: *mut *mut File) -> Result<()> { pub unsafe fn new(a: *mut *mut File, b: *mut *mut File) -> Result<()> {
*a = filealloc(); *a = filealloc();
*b = filealloc(); *b = filealloc();
@ -66,6 +67,7 @@ impl Pipe {
/// Unsafely get a reference to `self`. /// Unsafely get a reference to `self`.
/// ///
/// `self.lock` must be held beforehand. /// `self.lock` must be held beforehand.
#[allow(clippy::mut_from_ref)]
unsafe fn as_mut(&self) -> &mut Self { unsafe fn as_mut(&self) -> &mut Self {
&mut *addr_of!(*self).cast_mut() &mut *addr_of!(*self).cast_mut()
} }

View File

@ -2,8 +2,8 @@ use crate::{
arch::riscv::memlayout::QEMU_POWER, arch::riscv::memlayout::QEMU_POWER,
fs::{ fs::{
self, self,
file::{self, File, Inode}, file::{self, File},
log::{self, LogOperation}, log::LogOperation,
stat::KIND_DIR, stat::KIND_DIR,
}, },
mem::virtual_memory::{copyin, copyinstr}, mem::virtual_memory::{copyin, copyinstr},
@ -102,15 +102,14 @@ impl Syscall {
} }
Syscall::Chdir => { Syscall::Chdir => {
let mut path = [0u8; crate::MAXPATH]; let mut path = [0u8; crate::MAXPATH];
let mut inode: *mut Inode = null_mut(); let p = myproc();
let mut p = myproc();
let _operation = LogOperation::new(); let _operation = LogOperation::new();
if argstr(0, addr_of_mut!(path).cast(), path.len() as i32) < 0 { if argstr(0, addr_of_mut!(path).cast(), path.len() as i32) < 0 {
return -1i64 as u64; 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() { if inode.is_null() {
return -1i64 as u64; return -1i64 as u64;
} }