diff options
author | Bert Belder <bertbelder@gmail.com> | 2020-03-04 15:52:08 -0800 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2020-03-04 15:54:09 -0800 |
commit | 5d3dfa4cf699ebd46baf5e75dd0ca2a55216a7c1 (patch) | |
tree | 8e2a93a57fd6a1cedc301ae3b5481a2dcc2209f8 /cli/ops/tty.rs | |
parent | a1b98e9e6a204c3d522593cfb8593be5855d6615 (diff) |
Remove unnecessary macro from cli/ops/tty.rs (#4254)
It contains a clippy issue, and there's no need for this macro anyway.
Diffstat (limited to 'cli/ops/tty.rs')
-rw-r--r-- | cli/ops/tty.rs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/cli/ops/tty.rs b/cli/ops/tty.rs index e83d2edfd..b803d99fb 100644 --- a/cli/ops/tty.rs +++ b/cli/ops/tty.rs @@ -39,17 +39,6 @@ pub fn init(i: &mut Isolate, s: &State) { i.register_op("op_isatty", s.core_op(json_op(s.stateful_op(op_isatty)))); } -#[cfg(windows)] -macro_rules! wincheck { - ($funcall:expr) => {{ - let rc = unsafe { $funcall }; - if rc == 0 { - Err(OpError::from(std::io::Error::last_os_error()))?; - } - rc - }}; -} - #[derive(Deserialize)] struct SetRawArgs { rid: u32, @@ -73,6 +62,7 @@ pub fn op_set_raw( #[cfg(windows)] { use std::os::windows::io::AsRawHandle; + use winapi::shared::minwindef::FALSE; use winapi::um::{consoleapi, handleapi}; let state = state_.borrow_mut(); @@ -100,13 +90,19 @@ pub fn op_set_raw( return Err(OpError::other("null handle".to_owned())); } let mut original_mode: DWORD = 0; - wincheck!(consoleapi::GetConsoleMode(handle, &mut original_mode)); + if unsafe { consoleapi::GetConsoleMode(handle, &mut original_mode) } + == FALSE + { + return Err(OpError::from(std::io::Error::last_os_error())); + } let new_mode = if is_raw { original_mode & !RAW_MODE_MASK } else { original_mode | RAW_MODE_MASK }; - wincheck!(consoleapi::SetConsoleMode(handle, new_mode)); + if unsafe { consoleapi::SetConsoleMode(handle, new_mode) } == FALSE { + return Err(OpError::from(std::io::Error::last_os_error())); + } Ok(JsonOp::Sync(json!({}))) } |