Skip to content

Commit 03bc819

Browse files
committed
clippy
1 parent b60f3b8 commit 03bc819

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

openssl-sys/src/rsa.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub unsafe fn EVP_PKEY_CTX_set0_rsa_oaep_label(
7676
EVP_PKEY_OP_TYPE_CRYPT,
7777
EVP_PKEY_CTRL_RSA_OAEP_LABEL,
7878
len,
79-
label as *mut c_void,
79+
label,
8080
)
8181
}
8282

openssl/src/encrypt.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
//! assert_eq!(&*decrypted, data);
4141
//! ```
4242
#[cfg(any(ossl102, libressl310))]
43-
use libc::{c_int, c_void};
43+
use libc::c_int;
4444
use std::{marker::PhantomData, ptr};
4545

4646
use crate::error::ErrorStack;
@@ -174,7 +174,7 @@ impl<'a> Encrypter<'a> {
174174

175175
cvt(ffi::EVP_PKEY_CTX_set0_rsa_oaep_label(
176176
self.pctx,
177-
p as *mut c_void,
177+
p,
178178
label.len() as c_int,
179179
))
180180
.map(|_| ())
@@ -378,7 +378,7 @@ impl<'a> Decrypter<'a> {
378378

379379
cvt(ffi::EVP_PKEY_CTX_set0_rsa_oaep_label(
380380
self.pctx,
381-
p as *mut c_void,
381+
p,
382382
label.len() as c_int,
383383
))
384384
.map(|_| ())

openssl/src/ssl/callbacks.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ where
8686
};
8787
// Give the callback mutable slices into which it can write the identity and psk.
8888
let identity_sl = slice::from_raw_parts_mut(identity as *mut u8, max_identity_len as usize);
89+
#[allow(clippy::unnecessary_cast)]
8990
let psk_sl = slice::from_raw_parts_mut(psk as *mut u8, max_psk_len as usize);
9091
match (*callback)(ssl, hint, identity_sl, psk_sl) {
9192
Ok(psk_len) => psk_len as u32,
@@ -124,6 +125,7 @@ where
124125
Some(CStr::from_ptr(identity).to_bytes())
125126
};
126127
// Give the callback mutable slices into which it can write the psk.
128+
#[allow(clippy::unnecessary_cast)]
127129
let psk_sl = slice::from_raw_parts_mut(psk as *mut u8, max_psk_len as usize);
128130
match (*callback)(ssl, identity, psk_sl) {
129131
Ok(psk_len) => psk_len as u32,
@@ -194,6 +196,7 @@ where
194196
.ssl_context()
195197
.ex_data(SslContext::cached_ex_index::<F>())
196198
.expect("BUG: alpn callback missing") as *const F;
199+
#[allow(clippy::unnecessary_cast)]
197200
let protos = slice::from_raw_parts(inbuf as *const u8, inlen as usize);
198201

199202
match (*callback)(ssl, protos) {
@@ -412,6 +415,7 @@ where
412415
.expect("BUG: session context missing")
413416
.ex_data(SslContext::cached_ex_index::<F>())
414417
.expect("BUG: get session callback missing") as *const F;
418+
#[allow(clippy::unnecessary_cast)]
415419
let data = slice::from_raw_parts(data as *const u8, len as usize);
416420

417421
match (*callback)(ssl, data) {
@@ -455,6 +459,7 @@ where
455459
.ssl_context()
456460
.ex_data(SslContext::cached_ex_index::<F>())
457461
.expect("BUG: stateless cookie generate callback missing") as *const F;
462+
#[allow(clippy::unnecessary_cast)]
458463
let slice = slice::from_raw_parts_mut(cookie as *mut u8, ffi::SSL_COOKIE_LENGTH as usize);
459464
match (*callback)(ssl, slice) {
460465
Ok(len) => {
@@ -482,6 +487,7 @@ where
482487
.ssl_context()
483488
.ex_data(SslContext::cached_ex_index::<F>())
484489
.expect("BUG: stateless cookie verify callback missing") as *const F;
490+
#[allow(clippy::unnecessary_cast)]
485491
let slice = slice::from_raw_parts(cookie as *const c_uchar as *const u8, cookie_len);
486492
(*callback)(ssl, slice) as c_int
487493
}
@@ -503,6 +509,7 @@ where
503509
.expect("BUG: cookie generate callback missing") as *const F;
504510
// We subtract 1 from DTLS1_COOKIE_LENGTH as the ostensible value, 256, is erroneous but retained for
505511
// compatibility. See comments in dtls1.h.
512+
#[allow(clippy::unnecessary_cast)]
506513
let slice =
507514
slice::from_raw_parts_mut(cookie as *mut u8, ffi::DTLS1_COOKIE_LENGTH as usize - 1);
508515
match (*callback)(ssl, slice) {
@@ -542,6 +549,7 @@ where
542549
.ssl_context()
543550
.ex_data(SslContext::cached_ex_index::<F>())
544551
.expect("BUG: cookie verify callback missing") as *const F;
552+
#[allow(clippy::unnecessary_cast)]
545553
let slice =
546554
slice::from_raw_parts(cookie as *const c_uchar as *const u8, cookie_len as usize);
547555
(*callback)(ssl, slice) as c_int
@@ -654,6 +662,7 @@ where
654662
.ex_data(SslContext::cached_ex_index::<F>())
655663
.expect("BUG: custom ext parse callback missing") as *const F;
656664
let ectx = ExtensionContext::from_bits_truncate(context);
665+
#[allow(clippy::unnecessary_cast)]
657666
let slice = slice::from_raw_parts(input as *const u8, inlen);
658667
let cert = if ectx.contains(ExtensionContext::TLS1_3_CERTIFICATE) {
659668
Some((chainidx, X509Ref::from_ptr(x)))

openssl/src/ssl/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,7 @@ impl SslSessionRef {
21322132
unsafe {
21332133
let mut len = 0;
21342134
let p = ffi::SSL_SESSION_get_id(self.as_ptr(), &mut len);
2135+
#[allow(clippy::unnecessary_cast)]
21352136
slice::from_raw_parts(p as *const u8, len as usize)
21362137
}
21372138
}

openssl/src/x509/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,6 +2102,7 @@ impl GeneralNameRef {
21022102
let ptr = ASN1_STRING_get0_data(d as *mut _);
21032103
let len = ffi::ASN1_STRING_length(d as *mut _);
21042104

2105+
#[allow(clippy::unnecessary_cast)]
21052106
let slice = slice::from_raw_parts(ptr as *const u8, len as usize);
21062107
// IA5Strings are stated to be ASCII (specifically IA5). Hopefully
21072108
// OpenSSL checks that when loading a certificate but if not we'll
@@ -2155,6 +2156,7 @@ impl GeneralNameRef {
21552156
let ptr = ASN1_STRING_get0_data(d as *mut _);
21562157
let len = ffi::ASN1_STRING_length(d as *mut _);
21572158

2159+
#[allow(clippy::unnecessary_cast)]
21582160
Some(slice::from_raw_parts(ptr as *const u8, len as usize))
21592161
}
21602162
}

0 commit comments

Comments
 (0)