From c3b1d0d6d8690eaebe3064711b026770cc37efa3 Mon Sep 17 00:00:00 2001 From: Peter Morjan Date: Sat, 7 Jan 2017 15:41:52 +0100 Subject: [PATCH] ssh/terminal: consistent return value for Restore This patch makes the Restore function return nil on success to be consistent with other functions like MakeRaw. Change-Id: I81e63f568787dd88466a5bb30cb87c4c3be75a5c Reviewed-on: https://go-review.googlesource.com/34952 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- ssh/terminal/util.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ssh/terminal/util.go b/ssh/terminal/util.go index c869213..747f1b8 100644 --- a/ssh/terminal/util.go +++ b/ssh/terminal/util.go @@ -72,8 +72,10 @@ func GetState(fd int) (*State, error) { // Restore restores the terminal connected to the given file descriptor to a // previous state. func Restore(fd int, state *State) error { - _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&state.termios)), 0, 0, 0) - return err + if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&state.termios)), 0, 0, 0); err != 0 { + return err + } + return nil } // GetSize returns the dimensions of the given terminal.