diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-05-03 15:48:26 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-05-03 15:48:26 +0200 |
| commit | a630fd8b418650f8df52aead511ec4d27ca48ad2 (patch) | |
| tree | 0202f7587a306bab366f7d3720ef9b831933e3e0 /vm | |
| parent | 9fe5658a1b7320b756d02cf2075dc5c735f86ff4 (diff) | |
gometalinter: some fixes for unparam
But we still can't enable it as there are more [uninteresting] warnings.
Update #538
Diffstat (limited to 'vm')
| -rw-r--r-- | vm/gce/gce.go | 8 | ||||
| -rw-r--r-- | vm/isolated/isolated.go | 16 |
2 files changed, 12 insertions, 12 deletions
diff --git a/vm/gce/gce.go b/vm/gce/gce.go index 7f3281382..843072cff 100644 --- a/vm/gce/gce.go +++ b/vm/gce/gce.go @@ -192,7 +192,7 @@ func (inst *instance) Forward(port int) (string, error) { func (inst *instance) Copy(hostSrc string) (string, error) { vmDst := "./" + filepath.Base(hostSrc) args := append(sshArgs(inst.debug, inst.sshKey, "-P", 22), hostSrc, inst.sshUser+"@"+inst.ip+":"+vmDst) - if _, err := runCmd(inst.debug, "scp", args...); err != nil { + if err := runCmd(inst.debug, "scp", args...); err != nil { return "", err } return vmDst, nil @@ -359,7 +359,7 @@ func (pool *Pool) waitInstanceBoot(name, ip, sshKey, sshUser, gceKey string) err return fmt.Errorf("shutdown in progress") } args := append(sshArgs(pool.env.Debug, sshKey, "-p", 22), sshUser+"@"+ip, pwd) - if _, err := runCmd(pool.env.Debug, "ssh", args...); err == nil { + if err := runCmd(pool.env.Debug, "ssh", args...); err == nil { return nil } } @@ -473,7 +473,7 @@ func uploadImageToGCS(localImage, gcsImage string) error { return nil } -func runCmd(debug bool, bin string, args ...string) ([]byte, error) { +func runCmd(debug bool, bin string, args ...string) error { if debug { log.Logf(0, "running command: %v %#v", bin, args) } @@ -481,7 +481,7 @@ func runCmd(debug bool, bin string, args ...string) ([]byte, error) { if debug { log.Logf(0, "result: %v\n%s", err, output) } - return output, err + return err } func sshArgs(debug bool, sshKey, portArg string, port int) []string { diff --git a/vm/isolated/isolated.go b/vm/isolated/isolated.go index 449228192..8ab3eb9bf 100644 --- a/vm/isolated/isolated.go +++ b/vm/isolated/isolated.go @@ -115,15 +115,16 @@ func (inst *instance) Forward(port int) (string, error) { return fmt.Sprintf("127.0.0.1:%v", port), nil } -func (inst *instance) ssh(command string) ([]byte, error) { +func (inst *instance) ssh(command string) error { if inst.debug { log.Logf(0, "executing ssh %+v", command) } rpipe, wpipe, err := osutil.LongPipe() if err != nil { - return nil, err + return err } + // TODO(dvyukov): who is closing rpipe? args := append(inst.sshArgs("-p"), inst.target, command) if inst.debug { @@ -134,7 +135,7 @@ func (inst *instance) ssh(command string) ([]byte, error) { cmd.Stderr = wpipe if err := cmd.Start(); err != nil { wpipe.Close() - return nil, err + return err } wpipe.Close() @@ -155,14 +156,13 @@ func (inst *instance) ssh(command string) ([]byte, error) { if inst.debug { log.Logf(0, "ssh failed: %v\n%s", err, out) } - return nil, fmt.Errorf("ssh %+v failed: %v\n%s", args, err, out) + return fmt.Errorf("ssh %+v failed: %v\n%s", args, err, out) } close(done) if inst.debug { log.Logf(0, "ssh returned") } - out, _ := ioutil.ReadAll(rpipe) - return out, nil + return nil } func (inst *instance) repair() error { @@ -199,7 +199,7 @@ func (inst *instance) waitForSSH(timeout int) error { if !vmimpl.SleepInterruptible(time.Second) { return fmt.Errorf("shutdown in progress") } - if _, err = inst.ssh("pwd"); err == nil { + if err = inst.ssh("pwd"); err == nil { return nil } if time.Since(start).Seconds() > float64(timeout) { @@ -217,7 +217,7 @@ func (inst *instance) waitForReboot(timeout int) error { return fmt.Errorf("shutdown in progress") } // If it fails, then the reboot started - if _, err = inst.ssh("pwd"); err != nil { + if err = inst.ssh("pwd"); err != nil { return nil } if time.Since(start).Seconds() > float64(timeout) { |
