Skip to content

Commit

Permalink
sources: fix clippy warnings for 1.78.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sumukhballal committed Jun 13, 2024
1 parent a8658b9 commit ea7cbcf
Show file tree
Hide file tree
Showing 22 changed files with 27 additions and 105 deletions.
21 changes: 0 additions & 21 deletions sources/api/bootstrap-containers/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,27 +640,6 @@ mod error {
source: std::io::Error,
},

#[snafu(display(
"Error deserializing response as JSON from {} to {}: {}",
method,
uri,
source
))]
ResponseJson {
method: &'static str,
uri: String,
source: serde_json::Error,
},

#[snafu(display("Unable to serialize data: {}", source))]
Serialize { source: serde_json::Error },

#[snafu(display("Failed to change settings via apiclient: {}", source))]
Set { source: io::Error },

#[snafu(display("Failed to change settings, apiclient returned an error"))]
SetClient,

#[snafu(display("{}", message))]
Usage { message: String },

Expand Down
6 changes: 0 additions & 6 deletions sources/api/certdog/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,6 @@ mod error {
#[snafu(display("Logger setup error: {}", source))]
Logger { source: log::SetLoggerError },

#[snafu(display("Invalid log level '{}'", log_level))]
LogLevel {
log_level: String,
source: log::ParseLevelError,
},

#[snafu(display("Failed to parse PEM: {}", source))]
ParsePEM {
source: x509_parser::error::PEMError,
Expand Down
1 change: 1 addition & 0 deletions sources/api/corndog/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ mod error {
#[snafu(display("Logger setup error: {}", source))]
Logger { source: log::SetLoggerError },

#[allow(dead_code)]
#[snafu(display(
"Error deserializing response as JSON from {} to '{}': {}",
method,
Expand Down
12 changes: 6 additions & 6 deletions sources/api/datastore/src/serialization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,22 @@ impl ser::Serializer for &MapKeySerializer {
self.serialize_str(variant)
}

fn serialize_newtype_struct<T: ?Sized>(self, _name: &'static str, _value: &T) -> Result<String>
fn serialize_newtype_struct<T>(self, _name: &'static str, _value: &T) -> Result<String>
where
T: Serialize,
T: Serialize + ?Sized,
{
bad_key("newtype_struct")
}

fn serialize_newtype_variant<T: ?Sized>(
fn serialize_newtype_variant<T>(
self,
_name: &'static str,
_variant_index: u32,
_variant: &'static str,
_value: &T,
) -> Result<String>
where
T: Serialize,
T: Serialize + ?Sized,
{
bad_key("newtype_variant")
}
Expand All @@ -155,9 +155,9 @@ impl ser::Serializer for &MapKeySerializer {
bad_key("none")
}

fn serialize_some<T: ?Sized>(self, _value: &T) -> Result<String>
fn serialize_some<T>(self, _value: &T) -> Result<String>
where
T: Serialize,
T: Serialize + ?Sized,
{
bad_key("some")
}
Expand Down
3 changes: 0 additions & 3 deletions sources/api/host-containers/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ mod error {
#[snafu(display("Host containers '{}' missing field '{}'", name, field))]
MissingField { name: String, field: String },

#[snafu(display("Unable to create host-containers config dir {}: {}", path.display(), source))]
EnvFileDirCreate { path: PathBuf, source: io::Error },

#[snafu(display("Failed to build EnvironmentFile for {}: {}", name, source))]
EnvFileBuildFailed { name: String, source: fmt::Error },

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl Migration for ReplaceStringMigration {
match data {
serde_json::Value::String(data) => {
if data == self.old_val {
*data = self.new_val.to_owned();
self.new_val.clone_into(data);
println!(
"Changed value of '{}' from '{}' to '{}' on upgrade",
self.setting, self.old_val, self.new_val
Expand Down Expand Up @@ -233,7 +233,7 @@ impl Migration for ReplaceStringMigration {
match data {
serde_json::Value::String(data) => {
if data == self.new_val {
*data = self.old_val.to_owned();
self.old_val.clone_into(data);
println!(
"Changed value of '{}' from '{}' to '{}' on downgrade",
self.setting, self.new_val, self.old_val
Expand Down Expand Up @@ -1725,7 +1725,7 @@ impl MetadataReplacement {
})
.and_then(|data| {
if data == self.old_val {
*data = self.new_val.to_owned();
self.new_val.clone_into(data);
println!(
"Changed value of metadata '{}' for setting '{}' from '{}' to '{}'.",
self.metadata,
Expand Down
24 changes: 0 additions & 24 deletions sources/api/migration/migrator/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ use std::process::Output;
#[derive(Debug, Snafu)]
#[snafu(visibility(pub(crate)))]
pub(crate) enum Error {
#[snafu(display("Internal error: {}", msg))]
Internal { msg: String },

#[snafu(display("Data store path '{}' contains invalid UTF-8", path.display()))]
DataStorePathNotUTF8 { path: PathBuf },

Expand All @@ -36,12 +33,6 @@ pub(crate) enum Error {
source: semver::Error,
},

#[snafu(display("Migration '{}' contains invalid version: {}", path.display(), source))]
InvalidMigrationVersion {
path: PathBuf,
source: semver::Error,
},

#[snafu(display("Data store for new version {} already exists at {}", version, path.display()))]
NewVersionAlreadyExists { version: Version, path: PathBuf },

Expand All @@ -67,9 +58,6 @@ pub(crate) enum Error {
#[snafu(display("Failed to read symlink at {} to find version: {}", link.display(), source))]
LinkRead { link: PathBuf, source: io::Error },

#[snafu(display("Failed listing migration directory '{}': {}", dir.display(), source))]
ListMigrations { dir: PathBuf, source: io::Error },

#[snafu(display("Invalid target name '{}': {}", target, source))]
TargetName {
target: String,
Expand Down Expand Up @@ -113,23 +101,11 @@ pub(crate) enum Error {
source: std::io::Error,
},

#[snafu(display("Failed reading migration directory entry: {}", source))]
ReadMigrationEntry { source: io::Error },

#[snafu(display("Failed to load TUF repo: {}", source))]
RepoLoad {
#[snafu(source(from(tough::error::Error, Box::new)))]
source: Box<tough::error::Error>,
},

#[snafu(display("Failed reading metadata of '{}': {}", path.display(), source))]
PathMetadata { path: PathBuf, source: io::Error },

#[snafu(display("Failed setting permissions of '{}': {}", path.display(), source))]
SetPermissions { path: PathBuf, source: io::Error },

#[snafu(display("Migration path '{}' contains invalid UTF-8", path.display()))]
MigrationNameNotUTF8 { path: PathBuf },
}

/// Result alias containing our Error type.
Expand Down
6 changes: 0 additions & 6 deletions sources/api/prairiedog/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ pub(super) enum Error {
#[snafu(display("Failed to setup logger: {}", source))]
Logger { source: log::SetLoggerError },

#[snafu(display("Invalid log level '{}'", log_level))]
LogLevel {
log_level: String,
source: log::ParseLevelError,
},

#[snafu(display("Failed to create mount '{}': '{}'", path, source))]
Mount { path: String, source: nix::Error },

Expand Down
6 changes: 0 additions & 6 deletions sources/api/schnauzer/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,6 @@ mod error {
template: String,
},

#[snafu(display(
"Expected ecr helper to be called with either 'registry' or 'region', got '{}'",
value,
))]
EcrParam { value: String },

#[snafu(display(
"Incorrect number of params provided to helper '{}' in template '{}' - {} expected, {} received",
helper,
Expand Down
1 change: 1 addition & 0 deletions sources/api/schnauzer/src/v2/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//!
//! We use `pest` to disambiguate the TOML frontmatter from the body of the template, then serde to
//! extract the contents of the frontmatter.
#![allow(clippy::empty_docs)]
use pest::Parser;
use pest_derive::Parser;
use serde::Deserialize;
Expand Down
1 change: 1 addition & 0 deletions sources/api/shibaken/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::warmpool::error::WarmPoolCheckError;
use snafu::Snafu;

#[allow(dead_code)]
#[derive(Debug, Snafu)]
#[snafu(visibility(pub(super)))]
pub(crate) enum Error {
Expand Down
1 change: 1 addition & 0 deletions sources/api/shibaken/src/warmpool/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::path::PathBuf;

pub type Result<T> = std::result::Result<T, WarmPoolCheckError>;

#[allow(dead_code)]
#[derive(Debug, Snafu)]
#[snafu(visibility(pub(super)))]
pub enum WarmPoolCheckError {
Expand Down
6 changes: 0 additions & 6 deletions sources/api/sundog/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,6 @@ mod error {
#[snafu(display("Error interpreting JSON value as API model: {}", source))]
InterpretModel { source: serde_json::Error },

#[snafu(display("Can't deserialize {} from command output '{}'", expected, input,))]
CommandJsonType {
expected: &'static str,
input: serde_json::Value,
},

#[snafu(display("Error deserializing HashMap to Settings: {}", source))]
Deserialize { source: deserialization::Error },

Expand Down
8 changes: 0 additions & 8 deletions sources/api/thar-be-settings/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,12 @@ use thar_be_settings::{config, get_changed_settings, service};

mod error {
use snafu::Snafu;
use std::path::PathBuf;

#[derive(Debug, Snafu)]
#[snafu(visibility(pub(super)))]
pub(super) enum Error {
#[snafu(display("Logger setup error: {}", source))]
Logger { source: log::SetLoggerError },

#[snafu(display("Failure to read template '{}' from '{}': {}", name, path.display(), source))]
TemplateRegister {
name: String,
path: PathBuf,
source: handlebars::TemplateError,
},
}
}

Expand Down
6 changes: 0 additions & 6 deletions sources/driverdog/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,6 @@ mod error {
#[snafu(display("Failed to setup logger: {}", source))]
Logger { source: log::SetLoggerError },

#[snafu(display("Invalid log level '{}'", log_level))]
LogLevel {
log_level: String,
source: log::ParseLevelError,
},

#[snafu(display("Missing module set '{}'", target))]
MissingModuleSet { target: String },

Expand Down
1 change: 1 addition & 0 deletions sources/early-boot-config/early-boot-config/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ mod error {
use snafu::Snafu;
use std::path::PathBuf;

#[allow(dead_code)]
#[derive(Debug, Snafu)]
#[snafu(visibility(pub(super)))]
pub(super) enum Error {
Expand Down
9 changes: 5 additions & 4 deletions sources/logdog/src/log_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use glob::glob;
use reqwest::blocking::{Client, Response};
use snafu::{ensure, OptionExt, ResultExt};
use std::collections::HashSet;
use std::fmt::{Display, Formatter};
use std::fs;
use std::fs::File;
use std::path::Path;
Expand Down Expand Up @@ -109,12 +110,12 @@ struct LogRequest<'a> {
}

/// This is used in error construction.
impl ToString for LogRequest<'_> {
fn to_string(&self) -> String {
impl Display for LogRequest<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
if self.instructions.is_empty() {
format!("{} {}", self.mode, self.filename)
write!(f, "{} {}", self.mode, self.filename)
} else {
format!("{} {} {}", self.mode, self.filename, self.instructions)
write!(f, "{} {} {}", self.mode, self.filename, self.instructions)
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions sources/netdog/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ mod error {
#[snafu(display("Unable to gather DNS settings: {}", source))]
GetDnsSettings { source: dns::Error },

#[allow(dead_code)]
#[snafu(display("Failed to read/parse DNS settings from DHCP lease: {}", source))]
DnsFromLease { source: dns::Error },

Expand Down Expand Up @@ -299,6 +300,7 @@ mod error {
#[snafu(display("Failed to write network interface configuration: {}", source))]
InterfaceConfigWrite { source: wicked::Error },

#[allow(dead_code)]
#[snafu(display("Unable to determine interface name: {}", source))]
InterfaceName { source: interface_id::Error },

Expand All @@ -321,6 +323,7 @@ mod error {
#[snafu(display("Failed to read/parse lease data: {}", source))]
LeaseParseFailed { source: lease::Error },

#[allow(dead_code)]
#[snafu(display("No DHCP lease found for interface '{}'", interface))]
MissingLease { interface: String },

Expand Down Expand Up @@ -350,9 +353,11 @@ mod error {
#[snafu(display("Failed to write primary interface to '{}': {}", path.display(), source))]
PrimaryInterfaceWrite { path: PathBuf, source: io::Error },

#[allow(dead_code)]
#[snafu(display("Failed to read primary interface from '{}': {}", path.display(), source))]
PrimaryInterfaceRead { path: PathBuf, source: io::Error },

#[allow(dead_code)]
#[snafu(display("Conflicting primary lease location; from wicked: '{}', generated by netdog: '{}'", wicked_path.display(), generated_path.display()))]
PrimaryLeaseConflict {
wicked_path: PathBuf,
Expand Down
1 change: 1 addition & 0 deletions sources/netdog/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ mod error {
source: toml::de::Error,
},

#[allow(dead_code)]
#[snafu(display("Failed to build resolver configuration: {}", source))]
ResolvConfBuildFailed { source: std::fmt::Error },

Expand Down
1 change: 1 addition & 0 deletions sources/netdog/src/networkd_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ mod error {
#[snafu(display("No IP Address for Primary Interface: {:?}", interface))]
NoIpAddress { interface: InterfaceId },

#[allow(dead_code)]
#[snafu(display("Failed to parse 'networkctl' output: {}", source))]
NetworkctlParsing { source: FromUtf8Error },

Expand Down
6 changes: 0 additions & 6 deletions sources/shimpei/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ mod error {
#[snafu(display("Failed to setup logger: {}", source))]
Logger { source: log::SetLoggerError },

#[snafu(display("Invalid log level '{}'", log_level))]
LogLevel {
log_level: String,
source: log::ParseLevelError,
},

#[snafu(display("Couldn't create CString from '{}': {}", input, source))]
InvalidString {
input: String,
Expand Down
1 change: 1 addition & 0 deletions sources/updater/updog/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use update_metadata::error::Error as update_metadata_error;

pub(crate) type Result<T> = std::result::Result<T, Error>;

#[allow(dead_code)]
#[derive(Debug, Snafu)]
#[snafu(visibility(pub(crate)))]
pub(crate) enum Error {
Expand Down

0 comments on commit ea7cbcf

Please sign in to comment.