diff options
| -rw-r--r-- | openvpn_ffi/src/lib.rs | 2 | ||||
| -rw-r--r-- | openvpn_ffi/src/parse.rs | 2 | ||||
| -rw-r--r-- | src/net.rs | 2 | ||||
| -rw-r--r-- | src/process/monitor.rs | 4 | ||||
| -rw-r--r-- | src/process/openvpn.rs | 2 | ||||
| -rw-r--r-- | talpid_ipc/src/nop_ipc.rs | 4 | ||||
| -rw-r--r-- | talpid_ipc/src/zmq_ipc.rs | 3 | ||||
| -rw-r--r-- | talpid_openvpn_plugin/src/lib.rs | 2 |
8 files changed, 10 insertions, 11 deletions
diff --git a/openvpn_ffi/src/lib.rs b/openvpn_ffi/src/lib.rs index 3c880b2293..702ea43315 100644 --- a/openvpn_ffi/src/lib.rs +++ b/openvpn_ffi/src/lib.rs @@ -61,7 +61,7 @@ impl OpenVpnPluginEvent { if i >= OpenVpnPluginEvent::Up as c_int && i <= OpenVpnPluginEvent::N as c_int { Ok(unsafe { ::std::mem::transmute_copy::<c_int, OpenVpnPluginEvent>(&i) }) } else { - Err(ErrorKind::InvalidEnumVariant(i).into()) + bail!(ErrorKind::InvalidEnumVariant(i)); } } } diff --git a/openvpn_ffi/src/parse.rs b/openvpn_ffi/src/parse.rs index 096e3ada55..2da10e3ca2 100644 --- a/openvpn_ffi/src/parse.rs +++ b/openvpn_ffi/src/parse.rs @@ -28,7 +28,7 @@ error_chain!{ /// terminated. Likewise, if any string pointed to is not properly null-terminated it may crash. pub unsafe fn string_array(mut ptr: *const *const c_char) -> Result<Vec<String>> { if ptr.is_null() { - Err(ErrorKind::Null.into()) + bail!(ErrorKind::Null); } else { let mut strings = Vec::new(); while !(*ptr).is_null() { diff --git a/src/net.rs b/src/net.rs index fb119ea8af..3701ae641e 100644 --- a/src/net.rs +++ b/src/net.rs @@ -61,7 +61,7 @@ impl RemoteAddr { })?; if address.is_empty() || address.contains(':') { let msg = format!("Invalid IP or domain: \"{}\"", address); - return Err(ErrorKind::AddrParse(msg).into()); + bail!(ErrorKind::AddrParse(msg)); } Ok(RemoteAddr::Domain(address.to_owned(), port)) } diff --git a/src/process/monitor.rs b/src/process/monitor.rs index 070cbdf196..3a6f9fb65f 100644 --- a/src/process/monitor.rs +++ b/src/process/monitor.rs @@ -91,7 +91,7 @@ impl<S: ChildSpawner> ChildMonitor<S> { }); Ok(io) } else { - Err(ErrorKind::InvalidState.into()) + bail!(ErrorKind::InvalidState); } } @@ -116,7 +116,7 @@ impl<S: ChildSpawner> ChildMonitor<S> { running_state.child.kill().chain_err(|| ErrorKind::Kill)?; Ok(()) } else { - Err(ErrorKind::InvalidState.into()) + bail!(ErrorKind::InvalidState); } } } diff --git a/src/process/openvpn.rs b/src/process/openvpn.rs index b6d82f02a9..e002d2b9c3 100644 --- a/src/process/openvpn.rs +++ b/src/process/openvpn.rs @@ -119,7 +119,7 @@ impl OpenVpnCommand { if let Some((ref path, ref plugin_args)) = self.plugin { args.push(OsString::from("--plugin")); args.push(OsString::from(path)); - args.extend(plugin_args.iter().map(|arg| OsString::from(arg))); + args.extend(plugin_args.iter().map(OsString::from)); } args } diff --git a/talpid_ipc/src/nop_ipc.rs b/talpid_ipc/src/nop_ipc.rs index 9a767f229d..50d4fae791 100644 --- a/talpid_ipc/src/nop_ipc.rs +++ b/talpid_ipc/src/nop_ipc.rs @@ -12,7 +12,7 @@ pub fn start_new_server<T, F>(_on_message: F) -> Result<IpcServerId> where T: serde::Deserialize + 'static, F: FnMut(Result<T>) + Send + 'static { - Err(ErrorKind::CouldNotStartServer.into()) + bail!(ErrorKind::CouldNotStartServer); } pub struct IpcClient<T> @@ -29,6 +29,6 @@ impl<T> IpcClient<T> } pub fn send(&mut self, _message: &T) -> Result<()> { - Err(ErrorKind::SendError.into()) + bail!(ErrorKind::SendError); } } diff --git a/talpid_ipc/src/zmq_ipc.rs b/talpid_ipc/src/zmq_ipc.rs index aeecf2be41..24d8e2f5d1 100644 --- a/talpid_ipc/src/zmq_ipc.rs +++ b/talpid_ipc/src/zmq_ipc.rs @@ -27,8 +27,7 @@ pub fn start_new_server<T, F>(on_message: F) -> Result<IpcServerId> return Ok(connection_string); } } - - return Err(ErrorKind::CouldNotStartServer.into()); + bail!(ErrorKind::CouldNotStartServer); } fn start_zmq_server(connection_string: &str) -> zmq::Result<zmq::Socket> { diff --git a/talpid_openvpn_plugin/src/lib.rs b/talpid_openvpn_plugin/src/lib.rs index 203b9502ee..14a6816894 100644 --- a/talpid_openvpn_plugin/src/lib.rs +++ b/talpid_openvpn_plugin/src/lib.rs @@ -87,7 +87,7 @@ fn parse_args(args: *const openvpn_plugin_args_open_in) -> Result<talpid_ipc::Ip .into_iter(); let _plugin_path = args_iter.next(); let core_server_id: String = args_iter.next() - .ok_or(ErrorKind::Msg("No core server id given as first argument".to_owned()))?; + .ok_or_else(|| ErrorKind::Msg("No core server id given as first argument".to_owned()))?; Ok(core_server_id) } |
