Merge pull request #1205 from npmccallum/modernize
Fix warnings on newer Rust
This commit is contained in:
commit
4a05dc7894
|
|
@ -6,7 +6,7 @@ macro_rules! private_key_from_pem {
|
||||||
pub fn $n2(pem: &[u8], passphrase: &[u8]) -> Result<$t, ::error::ErrorStack> {
|
pub fn $n2(pem: &[u8], passphrase: &[u8]) -> Result<$t, ::error::ErrorStack> {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::init();
|
ffi::init();
|
||||||
let bio = try!(::bio::MemBioSlice::new(pem));
|
let bio = ::bio::MemBioSlice::new(pem)?;
|
||||||
let passphrase = ::std::ffi::CString::new(passphrase).unwrap();
|
let passphrase = ::std::ffi::CString::new(passphrase).unwrap();
|
||||||
cvt_p($f(bio.as_ptr(),
|
cvt_p($f(bio.as_ptr(),
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
|
|
@ -23,7 +23,7 @@ macro_rules! private_key_from_pem {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::init();
|
ffi::init();
|
||||||
let mut cb = ::util::CallbackState::new(callback);
|
let mut cb = ::util::CallbackState::new(callback);
|
||||||
let bio = try!(::bio::MemBioSlice::new(pem));
|
let bio = ::bio::MemBioSlice::new(pem)?;
|
||||||
cvt_p($f(bio.as_ptr(),
|
cvt_p($f(bio.as_ptr(),
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
Some(::util::invoke_passwd_cb::<F>),
|
Some(::util::invoke_passwd_cb::<F>),
|
||||||
|
|
@ -39,14 +39,14 @@ macro_rules! private_key_to_pem {
|
||||||
$(#[$m])*
|
$(#[$m])*
|
||||||
pub fn $n(&self) -> Result<Vec<u8>, ::error::ErrorStack> {
|
pub fn $n(&self) -> Result<Vec<u8>, ::error::ErrorStack> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let bio = try!(::bio::MemBio::new());
|
let bio = ::bio::MemBio::new()?;
|
||||||
try!(cvt($f(bio.as_ptr(),
|
cvt($f(bio.as_ptr(),
|
||||||
self.as_ptr(),
|
self.as_ptr(),
|
||||||
ptr::null(),
|
ptr::null(),
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
-1,
|
-1,
|
||||||
None,
|
None,
|
||||||
ptr::null_mut())));
|
ptr::null_mut()))?;
|
||||||
Ok(bio.get_buf().to_owned())
|
Ok(bio.get_buf().to_owned())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -58,15 +58,15 @@ macro_rules! private_key_to_pem {
|
||||||
passphrase: &[u8]
|
passphrase: &[u8]
|
||||||
) -> Result<Vec<u8>, ::error::ErrorStack> {
|
) -> Result<Vec<u8>, ::error::ErrorStack> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let bio = try!(::bio::MemBio::new());
|
let bio = ::bio::MemBio::new()?;
|
||||||
assert!(passphrase.len() <= ::libc::c_int::max_value() as usize);
|
assert!(passphrase.len() <= ::libc::c_int::max_value() as usize);
|
||||||
try!(cvt($f(bio.as_ptr(),
|
cvt($f(bio.as_ptr(),
|
||||||
self.as_ptr(),
|
self.as_ptr(),
|
||||||
cipher.as_ptr(),
|
cipher.as_ptr(),
|
||||||
passphrase.as_ptr() as *const _ as *mut _,
|
passphrase.as_ptr() as *const _ as *mut _,
|
||||||
passphrase.len() as ::libc::c_int,
|
passphrase.len() as ::libc::c_int,
|
||||||
None,
|
None,
|
||||||
ptr::null_mut())));
|
ptr::null_mut()))?;
|
||||||
Ok(bio.get_buf().to_owned())
|
Ok(bio.get_buf().to_owned())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -78,8 +78,8 @@ macro_rules! to_pem {
|
||||||
$(#[$m])*
|
$(#[$m])*
|
||||||
pub fn $n(&self) -> Result<Vec<u8>, ::error::ErrorStack> {
|
pub fn $n(&self) -> Result<Vec<u8>, ::error::ErrorStack> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let bio = try!(::bio::MemBio::new());
|
let bio = ::bio::MemBio::new()?;
|
||||||
try!(cvt($f(bio.as_ptr(), self.as_ptr())));
|
cvt($f(bio.as_ptr(), self.as_ptr()))?;
|
||||||
Ok(bio.get_buf().to_owned())
|
Ok(bio.get_buf().to_owned())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -91,11 +91,11 @@ macro_rules! to_der {
|
||||||
$(#[$m])*
|
$(#[$m])*
|
||||||
pub fn $n(&self) -> Result<Vec<u8>, ::error::ErrorStack> {
|
pub fn $n(&self) -> Result<Vec<u8>, ::error::ErrorStack> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let len = try!(::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self),
|
let len = ::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self),
|
||||||
ptr::null_mut())));
|
ptr::null_mut()))?;
|
||||||
let mut buf = vec![0; len as usize];
|
let mut buf = vec![0; len as usize];
|
||||||
try!(::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self),
|
::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self),
|
||||||
&mut buf.as_mut_ptr())));
|
&mut buf.as_mut_ptr()))?;
|
||||||
Ok(buf)
|
Ok(buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -122,7 +122,7 @@ macro_rules! from_pem {
|
||||||
pub fn $n(pem: &[u8]) -> Result<$t, ::error::ErrorStack> {
|
pub fn $n(pem: &[u8]) -> Result<$t, ::error::ErrorStack> {
|
||||||
unsafe {
|
unsafe {
|
||||||
::init();
|
::init();
|
||||||
let bio = try!(::bio::MemBioSlice::new(pem));
|
let bio = ::bio::MemBioSlice::new(pem)?;
|
||||||
cvt_p($f(bio.as_ptr(), ::std::ptr::null_mut(), None, ::std::ptr::null_mut()))
|
cvt_p($f(bio.as_ptr(), ::std::ptr::null_mut(), None, ::std::ptr::null_mut()))
|
||||||
.map(|p| ::foreign_types::ForeignType::from_ptr(p))
|
.map(|p| ::foreign_types::ForeignType::from_ptr(p))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue