Fix lints

This commit is contained in:
Anthony Ramine 2023-03-27 11:59:56 +02:00
parent 6d61bf2adb
commit 74b0cc0da7
10 changed files with 20 additions and 15 deletions

View File

@ -332,7 +332,7 @@ fn main() {
println!("cargo:warning=fetching boringssl git submodule");
// fetch the boringssl submodule
let status = Command::new("git")
.args(&[
.args([
"submodule",
"update",
"--init",

View File

@ -399,6 +399,7 @@ impl Asn1Integer {
}
impl Asn1IntegerRef {
#[allow(clippy::unnecessary_cast)]
#[allow(missing_docs)]
#[deprecated(since = "0.10.6", note = "use to_bn instead")]
pub fn get(&self) -> i64 {

View File

@ -18,7 +18,7 @@ pub fn encode_block(src: &[u8]) -> String {
let src_len = src.len();
let len = encoded_len(src_len).unwrap();
let mut out = Vec::with_capacity(len as usize);
let mut out = Vec::with_capacity(len);
// SAFETY: `encoded_len` ensures space for 4 output characters
// for every 3 input bytes including padding and nul terminator.
@ -26,7 +26,7 @@ pub fn encode_block(src: &[u8]) -> String {
// `EVP_EncodeBlock` will only write to not read from `out`.
unsafe {
let out_len = ffi::EVP_EncodeBlock(out.as_mut_ptr(), src.as_ptr(), src_len);
out.set_len(out_len as usize);
out.set_len(out_len);
String::from_utf8_unchecked(out)
}
}
@ -52,7 +52,7 @@ pub fn decode_block(src: &str) -> Result<Vec<u8>, ErrorStack> {
let src_len = src.len();
let len = decoded_len(src_len).unwrap();
let mut out = Vec::with_capacity(len as usize);
let mut out = Vec::with_capacity(len);
// SAFETY: `decoded_len` ensures space for 3 output bytes
// for every 4 input characters including padding.

View File

@ -174,6 +174,7 @@ impl EcGroupRef {
/// OpenSSL documentation at [`EC_GROUP_get_degree`]
///
/// [`EC_GROUP_get_degree`]: https://www.openssl.org/docs/man1.1.0/crypto/EC_GROUP_get_degree.html
#[allow(clippy::unnecessary_cast)]
pub fn degree(&self) -> u32 {
unsafe { ffi::EC_GROUP_get_degree(self.as_ptr()) as u32 }
}

View File

@ -216,6 +216,7 @@ impl Error {
}
/// Returns the line in the source file which encountered the error.
#[allow(clippy::unnecessary_cast)]
pub fn line(&self) -> u32 {
self.line as u32
}

View File

@ -72,7 +72,7 @@ impl MessageDigest {
/// The size of the digest in bytes.
#[allow(clippy::trivially_copy_pass_by_ref)]
pub fn size(&self) -> usize {
unsafe { ffi::EVP_MD_size(self.0) as usize }
unsafe { ffi::EVP_MD_size(self.0) }
}
/// The name of the digest.

View File

@ -296,6 +296,7 @@ where
/// This corresponds to [`RSA_check_key`].
///
/// [`RSA_check_key`]: https://www.openssl.org/docs/man1.1.0/crypto/RSA_check_key.html
#[allow(clippy::unnecessary_cast)]
pub fn check_key(&self) -> Result<bool, ErrorStack> {
unsafe {
let result = ffi::RSA_check_key(self.as_ptr()) as i32;
@ -361,6 +362,7 @@ where
/// This corresponds to [`RSA_size`].
///
/// [`RSA_size`]: https://www.openssl.org/docs/man1.1.0/crypto/RSA_size.html
#[allow(clippy::unnecessary_cast)]
pub fn size(&self) -> u32 {
unsafe { ffi::RSA_size(self.as_ptr()) as u32 }
}

View File

@ -2746,7 +2746,7 @@ impl SslRef {
if len == 0 {
None
} else {
Some(slice::from_raw_parts(p as *const u8, len as usize))
Some(slice::from_raw_parts(p as *const u8, len))
}
}
}

View File

@ -199,7 +199,7 @@ fn verify_callback() {
CALLED_BACK.store(true, Ordering::SeqCst);
let cert = x509.current_cert().unwrap();
let digest = cert.digest(MessageDigest::sha1()).unwrap();
assert_eq!(hex::encode(&digest), expected);
assert_eq!(hex::encode(digest), expected);
true
});
@ -221,7 +221,7 @@ fn ssl_verify_callback() {
CALLED_BACK.store(true, Ordering::SeqCst);
let cert = x509.current_cert().unwrap();
let digest = cert.digest(MessageDigest::sha1()).unwrap();
assert_eq!(hex::encode(&digest), expected);
assert_eq!(hex::encode(digest), expected);
true
});
@ -311,9 +311,9 @@ fn test_connect_with_srtp_ctx() {
let mut ctx = SslContext::builder(SslMethod::dtls()).unwrap();
ctx.set_tlsext_use_srtp("SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32")
.unwrap();
ctx.set_certificate_file(&Path::new("test/cert.pem"), SslFiletype::PEM)
ctx.set_certificate_file(Path::new("test/cert.pem"), SslFiletype::PEM)
.unwrap();
ctx.set_private_key_file(&Path::new("test/key.pem"), SslFiletype::PEM)
ctx.set_private_key_file(Path::new("test/key.pem"), SslFiletype::PEM)
.unwrap();
let mut ssl = Ssl::new(&ctx.build()).unwrap();
ssl.set_mtu(1500).unwrap();
@ -367,9 +367,9 @@ fn test_connect_with_srtp_ssl() {
let guard = thread::spawn(move || {
let stream = listener.accept().unwrap().0;
let mut ctx = SslContext::builder(SslMethod::dtls()).unwrap();
ctx.set_certificate_file(&Path::new("test/cert.pem"), SslFiletype::PEM)
ctx.set_certificate_file(Path::new("test/cert.pem"), SslFiletype::PEM)
.unwrap();
ctx.set_private_key_file(&Path::new("test/key.pem"), SslFiletype::PEM)
ctx.set_private_key_file(Path::new("test/key.pem"), SslFiletype::PEM)
.unwrap();
let mut ssl = Ssl::new(&ctx.build()).unwrap();
ssl.set_tlsext_use_srtp("SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32")
@ -988,9 +988,9 @@ fn keying_export() {
let guard = thread::spawn(move || {
let stream = listener.accept().unwrap().0;
let mut ctx = SslContext::builder(SslMethod::tls()).unwrap();
ctx.set_certificate_file(&Path::new("test/cert.pem"), SslFiletype::PEM)
ctx.set_certificate_file(Path::new("test/cert.pem"), SslFiletype::PEM)
.unwrap();
ctx.set_private_key_file(&Path::new("test/key.pem"), SslFiletype::PEM)
ctx.set_private_key_file(Path::new("test/key.pem"), SslFiletype::PEM)
.unwrap();
let ssl = Ssl::new(&ctx.build()).unwrap();
let mut stream = ssl.accept(stream).unwrap();

View File

@ -181,7 +181,7 @@ impl<T: Stackable> StackRef<T> {
/// Returns the number of items in the stack.
pub fn len(&self) -> usize {
unsafe { OPENSSL_sk_num(self.as_stack()) as usize }
unsafe { OPENSSL_sk_num(self.as_stack()) }
}
/// Determines if the stack is empty.