Addressed review comments
- fixed invalid file permissions - removed redundand mem::transmute - removed outdated FIXME's - removed redundand temporary variable - removed macro_export for internal macros
This commit is contained in:
parent
4fd169a1e5
commit
3f413e9354
|
|
@ -43,10 +43,9 @@ impl MemBio {
|
||||||
/// Consumes current bio and returns wrapped value
|
/// Consumes current bio and returns wrapped value
|
||||||
/// Note that data ownership is lost and
|
/// Note that data ownership is lost and
|
||||||
/// should be handled manually
|
/// should be handled manually
|
||||||
pub unsafe fn unwrap(self) -> *mut ffi::BIO {
|
pub unsafe fn unwrap(mut self) -> *mut ffi::BIO {
|
||||||
let mut t = self;
|
self.owned = false;
|
||||||
t.owned = false;
|
self.bio
|
||||||
t.bio
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Temporarily gets wrapped value
|
/// Temporarily gets wrapped value
|
||||||
|
|
@ -57,7 +56,6 @@ impl MemBio {
|
||||||
|
|
||||||
impl Reader for MemBio {
|
impl Reader for MemBio {
|
||||||
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
|
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
|
||||||
// FIXME: merge with read
|
|
||||||
let ret = unsafe {
|
let ret = unsafe {
|
||||||
ffi::BIO_read(self.bio, buf.as_ptr() as *mut c_void,
|
ffi::BIO_read(self.bio, buf.as_ptr() as *mut c_void,
|
||||||
buf.len() as c_int)
|
buf.len() as c_int)
|
||||||
|
|
@ -74,7 +72,6 @@ impl Reader for MemBio {
|
||||||
|
|
||||||
impl Writer for MemBio {
|
impl Writer for MemBio {
|
||||||
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
|
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
|
||||||
// FIXME: merge with write
|
|
||||||
let ret = unsafe {
|
let ret = unsafe {
|
||||||
ffi::BIO_write(self.bio, buf.as_ptr() as *const c_void,
|
ffi::BIO_write(self.bio, buf.as_ptr() as *const c_void,
|
||||||
buf.len() as c_int)
|
buf.len() as c_int)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
#![macro_escape]
|
#![macro_escape]
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! try_ssl_stream {
|
macro_rules! try_ssl_stream {
|
||||||
($e:expr) => (
|
($e:expr) => (
|
||||||
match $e {
|
match $e {
|
||||||
|
|
@ -11,7 +10,6 @@ macro_rules! try_ssl_stream {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shortcut return with SSL error if something went wrong
|
/// Shortcut return with SSL error if something went wrong
|
||||||
#[macro_export]
|
|
||||||
macro_rules! try_ssl_if {
|
macro_rules! try_ssl_if {
|
||||||
($e:expr) => (
|
($e:expr) => (
|
||||||
if $e {
|
if $e {
|
||||||
|
|
@ -22,13 +20,11 @@ macro_rules! try_ssl_if {
|
||||||
|
|
||||||
/// Shortcut return with SSL error if last error result is 0
|
/// Shortcut return with SSL error if last error result is 0
|
||||||
/// (default)
|
/// (default)
|
||||||
#[macro_export]
|
|
||||||
macro_rules! try_ssl{
|
macro_rules! try_ssl{
|
||||||
($e:expr) => (try_ssl_if!($e == 0))
|
($e:expr) => (try_ssl_if!($e == 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shortcut return with SSL if got a null result
|
/// Shortcut return with SSL if got a null result
|
||||||
#[macro_export]
|
|
||||||
macro_rules! try_ssl_null{
|
macro_rules! try_ssl_null{
|
||||||
($e:expr) => (try_ssl_if!($e == ptr::null_mut()))
|
($e:expr) => (try_ssl_if!($e == ptr::null_mut()))
|
||||||
}
|
}
|
||||||
|
|
@ -42,7 +38,6 @@ macro_rules! try_ssl_null{
|
||||||
/// let _ = try!(something)
|
/// let _ = try!(something)
|
||||||
/// Ok(())
|
/// Ok(())
|
||||||
/// ```
|
/// ```
|
||||||
#[macro_export]
|
|
||||||
macro_rules! lift_ssl_if{
|
macro_rules! lift_ssl_if{
|
||||||
($e:expr) => ( {
|
($e:expr) => ( {
|
||||||
if $e {
|
if $e {
|
||||||
|
|
@ -55,7 +50,6 @@ macro_rules! lift_ssl_if{
|
||||||
|
|
||||||
/// Lifts current SSL error code into Result<(), Error>
|
/// Lifts current SSL error code into Result<(), Error>
|
||||||
/// if SSL returned 0 (default error indication)
|
/// if SSL returned 0 (default error indication)
|
||||||
#[macro_export]
|
|
||||||
macro_rules! lift_ssl {
|
macro_rules! lift_ssl {
|
||||||
($e:expr) => (lift_ssl_if!($e == 0))
|
($e:expr) => (lift_ssl_if!($e == 0))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -184,8 +184,8 @@ impl X509Generator {
|
||||||
fn add_extension(x509: *mut ffi::X509, extension: c_int, value: &str) -> Result<(), SslError> {
|
fn add_extension(x509: *mut ffi::X509, extension: c_int, value: &str) -> Result<(), SslError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
// FIXME: RAII
|
// FIXME: RAII
|
||||||
let ctx: ffi::X509V3_CTX = mem::zeroed();
|
let mut ctx: ffi::X509V3_CTX = mem::zeroed();
|
||||||
ffi::X509V3_set_ctx(mem::transmute(&ctx), x509, x509,
|
ffi::X509V3_set_ctx(&mut ctx, x509, x509,
|
||||||
ptr::null_mut(), ptr::null_mut(), 0);
|
ptr::null_mut(), ptr::null_mut(), 0);
|
||||||
let ext = value.with_c_str(|value|
|
let ext = value.with_c_str(|value|
|
||||||
ffi::X509V3_EXT_conf_nid(ptr::null_mut(), mem::transmute(&ctx), extension, mem::transmute(value)));
|
ffi::X509V3_EXT_conf_nid(ptr::null_mut(), mem::transmute(&ctx), extension, mem::transmute(value)));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue