From 644a2d2081182940e6fb1a974af750359e049dba Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jackpot51@gmail.com> Date: Wed, 14 Feb 2024 12:38:02 -0700 Subject: [PATCH] Fix clippy lints --- src/allocator.rs | 5 +---- src/bin/mkfs.rs | 2 +- src/bin/mount.rs | 8 ++++---- src/block.rs | 6 +----- src/dir.rs | 5 +---- src/mount/fuse.rs | 32 ++++++++++++++++---------------- src/tree.rs | 5 +---- 7 files changed, 25 insertions(+), 38 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index 862d9fa..dbe23ef 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -147,10 +147,7 @@ impl AllocEntry { impl Clone for AllocEntry { fn clone(&self) -> Self { - Self { - addr: self.addr, - count: self.count, - } + *self } } diff --git a/src/bin/mkfs.rs b/src/bin/mkfs.rs index 9ac2dfe..b868940 100644 --- a/src/bin/mkfs.rs +++ b/src/bin/mkfs.rs @@ -76,7 +76,7 @@ fn main() { let password = io::stdin() .read_passwd(&mut io::stderr()) .unwrap() - .unwrap_or(String::new()); + .unwrap_or_default(); eprintln!(); diff --git a/src/bin/mount.rs b/src/bin/mount.rs index 707607f..d157c14 100644 --- a/src/bin/mount.rs +++ b/src/bin/mount.rs @@ -142,7 +142,7 @@ fn filesystem_by_path( let password = io::stdin() .read_passwd(&mut io::stderr()) .unwrap() - .unwrap_or(String::new()); + .unwrap_or_default(); eprintln!(); @@ -158,10 +158,10 @@ fn filesystem_by_path( bootloader_password() }; - match DiskFile::open(&path).map(|image| DiskCache::new(image)) { + match DiskFile::open(path).map(DiskCache::new) { Ok(disk) => match redoxfs::FileSystem::open( disk, - password_opt.as_ref().map(|x| x.as_slice()), + password_opt.as_deref(), block_opt, true, ) { @@ -277,7 +277,7 @@ fn daemon(disk_id: &DiskId, mountpoint: &str, block_opt: Option<u64>, mut write: }; if let Some((path, filesystem)) = filesystem_opt { - match mount(filesystem, &mountpoint, |mounted_path| { + match mount(filesystem, mountpoint, |mounted_path| { capability_mode(); println!( diff --git a/src/block.rs b/src/block.rs index 266648a..70dabb9 100644 --- a/src/block.rs +++ b/src/block.rs @@ -139,11 +139,7 @@ impl<T> BlockPtr<T> { impl<T> Clone for BlockPtr<T> { fn clone(&self) -> Self { - Self { - addr: self.addr, - hash: self.hash, - phantom: PhantomData, - } + *self } } diff --git a/src/dir.rs b/src/dir.rs index d6c047b..379e3b3 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -45,10 +45,7 @@ impl DirEntry { impl Clone for DirEntry { fn clone(&self) -> Self { - Self { - node_ptr: self.node_ptr, - name: self.name, - } + *self } } diff --git a/src/mount/fuse.rs b/src/mount/fuse.rs index 8714e3d..ae6e1c0 100644 --- a/src/mount/fuse.rs +++ b/src/mount/fuse.rs @@ -110,7 +110,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { reply.entry(&TTL, &node_attr(&node), 0); } Err(err) => { - reply.error(err.errno as i32); + reply.error(err.errno); } } } @@ -122,7 +122,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { reply.attr(&TTL, &node_attr(&node)); } Err(err) => { - reply.error(err.errno as i32); + reply.error(err.errno); } } } @@ -150,7 +150,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { let mut node = match self.fs.tx(|tx| tx.read_tree(node_ptr)) { Ok(ok) => ok, Err(err) => { - reply.error(err.errno as i32); + reply.error(err.errno); return; } }; @@ -207,7 +207,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { } } Err(err) => { - reply.error(err.errno as i32); + reply.error(err.errno); return; } } @@ -217,7 +217,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { if node_changed { if let Err(err) = self.fs.tx(|tx| tx.sync_tree(node)) { - reply.error(err.errno as i32); + reply.error(err.errno); return; } } @@ -253,7 +253,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { reply.data(&data[..count]); } Err(err) => { - reply.error(err.errno as i32); + reply.error(err.errno); } } } @@ -286,7 +286,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { reply.written(count as u32); } Err(err) => { - reply.error(err.errno as i32); + reply.error(err.errno); } } } @@ -337,7 +337,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { let node = match self.fs.tx(|tx| tx.read_tree(child.node_ptr())) { Ok(ok) => ok, Err(err) => { - reply.error(err.errno as i32); + reply.error(err.errno); return; } }; @@ -362,7 +362,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { reply.ok(); } Err(err) => { - reply.error(err.errno as i32); + reply.error(err.errno); } } } @@ -393,7 +393,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { reply.created(&TTL, &node_attr(&node), 0, 0, flags as u32); } Err(error) => { - reply.error(error.errno as i32); + reply.error(error.errno); } } } @@ -423,7 +423,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { reply.entry(&TTL, &node_attr(&node), 0); } Err(error) => { - reply.error(error.errno as i32); + reply.error(error.errno); } } } @@ -438,7 +438,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { reply.ok(); } Err(err) => { - reply.error(err.errno as i32); + reply.error(err.errno); } } } @@ -453,7 +453,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { reply.ok(); } Err(err) => { - reply.error(err.errno as i32); + reply.error(err.errno); } } } @@ -499,7 +499,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { reply.entry(&TTL, &node_attr(&node), 0); } Err(error) => { - reply.error(error.errno as i32); + reply.error(error.errno); } } } @@ -521,7 +521,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { reply.data(&data[..count]); } Err(err) => { - reply.error(err.errno as i32); + reply.error(err.errno); } } } @@ -547,7 +547,7 @@ impl<'f, D: Disk> Filesystem for Fuse<'f, D> { .tx(|tx| tx.rename_node(orig_parent_ptr, orig_name, new_parent_ptr, new_name)) { Ok(()) => reply.ok(), - Err(err) => reply.error(err.errno as i32), + Err(err) => reply.error(err.errno), } } } diff --git a/src/tree.rs b/src/tree.rs index 4526d37..7e9468f 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -135,10 +135,7 @@ impl<T> TreePtr<T> { impl<T> Clone for TreePtr<T> { fn clone(&self) -> Self { - Self { - id: self.id, - phantom: PhantomData, - } + *self } } -- GitLab