From de80aae4bc1e6d5a03bdca2492352ec986964069 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 30 Nov 2020 10:19:10 -0800 Subject: [PATCH] recvtty: fix errcheck linter warnings Fixes the following errcheck linter warnings > contrib/cmd/recvtty/recvtty.go:115:10: Error return value of `io.Copy` is not checked (errcheck) > io.Copy(os.Stdout, c) > ^ > contrib/cmd/recvtty/recvtty.go:120:11: Error return value of `io.Copy` is not checked (errcheck) > io.Copy(c, os.Stdin) > ^ > contrib/cmd/recvtty/recvtty.go:175:11: Error return value of `io.Copy` is not checked (errcheck) > io.Copy(devnull, master) > ^ Signed-off-by: Kir Kolyshkin --- contrib/cmd/recvtty/recvtty.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/contrib/cmd/recvtty/recvtty.go b/contrib/cmd/recvtty/recvtty.go index 086700cef..cf2fddf76 100644 --- a/contrib/cmd/recvtty/recvtty.go +++ b/contrib/cmd/recvtty/recvtty.go @@ -111,16 +111,19 @@ func handleSingle(path string, noStdin bool) error { } // Copy from our stdio to the master fd. - var wg sync.WaitGroup + var ( + wg sync.WaitGroup + inErr, outErr error + ) wg.Add(1) go func() { - io.Copy(os.Stdout, c) + _, outErr = io.Copy(os.Stdout, c) wg.Done() }() if !noStdin { wg.Add(1) go func() { - io.Copy(c, os.Stdin) + _, inErr = io.Copy(c, os.Stdin) wg.Done() }() } @@ -128,7 +131,12 @@ func handleSingle(path string, noStdin bool) error { // Only close the master fd once we've stopped copying. wg.Wait() c.Close() - return nil + + if outErr != nil { + return outErr + } + + return inErr } func handleNull(path string) error { @@ -168,7 +176,7 @@ func handleNull(path string) error { return } - io.Copy(ioutil.Discard, master) + _, _ = io.Copy(ioutil.Discard, master) }(conn) } }