aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-05-02 21:20:13 -0700
committerSteven Fackler <[email protected]>2016-05-03 20:24:07 -0700
commitf1846bce7840b16cdcf079d2d96d6ed24d2cc269 (patch)
tree95f2301b13ed608b57bb8cc3521994da3a6653c7
parentDrop MaybeSslStream (diff)
downloadrust-openssl-f1846bce7840b16cdcf079d2d96d6ed24d2cc269.tar.xz
rust-openssl-f1846bce7840b16cdcf079d2d96d6ed24d2cc269.zip
Remove silly internal error enum
-rw-r--r--openssl/src/ssl/mod.rs53
1 files changed, 9 insertions, 44 deletions
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs
index 08f85dfb..c6ebb397 100644
--- a/openssl/src/ssl/mod.rs
+++ b/openssl/src/ssl/mod.rs
@@ -834,12 +834,8 @@ impl Ssl {
unsafe { ffi::SSL_write(self.ssl, buf.as_ptr() as *const c_void, len) }
}
- fn get_error(&self, ret: c_int) -> LibErrorStack {
- let err = unsafe { ffi::SSL_get_error(self.ssl, ret) };
- match LibErrorStack::from_i32(err as i32) {
- Some(err) => err,
- None => unreachable!(),
- }
+ fn get_error(&self, ret: c_int) -> c_int {
+ unsafe { ffi::SSL_get_error(self.ssl, ret) }
}
/// Sets the verification mode to be used during the handshake process.
@@ -1037,37 +1033,6 @@ impl Ssl {
}
}
-macro_rules! make_LibErrorStack {
- ($($variant:ident = $value:ident),+) => {
- #[derive(Debug)]
- #[repr(i32)]
- enum LibErrorStack {
- $($variant = ffi::$value),+
- }
-
- impl LibErrorStack {
- fn from_i32(val: i32) -> Option<LibErrorStack> {
- match val {
- $(ffi::$value => Some(LibErrorStack::$variant),)+
- _ => None
- }
- }
- }
- }
-}
-
-make_LibErrorStack! {
- ErrorNone = SSL_ERROR_NONE,
- ErrorSsl = SSL_ERROR_SSL,
- ErrorWantRead = SSL_ERROR_WANT_READ,
- ErrorWantWrite = SSL_ERROR_WANT_WRITE,
- ErrorWantX509Lookup = SSL_ERROR_WANT_X509_LOOKUP,
- ErrorSyscall = SSL_ERROR_SYSCALL,
- ErrorZeroReturn = SSL_ERROR_ZERO_RETURN,
- ErrorWantConnect = SSL_ERROR_WANT_CONNECT,
- ErrorWantAccept = SSL_ERROR_WANT_ACCEPT
-}
-
/// A stream wrapper which handles SSL encryption for an underlying stream.
pub struct SslStream<S> {
ssl: Ssl,
@@ -1177,8 +1142,8 @@ impl<S> SslStream<S> {
self.check_panic();
match self.ssl.get_error(ret) {
- LibErrorStack::ErrorSsl => Error::Ssl(ErrorStack::get()),
- LibErrorStack::ErrorSyscall => {
+ ffi::SSL_ERROR_SSL => Error::Ssl(ErrorStack::get()),
+ ffi::SSL_ERROR_SYSCALL => {
let errs = ErrorStack::get();
if errs.errors().is_empty() {
if ret == 0 {
@@ -1191,12 +1156,12 @@ impl<S> SslStream<S> {
Error::Ssl(errs)
}
}
- LibErrorStack::ErrorZeroReturn => Error::ZeroReturn,
- LibErrorStack::ErrorWantWrite => Error::WantWrite(self.get_bio_error()),
- LibErrorStack::ErrorWantRead => Error::WantRead(self.get_bio_error()),
+ ffi::SSL_ERROR_ZERO_RETURN => Error::ZeroReturn,
+ ffi::SSL_ERROR_WANT_WRITE => Error::WantWrite(self.get_bio_error()),
+ ffi::SSL_ERROR_WANT_READ => Error::WantRead(self.get_bio_error()),
err => {
- Error::Stream(io::Error::new(io::ErrorKind::Other,
- format!("unexpected error {:?}", err)))
+ Error::Stream(io::Error::new(io::ErrorKind::InvalidData,
+ format!("unexpected error {}", err)))
}
}
}