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 {
num_bytes as i32
num_bytes
} else {
-1
}

View File

@ -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()
}

View File

@ -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;
}