From 21eb5d5618ac3989c6d0dfdd5bd08f093f4b3b7f Mon Sep 17 00:00:00 2001 From: Erdem Meydanli Date: Tue, 19 Mar 2024 02:27:35 +0000 Subject: [PATCH] clippy: eliminate warnings & errors Signed-off-by: Erdem Meydanli --- src/common/mod.rs | 9 ++------- src/enclave_proc/connection.rs | 1 - src/enclave_proc/resource_manager.rs | 10 ++-------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/common/mod.rs b/src/common/mod.rs index fafc37d2..e50099ac 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -56,8 +56,9 @@ const SOCKETS_DIR_PATH: &str = "/run/nitro_enclaves"; const BACKTRACE_VAR: &str = "BACKTRACE"; /// All possible errors which may occur. -#[derive(Debug, Clone, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Clone, Copy, Hash, PartialEq)] pub enum NitroCliErrorEnum { + #[default] /// Unspecified error (should avoid using it thoughout the code). UnspecifiedError = 0, /// Error for handling missing arguments. @@ -180,12 +181,6 @@ pub enum NitroCliErrorEnum { EIFSignatureCheckerError, } -impl Default for NitroCliErrorEnum { - fn default() -> NitroCliErrorEnum { - NitroCliErrorEnum::UnspecifiedError - } -} - impl Eq for NitroCliErrorEnum {} /// The type of commands that can be sent to an enclave process. diff --git a/src/enclave_proc/connection.rs b/src/enclave_proc/connection.rs index 47fa2ca8..458ae1b7 100644 --- a/src/enclave_proc/connection.rs +++ b/src/enclave_proc/connection.rs @@ -12,7 +12,6 @@ use std::collections::HashMap; use std::io::Write; use std::os::unix::io::AsRawFd; use std::os::unix::net::UnixStream; -use std::string::ToString; use std::sync::{Arc, Mutex}; use crate::common::{receive_from_stream, write_u64_le}; diff --git a/src/enclave_proc/resource_manager.rs b/src/enclave_proc/resource_manager.rs index 600061ce..294c88f2 100644 --- a/src/enclave_proc/resource_manager.rs +++ b/src/enclave_proc/resource_manager.rs @@ -11,7 +11,6 @@ use eif_loader::{enclave_ready, TIMEOUT_MINUTE_MS}; use libc::c_int; use log::{debug, info}; use std::collections::BTreeMap; -use std::convert::{From, Into}; use std::fs::{File, OpenOptions}; use std::io::prelude::*; use std::io::Error; @@ -109,8 +108,9 @@ pub struct MemoryRegion { } /// The state an enclave may be in. -#[derive(Clone)] +#[derive(Clone, Default)] pub enum EnclaveState { + #[default] /// The enclave is not running (it's either not started or has been terminated). Empty, /// The enclave is running. @@ -180,12 +180,6 @@ impl ToString for EnclaveState { } } -impl Default for EnclaveState { - fn default() -> Self { - EnclaveState::Empty - } -} - impl Default for EnclaveBuildInfo { fn default() -> Self { EnclaveBuildInfo::new(BTreeMap::new())