From 7c138ebbeed3981e9f94232aa0d84bd5aed2226e Mon Sep 17 00:00:00 2001 From: boucher Date: Mon, 4 May 2015 11:25:43 -0700 Subject: [PATCH] Reformat some error handling code and declare descriptor filename as a const. Docker-DCO-1.1-Signed-off-by: Ross Boucher (github: boucher) --- container_linux.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/container_linux.go b/container_linux.go index 8f8de127..37e094f8 100644 --- a/container_linux.go +++ b/container_linux.go @@ -288,6 +288,8 @@ func (c *linuxContainer) checkCriuVersion() error { return nil } +const descriptors_filename = "descriptors.json" + func (c *linuxContainer) Checkpoint(criuOpts *CriuOpts) error { c.m.Lock() defer c.m.Unlock() @@ -376,7 +378,7 @@ func (c *linuxContainer) Checkpoint(criuOpts *CriuOpts) error { return err } - err = ioutil.WriteFile(filepath.Join(criuOpts.ImagesDirectory, "std_fds.json"), fdsJSON, 0655) + err = ioutil.WriteFile(filepath.Join(criuOpts.ImagesDirectory, descriptors_filename), fdsJSON, 0655) if err != nil { return err } @@ -490,14 +492,16 @@ func (c *linuxContainer) Restore(process *Process, criuOpts *CriuOpts) error { } } - var fds []string - fdJSON, err := ioutil.ReadFile(filepath.Join(criuOpts.ImagesDirectory, "std_fds.json")) - if err != nil { + var ( + fds []string + fdJSON []byte + ) + + if fdJSON, err = ioutil.ReadFile(filepath.Join(criuOpts.ImagesDirectory, descriptors_filename)); err != nil { return err } - err = json.Unmarshal(fdJSON, &fds) - if err != nil { + if err = json.Unmarshal(fdJSON, &fds); err != nil { return err }