Skip to content

Commit

Permalink
chore(vfs) Remove Clippy warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan committed Aug 30, 2021
1 parent d0a95ac commit bb47a47
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/vfs/src/host_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ impl VirtualFile for File {

#[cfg(unix)]
fn host_file_bytes_available(host_fd: FileDescriptor) -> Result<usize> {
let mut bytes_found = 0 as libc::c_int;
let mut bytes_found: libc::c_int = 0;
let result = unsafe { libc::ioctl(host_fd.try_into()?, libc::FIONREAD, &mut bytes_found) };

match result {
Expand Down
7 changes: 7 additions & 0 deletions lib/vfs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ impl DirEntry {
}
}

#[allow(clippy::len_without_is_empty)] // Clippy thinks it's an iterator.
#[derive(Clone, Debug, Default)]
// TODO: review this, proper solution would probably use a trait object internally
pub struct Metadata {
Expand All @@ -369,21 +370,27 @@ impl Metadata {
pub fn is_file(&self) -> bool {
self.ft.is_file()
}

pub fn is_dir(&self) -> bool {
self.ft.is_dir()
}

pub fn accessed(&self) -> u64 {
self.accessed
}

pub fn created(&self) -> u64 {
self.created
}

pub fn modified(&self) -> u64 {
self.modified
}

pub fn file_type(&self) -> FileType {
self.ft.clone()
}

pub fn len(&self) -> u64 {
self.len
}
Expand Down
2 changes: 1 addition & 1 deletion lib/vfs/src/mem_fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl VirtualFile for FileHandle {

match fs.storage.get(self.inode) {
Some(Node::File { file, .. }) => file.buffer.len().try_into().unwrap_or(0),
_ => return 0,
_ => 0,
}
}

Expand Down
11 changes: 5 additions & 6 deletions lib/vfs/src/mem_fs/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ impl FileSystemInner {

_ => None,
})
.or_else(|| Some(None))
.or(Some(None))
.ok_or(FsError::InvalidInput),

_ => Err(FsError::BaseNotDirectory),
Expand Down Expand Up @@ -519,12 +519,11 @@ impl FileSystemInner {

impl fmt::Debug for FileSystemInner {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
writeln!(
formatter,
"\n{inode:<8} {ty:<4} {name}\n",
"\n{inode:<8} {ty:<4} name",
inode = "inode",
ty = "type",
name = "name",
)?;

fn debug(
Expand All @@ -534,9 +533,9 @@ impl fmt::Debug for FileSystemInner {
indentation: usize,
) -> fmt::Result {
for node in nodes {
write!(
writeln!(
formatter,
"{inode:<8} {ty:<4} {indentation_symbol:indentation_width$}{name}\n",
"{inode:<8} {ty:<4} {indentation_symbol:indentation_width$}{name}",
inode = node.inode(),
ty = match node {
Node::File { .. } => "file",
Expand Down

0 comments on commit bb47a47

Please sign in to comment.