From c67a9331a4f7c25df943ff821c9c6ed8013df869 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 1 Aug 2018 13:19:54 +0200 Subject: gometalinter: clean up some errcheck warnings Check some errors where relevant. Unfortunately enabling errcheck does not look feasible, too many warnings. Update #538 --- vm/adb/adb.go | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) (limited to 'vm') 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 { -- cgit mrf-deployment