Skip to content

Commit

Permalink
apple-codesign: fix some clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
indygreg committed Nov 12, 2023
1 parent 12e7c43 commit 135d28e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 5 additions & 5 deletions apple-codesign/src/cli/certificate_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ pub struct SigningCertificates {

impl SigningCertificates {
pub fn extend(&mut self, other: Self) {
self.keys.extend(other.keys.into_iter());
self.certs.extend(other.certs.into_iter());
self.keys.extend(other.keys);
self.certs.extend(other.certs);
}

pub fn is_empty(&self) -> bool {
Expand All @@ -52,18 +52,18 @@ impl SigningCertificates {
/// Resolve a private key in this collection.
///
/// Errors unless the number of keys is exactly one.
pub fn private_key(&self) -> Result<&Box<dyn PrivateKey>, AppleCodesignError> {
pub fn private_key(&self) -> Result<&dyn PrivateKey, AppleCodesignError> {
self.private_key_optional()?
.ok_or_else(|| AppleCodesignError::CliGeneralError("no private key found".into()))
}

/// Resolve an optional private key in this collection.
///
/// Errors if there are more than 1 key.
pub fn private_key_optional(&self) -> Result<Option<&Box<dyn PrivateKey>>, AppleCodesignError> {
pub fn private_key_optional(&self) -> Result<Option<&dyn PrivateKey>, AppleCodesignError> {
match self.keys.len() {
0 => Ok(None),
1 => Ok(Some(&self.keys[0])),
1 => Ok(Some(self.keys[0].as_ref())),
n => Err(AppleCodesignError::CliGeneralError(format!(
"at most 1 private keys can be present (found {n})"
))),
Expand Down
8 changes: 3 additions & 5 deletions apple-codesign/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2240,11 +2240,9 @@ fn command_sign(args: &Sign) -> Result<(), AppleCodesignError> {

// Doesn't make sense to set a time-stamp server URL unless we're generating
// CMS signatures.
if settings.signing_key().is_some() {
if args.timestamp_url != "none" {
warn!("using time-stamp protocol server {}", args.timestamp_url);
settings.set_time_stamp_url(&args.timestamp_url)?;
}
if settings.signing_key().is_some() && args.timestamp_url != "none" {
warn!("using time-stamp protocol server {}", args.timestamp_url);
settings.set_time_stamp_url(&args.timestamp_url)?;
}

if let Some(time) = &args.signing_time {
Expand Down

0 comments on commit 135d28e

Please sign in to comment.