Simplify error handling on function return

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
Mrunal Patel 2017-01-06 15:57:31 -08:00
parent 1a9dd2678d
commit 84a3bd250c
4 changed files with 4 additions and 17 deletions

5
ps.go
View File

@ -39,10 +39,7 @@ var psCommand = cli.Command{
}
if context.String("format") == "json" {
if err := json.NewEncoder(os.Stdout).Encode(pids); err != nil {
return err
}
return nil
return json.NewEncoder(os.Stdout).Encode(pids)
}
// [1:] is to remove command name, ex:

5
tty.go
View File

@ -108,10 +108,7 @@ func (t *tty) sendtty(socket *os.File, ti *libcontainer.TerminalInfo) error {
// Create a fake file to contain the terminal info.
console := os.NewFile(t.console.File().Fd(), ti.String())
if err := utils.SendFd(socket, console); err != nil {
return err
}
return nil
return utils.SendFd(socket, console)
}
// ClosePostStart closes any fds that are provided to the container and dup2'd

View File

@ -224,9 +224,6 @@ other options are ignored.
config.Cgroups.Resources.MemoryReservation = int64(*r.Memory.Reservation)
config.Cgroups.Resources.MemorySwap = int64(*r.Memory.Swap)
if err := container.Set(config); err != nil {
return err
}
return nil
return container.Set(config)
},
}

View File

@ -80,9 +80,5 @@ func revisePidFile(context *cli.Context) error {
if err != nil {
return err
}
err = context.Set("pid-file", pidFile)
if err != nil {
return err
}
return nil
return context.Set("pid-file", pidFile)
}