Skip to content

Commit

Permalink
Remove unneeded calls to .cast() (#209)
Browse files Browse the repository at this point in the history
* Remove unneeded calls to .cast()

* Satisfy clippy
  • Loading branch information
justsmth authored Aug 14, 2023
1 parent c74566e commit 7ce2d17
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion aws-lc-rs/src/aead/aead_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl AeadCtx {
let aead_ctx = unsafe {
LcPtr::new(EVP_AEAD_CTX_new(
aead,
key_bytes.as_ptr().cast(),
key_bytes.as_ptr(),
key_bytes.len(),
TAG_LEN,
))?
Expand Down
3 changes: 1 addition & 2 deletions aws-lc-rs/src/aead/poly1305.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ pub struct Context {
// are used, is only correct when the state buffer is 64-byte aligned.
#[repr(C, align(64))]
#[allow(non_camel_case_types)]
struct poly1305_state([u8; OPAQUE_LEN]);
const OPAQUE_LEN: usize = 512;
struct poly1305_state(aws_lc::poly1305_state);

impl Context {
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/agreement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ impl EphemeralPrivateKey {
KeyInner::X25519(priv_key) => {
let mut buffer = [0u8; MAX_PUBLIC_KEY_LEN];
unsafe {
X25519_public_from_private(buffer.as_mut_ptr().cast(), priv_key.as_ptr());
X25519_public_from_private(buffer.as_mut_ptr(), priv_key.as_ptr());
}

Ok(PublicKey {
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ unsafe fn ec_point_to_bytes(
**ec_group,
**ec_point,
pt_conv_form,
buf.as_mut_ptr().cast(),
buf.as_mut_ptr(),
PUBLIC_KEY_MAX_LEN,
null_mut(),
);
Expand Down
1 change: 1 addition & 0 deletions aws-lc-rs/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ mod tests {
let unspecified = super::Unspecified::from(key_rejected);
assert_eq!("Unspecified", unspecified.description());

#[allow(clippy::redundant_locals)]
let unspecified = unspecified;
assert_eq!("Unspecified", unspecified.description());
}
Expand Down
6 changes: 1 addition & 5 deletions aws-lc-rs/src/hmac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,7 @@ impl Context {
#[inline]
fn try_update(&mut self, data: &[u8]) -> Result<(), Unspecified> {
unsafe {
if 1 != HMAC_Update(
self.key.get_hmac_ctx_ptr(),
data.as_ptr().cast(),
data.len(),
) {
if 1 != HMAC_Update(self.key.get_hmac_ctx_ptr(), data.as_ptr(), data.len()) {
return Err(Unspecified);
}
}
Expand Down

0 comments on commit 7ce2d17

Please sign in to comment.