From 84a3bd250c3529c5e487a961eaa67c2fb19e0690 Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Fri, 6 Jan 2017 15:57:31 -0800 Subject: [PATCH 1/2] Simplify error handling on function return Signed-off-by: Mrunal Patel --- ps.go | 5 +---- tty.go | 5 +---- update.go | 5 +---- utils.go | 6 +----- 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/ps.go b/ps.go index f285c22e6..228f161a0 100644 --- a/ps.go +++ b/ps.go @@ -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: diff --git a/tty.go b/tty.go index a32443424..0baed5a4b 100644 --- a/tty.go +++ b/tty.go @@ -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 diff --git a/update.go b/update.go index 1c1264409..cecd9986f 100644 --- a/update.go +++ b/update.go @@ -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) }, } diff --git a/utils.go b/utils.go index 8d30cfdff..ce610440d 100644 --- a/utils.go +++ b/utils.go @@ -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) } From 87d08d1ac2f3d562bc137e7d43d842b528224bd4 Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Fri, 6 Jan 2017 16:02:05 -0800 Subject: [PATCH 2/2] Simplify loop to a simple array append Signed-off-by: Mrunal Patel --- exec.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/exec.go b/exec.go index 4f37d24de..544d3de4c 100644 --- a/exec.go +++ b/exec.go @@ -178,9 +178,8 @@ func getProcess(context *cli.Context, bundle string) (*specs.Process, error) { p.Capabilities = caps } // append the passed env variables - for _, e := range context.StringSlice("env") { - p.Env = append(p.Env, e) - } + p.Env = append(p.Env, context.StringSlice("env")...) + // set the tty if context.IsSet("tty") { p.Terminal = context.Bool("tty")