Skip to content

Commit

Permalink
remove final Tcgetattr(..., termio) calls
Browse files Browse the repository at this point in the history
  • Loading branch information
davecheney committed Dec 26, 2020
1 parent e25b098 commit 321cc23
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
6 changes: 3 additions & 3 deletions term_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ func Open(name string, options ...func(*Term) error) (*Term, error) {
}
}

t := Term{name: name, fd: fd}
termios.Tcgetattr(uintptr(t.fd), &t.orig)
if err := termios.Tcgetattr(uintptr(t.fd), &t.orig); err != nil {
orig, err := termios.Tcgetattr(uintptr(t.fd))
if err != nil {
return nil, err
}
t := Term{name: name, fd: fd, *orig}

if err := t.SetOption(options...); err != nil {
return nil, err
Expand Down
6 changes: 1 addition & 5 deletions term_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ func (t *Term) SetSpeed(baud int) error {

// GetSpeed gets the transmit baud rate.
func (t *Term) GetSpeed() (int, error) {
var a attr
if err := termios.Tcgetattr(uintptr(t.fd), (*syscall.Termios)(&a)); err != nil {
return 0, err
}
return a.getSpeed()
return 0, errNotSupported
}

// Flush flushes both data received but not read, and data written but not transmitted.
Expand Down
6 changes: 2 additions & 4 deletions termios/termios_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ const (
)

// Tcgetattr gets the current serial port settings.
func Tcgetattr(fd uintptr, argp *unix.Termios) error {
termios, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
*argp = *(tiosTounix(termios))
return err
func Tcgetattr(fd uintptr) (*unix.Termios, error) {
return unix.IoctlGetTermios(int(fd), unix.TCGETS)
}

// Tcsetattr sets the current serial port settings.
Expand Down

0 comments on commit 321cc23

Please sign in to comment.