aboutsummaryrefslogtreecommitdiffstats
path: root/vm/adb/adb.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-08-01 13:19:54 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-08-02 16:57:31 +0200
commitc67a9331a4f7c25df943ff821c9c6ed8013df869 (patch)
treee380eb862ba4e10896ad0d31442bd2f2c4928c0e /vm/adb/adb.go
parent0a7cf4ec6374315af969a5bad7532095a1962492 (diff)
gometalinter: clean up some errcheck warnings
Check some errors where relevant. Unfortunately enabling errcheck does not look feasible, too many warnings. Update #538
Diffstat (limited to 'vm/adb/adb.go')
-rw-r--r--vm/adb/adb.go38
1 files changed, 3 insertions, 35 deletions
diff --git a/vm/adb/adb.go b/vm/adb/adb.go
index 88842d340..8a7a0bb2e 100644
--- a/vm/adb/adb.go
+++ b/vm/adb/adb.go
@@ -245,44 +245,12 @@ func (inst *instance) adb(args ...string) ([]byte, error) {
if inst.debug {
log.Logf(0, "executing adb %+v", args)
}
- rpipe, wpipe, err := os.Pipe()
- if err != nil {
- return nil, fmt.Errorf("failed to create pipe: %v", err)
- }
- defer wpipe.Close()
- defer rpipe.Close()
- cmd := osutil.Command(inst.adbBin, append([]string{"-s", inst.device}, args...)...)
- cmd.Stdout = wpipe
- cmd.Stderr = wpipe
- if err := cmd.Start(); err != nil {
- return nil, err
- }
- wpipe.Close()
- done := make(chan bool)
- go func() {
- select {
- case <-time.After(time.Minute):
- if inst.debug {
- log.Logf(0, "adb hanged")
- }
- cmd.Process.Kill()
- case <-done:
- }
- }()
- if err := cmd.Wait(); err != nil {
- close(done)
- out, _ := ioutil.ReadAll(rpipe)
- if inst.debug {
- log.Logf(0, "adb failed: %v\n%s", err, out)
- }
- return nil, fmt.Errorf("adb %+v failed: %v\n%s", args, err, out)
- }
- close(done)
+ args = append([]string{"-s", inst.device}, args...)
+ out, err := osutil.RunCmd(time.Minute, "", inst.adbBin, args...)
if inst.debug {
log.Logf(0, "adb returned")
}
- out, _ := ioutil.ReadAll(rpipe)
- return out, nil
+ return out, err
}
func (inst *instance) repair() error {