diff options
author | David Tolnay <dtolnay@chromium.org> | 2018-12-01 17:49:30 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-12-03 20:32:03 -0800 |
commit | 5bbbf610828e975fd308b90543359a85ef59b67f (patch) | |
tree | 4cd736628475d702b7ac45feb2e359c3fb74d220 /io_jail | |
parent | 21fb34fb937678d85e9bfa4c721ab4a29196c764 (diff) | |
download | crosvm-5bbbf610828e975fd308b90543359a85ef59b67f.tar crosvm-5bbbf610828e975fd308b90543359a85ef59b67f.tar.gz crosvm-5bbbf610828e975fd308b90543359a85ef59b67f.tar.bz2 crosvm-5bbbf610828e975fd308b90543359a85ef59b67f.tar.lz crosvm-5bbbf610828e975fd308b90543359a85ef59b67f.tar.xz crosvm-5bbbf610828e975fd308b90543359a85ef59b67f.tar.zst crosvm-5bbbf610828e975fd308b90543359a85ef59b67f.zip |
lint: Resolve the easier clippy lints
Hopefully the changes are self-explanatory and uncontroversial. This eliminates much of the noise from `cargo clippy` and, for my purposes, gives me a reasonable way to use it as a tool when writing and reviewing code. Here is the Clippy invocation I was using: cargo +nightly clippy -- -W clippy::correctness -A renamed_and_removed_lints -Aclippy::{blacklisted_name,borrowed_box,cast_lossless,cast_ptr_alignment,enum_variant_names,identity_op,if_same_then_else,mut_from_ref,needless_pass_by_value,new_without_default,new_without_default_derive,or_fun_call,ptr_arg,should_implement_trait,single_match,too_many_arguments,trivially_copy_pass_by_ref,unreadable_literal,unsafe_vector_initialization,useless_transmute} TEST=cargo check --features wl-dmabuf,gpu,usb-emulation TEST=boot linux Change-Id: I55eb1b4a72beb2f762480e3333a921909314a0a2 Reviewed-on: https://chromium-review.googlesource.com/1356911 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'io_jail')
-rw-r--r-- | io_jail/src/lib.rs | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/io_jail/src/lib.rs b/io_jail/src/lib.rs index 773a3e9..c50916e 100644 --- a/io_jail/src/lib.rs +++ b/io_jail/src/lib.rs @@ -73,74 +73,62 @@ pub enum Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - &Error::BindMount { - ref src, - ref dst, - errno, - } => write!( + Error::BindMount { src, dst, errno } => write!( f, "failed to accept bind mount {:?} -> {:?}: {}", src, dst, errno ), - &Error::Mount { + Error::Mount { errno, - ref src, - ref dest, - ref fstype, + src, + dest, + fstype, flags, - ref data, + data, } => write!( f, "failed to accept mount {:?} -> {:?} of type {:?} with flags 0x{:x} \ and data {:?}: {}", src, dest, fstype, flags, data, errno ), - &Error::CheckingMultiThreaded(ref e) => write!( + Error::CheckingMultiThreaded(e) => write!( f, "Failed to count the number of threads from /proc/self/tasks {}", e ), - &Error::CreatingMinijail => { - write!(f, "minjail_new failed due to an allocation failure") - } - &Error::ForkingMinijail(ref e) => write!(f, "minijail_fork failed with error {}", e), - &Error::ForkingWhileMultiThreaded => { + Error::CreatingMinijail => write!(f, "minjail_new failed due to an allocation failure"), + Error::ForkingMinijail(e) => write!(f, "minijail_fork failed with error {}", e), + Error::ForkingWhileMultiThreaded => { write!(f, "Attempt to call fork() while multithreaded") } - &Error::SeccompPath(ref p) => write!(f, "missing seccomp policy path: {:?}", p), - &Error::StrToCString(ref s) => { - write!(f, "failed to convert string into CString: {:?}", s) - } - &Error::PathToCString(ref s) => { - write!(f, "failed to convert path into CString: {:?}", s) - } - &Error::DupDevNull(errno) => write!( + Error::SeccompPath(p) => write!(f, "missing seccomp policy path: {:?}", p), + Error::StrToCString(s) => write!(f, "failed to convert string into CString: {:?}", s), + Error::PathToCString(s) => write!(f, "failed to convert path into CString: {:?}", s), + Error::DupDevNull(errno) => write!( f, "failed to call dup2 to set stdin, stdout, or stderr to /dev/null: {}", errno ), - &Error::OpenDevNull(ref e) => write!( + Error::OpenDevNull(e) => write!( f, "fail to open /dev/null for setting FDs 0, 1, or 2: {}", e ), - &Error::SetAltSyscallTable { ref name, errno } => { + Error::SetAltSyscallTable { name, errno } => { write!(f, "failed to set alt-syscall table {:?}: {}", name, errno) } - &Error::SettingChrootDirectory(errno, ref p) => { + Error::SettingChrootDirectory(errno, p) => { write!(f, "failed to set chroot {:?}: {}", p, errno) } - &Error::SettingPivotRootDirectory(errno, ref p) => { + Error::SettingPivotRootDirectory(errno, p) => { write!(f, "failed to set pivot root {:?}: {}", p, errno) } - &Error::ReadFdDirEntry(ref e) => { + Error::ReadFdDirEntry(e) => { write!(f, "failed to read an entry in /proc/self/fd: {}", e) } - &Error::ReadFdDir(ref e) => write!(f, "failed to open /proc/self/fd: {}", e), - &Error::ProcFd(ref s) => { - write!(f, "an entry in /proc/self/fd is not an integer: {}", s) - } - &Error::PreservingFd(ref e) => { + Error::ReadFdDir(e) => write!(f, "failed to open /proc/self/fd: {}", e), + Error::ProcFd(s) => write!(f, "an entry in /proc/self/fd is not an integer: {}", s), + Error::PreservingFd(e) => { write!(f, "fork failed in minijail_preserve_fd with error {}", e) } } |