Skip to content

Commit

Permalink
Merge pull request #89 from boxdot/clippy
Browse files Browse the repository at this point in the history
Fix clippy.
  • Loading branch information
rubdos authored Apr 26, 2021
2 parents 1179986 + 450a8cb commit 8ddb9c8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
4 changes: 1 addition & 3 deletions libsignal-service/src/attachment_cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ mod tests {
}

#[test]
fn attachment_encrypt_decrypt_bad_key() -> Result<(), AttachmentCipherError>
{
fn attachment_encrypt_decrypt_bad_key() {
let mut key = [0u8; 64];
let mut iv = [0u8; 16];
rand::thread_rng().fill_bytes(&mut key);
Expand All @@ -142,7 +141,6 @@ mod tests {
AttachmentCipherError::MacError
);
assert_ne!(&buf, &plaintext);
Ok(())
}

#[test]
Expand Down
19 changes: 8 additions & 11 deletions libsignal-service/src/groups_v2/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,27 +155,24 @@ impl GroupOperations {
}
}

fn decrypt_title(
&self,
ciphertext: &[u8],
) -> Result<String, GroupDecryptionError> {
fn decrypt_title(&self, ciphertext: &[u8]) -> String {
use group_attribute_blob::Content;
match self.decrypt_blob(&ciphertext).content {
Some(Content::Title(title)) => Ok(title),
_ => Ok("".into()), // TODO: return an error here?
Some(Content::Title(title)) => title,
_ => "".into(), // TODO: return an error here?
}
}

fn decrypt_disappearing_message_timer(
&self,
ciphertext: &[u8],
) -> Result<Option<DecryptedTimer>, GroupDecryptionError> {
) -> Option<DecryptedTimer> {
use group_attribute_blob::Content;
match self.decrypt_blob(ciphertext).content {
Some(Content::DisappearingMessagesDuration(duration)) => {
Ok(Some(DecryptedTimer { duration }))
Some(DecryptedTimer { duration })
}
_ => Ok(None),
_ => None,
}
}

Expand All @@ -186,11 +183,11 @@ impl GroupOperations {
let group_operations = Self {
group_secret_params,
};
let title = group_operations.decrypt_title(&group.title)?;
let title = group_operations.decrypt_title(&group.title);
let disappearing_messages_timer = group_operations
.decrypt_disappearing_message_timer(
&group.disappearing_messages_timer,
)?;
);
let members = group
.members
.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion libsignal-service/src/provisioning/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ mod tests {
let ctx = Context::default();
let cipher = ProvisioningCipher::new(ctx.clone()).unwrap();
let encrypt_cipher =
ProvisioningCipher::from_public(ctx.clone(), cipher.public_key());
ProvisioningCipher::from_public(ctx, cipher.public_key());

assert_eq!(
cipher.public_key(),
Expand Down
2 changes: 1 addition & 1 deletion libsignal-service/src/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<Service: PushService> MessageReceiver<Service> {
});
}
}
Err(e) => return Err(e.into()),
Err(e) => return Err(e),
}
};

Expand Down
10 changes: 5 additions & 5 deletions libsignal-service/src/sealed_session_cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ mod tests {
)?;

let bob_cipher = SealedSessionCipher::new(
ctx.clone(),
ctx,
bob_store_context,
bob_address(),
certificate_validator,
Expand Down Expand Up @@ -858,7 +858,7 @@ mod tests {
)?;

let bob_cipher = SealedSessionCipher::new(
ctx.clone(),
ctx,
bob_store_context,
bob_address(),
certificate_validator,
Expand Down Expand Up @@ -901,7 +901,7 @@ mod tests {
)?;

let bob_cipher = SealedSessionCipher::new(
ctx.clone(),
ctx,
bob_store_context,
bob_address(),
certificate_validator,
Expand Down Expand Up @@ -998,13 +998,13 @@ mod tests {
.as_slice()
.to_vec();

Ok(SenderCertificate::try_from(
SenderCertificate::try_from(
&context,
crate::proto::SenderCertificate {
certificate: Some(sender_certificate_bytes),
signature: Some(sender_certificate_signature),
},
)?)
)
}

fn initialize_session(
Expand Down

0 comments on commit 8ddb9c8

Please sign in to comment.