Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ancwrd1 committed Sep 16, 2024
1 parent e6d2d78 commit 3457961
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions security-framework/src/cms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mod encoder {
}

impl CMSEncoder {
/// Create a new instance of CMSEncoder
/// Create a new instance of `CMSEncoder`
pub fn create() -> Result<Self> {
let mut inner: CMSEncoderRef = ptr::null_mut();
cvt(unsafe { CMSEncoderCreate(&mut inner) })?;
Expand All @@ -67,12 +67,12 @@ mod encoder {
cvt(unsafe {
CMSEncoderAddSigners(
self.0,
if signers.len() > 0 { signers.as_CFTypeRef() } else { ptr::null() })
if signers.is_empty() { ptr::null() } else { signers.as_CFTypeRef() })
})?;
Ok(())
}

/// Obtains the array of signers specified with the add_signers function
/// Obtains the array of signers specified with the `add_signers` function
pub fn copy_signers(&self) -> Result<Vec<SecIdentity>> {
let mut out: CFArrayRef = ptr::null_mut();
cvt(unsafe { CMSEncoderCopySigners(self.0, &mut out) })?;
Expand All @@ -91,12 +91,12 @@ mod encoder {
cvt(unsafe {
CMSEncoderAddRecipients(
self.0,
if recipients.len() > 0 { recipients.as_CFTypeRef() } else { ptr::null() })
if recipients.is_empty() { ptr::null() } else { recipients.as_CFTypeRef() })
})?;
Ok(())
}

/// Obtains the array of recipients specified with the add_recipients function
/// Obtains the array of recipients specified with the `add_recipients` function
pub fn copy_recipients(&self) -> Result<Vec<SecCertificate>> {
let mut out: CFArrayRef = ptr::null_mut();
cvt(unsafe { CMSEncoderCopyRecipients(self.0, &mut out) })?;
Expand Down Expand Up @@ -142,12 +142,12 @@ mod encoder {
cvt(unsafe {
CMSEncoderAddSupportingCerts(
self.0,
if certs.len() > 0 { certs.as_CFTypeRef() } else { ptr::null() })
if !certs.is_empty() { certs.as_CFTypeRef() } else { ptr::null() })
})?;
Ok(())
}

/// Obtains the certificates added to a message with add_supporting_certs
/// Obtains the certificates added to a message with `add_supporting_certs`
pub fn copy_supporting_certs(&self) -> Result<Vec<SecCertificate>> {
let mut out: CFArrayRef = ptr::null_mut();
cvt(unsafe { CMSEncoderCopySupportingCerts(self.0, &mut out) })?;
Expand Down Expand Up @@ -233,12 +233,12 @@ mod encoder {
let mut out: CFDataRef = ptr::null_mut();
let signers = CFArray::from_CFTypes(signers);
let recipients = CFArray::from_CFTypes(recipients);
let content_type_oid = content_type_oid.map(|c| CFString::new(c));
let content_type_oid = content_type_oid.map(CFString::new);

cvt(unsafe {
CMSEncodeContent(
if signers.len() > 0 { signers.as_CFTypeRef() } else { ptr::null() },
if recipients.len() > 0 { recipients.as_CFTypeRef() } else { ptr::null() },
if signers.is_empty() { ptr::null() } else { signers.as_CFTypeRef() },
if recipients.is_empty() { ptr::null() } else { recipients.as_CFTypeRef() },
content_type_oid.as_ref().map(|oid| oid.as_CFTypeRef()).unwrap_or(ptr::null()),
detached_content.into(),
signed_attributes,
Expand All @@ -255,7 +255,7 @@ mod encoder {
mod decoder {
use super::*;

/// Holds a result of the CMSDecoder::copy_signer_status function
/// Holds a result of the `CMSDecoder::copy_signer_status` function
pub struct SignerStatus {
/// Signature status
pub signer_status: CMSSignerStatus,
Expand All @@ -282,7 +282,7 @@ mod decoder {
}

impl CMSDecoder {
/// Create a new instance of CMSDecoder
/// Create a new instance of `CMSDecoder`
pub fn create() -> Result<Self> {
let mut inner: CMSDecoderRef = ptr::null_mut();
cvt(unsafe { CMSDecoderCreate(&mut inner) })?;
Expand Down Expand Up @@ -311,7 +311,7 @@ mod decoder {
Ok(())
}

/// Obtains the detached content specified with the set_detached_content function
/// Obtains the detached content specified with the `set_detached_content` function
pub fn copy_detached_content(&self) -> Result<Vec<u8>> {
unsafe {
let mut out: CFDataRef = ptr::null_mut();
Expand Down Expand Up @@ -347,7 +347,7 @@ mod decoder {
CMSDecoderCopySignerStatus(
self.0,
signer_index,
if policies.len() > 0 { policies.as_CFTypeRef() } else { ptr::null() },
if policies.is_empty() { ptr::null() } else { policies.as_CFTypeRef() },
true.into(),
&mut signer_status,
&mut sec_trust,
Expand Down

0 comments on commit 3457961

Please sign in to comment.