Fix error shadow and error check warnings

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
Mrunal Patel 2017-01-06 16:21:23 -08:00
parent 1a9dd2678d
commit c54f1495e3
3 changed files with 11 additions and 11 deletions

View File

@ -14,7 +14,7 @@ import (
)
func killContainer(container libcontainer.Container) error {
container.Signal(syscall.SIGKILL, false)
_ = container.Signal(syscall.SIGKILL, false)
for i := 0; i < 100; i++ {
time.Sleep(100 * time.Millisecond)
if err := container.Signal(syscall.Signal(0), false); err != nil {
@ -61,7 +61,7 @@ status of "ubuntu01" as "stopped" the following will delete resources held for
// if there was an aborted start or something of the sort then the container's directory could exist but
// libcontainer does not see it because the state.json file inside that directory was never created.
path := filepath.Join(context.GlobalString("root"), id)
if err := os.RemoveAll(path); err != nil {
if err = os.RemoveAll(path); err != nil {
fmt.Fprintf(os.Stderr, "remove %s: %v\n", path, err)
}
fmt.Fprintf(os.Stderr, "container %s does not exist\n", id)

View File

@ -150,7 +150,7 @@ func restoreContainer(context *cli.Context, spec *specs.Spec, config *configs.Co
setManageCgroupsMode(context, options)
if err := setEmptyNsMask(context, options); err != nil {
if err = setEmptyNsMask(context, options); err != nil {
return -1, err
}
@ -176,8 +176,8 @@ func restoreContainer(context *cli.Context, spec *specs.Spec, config *configs.Co
}
if pidFile := context.String("pid-file"); pidFile != "" {
if err := createPidFile(pidFile, process); err != nil {
process.Signal(syscall.SIGKILL)
process.Wait()
_ = process.Signal(syscall.SIGKILL)
_, _ = process.Wait()
return -1, err
}
}

View File

@ -239,12 +239,12 @@ func (r *runner) run(config *specs.Process) (int, error) {
r.destroy()
return -1, err
}
if err := startFn(process); err != nil {
if err = startFn(process); err != nil {
r.destroy()
return -1, err
}
if config.Terminal {
if err := tty.recvtty(process, r.detach || r.create); err != nil {
if err = tty.recvtty(process, r.detach || r.create); err != nil {
r.terminate(process)
r.destroy()
return -1, err
@ -284,13 +284,13 @@ func (r *runner) run(config *specs.Process) (int, error) {
}
}
if err := tty.ClosePostStart(); err != nil {
if err = tty.ClosePostStart(); err != nil {
r.terminate(process)
r.destroy()
return -1, err
}
if r.pidFile != "" {
if err := createPidFile(r.pidFile, process); err != nil {
if err = createPidFile(r.pidFile, process); err != nil {
r.terminate(process)
r.destroy()
return -1, err
@ -314,8 +314,8 @@ func (r *runner) destroy() {
}
func (r *runner) terminate(p *libcontainer.Process) {
p.Signal(syscall.SIGKILL)
p.Wait()
_ = p.Signal(syscall.SIGKILL)
_, _ = p.Wait()
}
func validateProcessSpec(spec *specs.Process) error {