diff --git a/api/server/httputils/form.go b/api/server/httputils/form.go index 20188c12d8..280e1c1765 100644 --- a/api/server/httputils/form.go +++ b/api/server/httputils/form.go @@ -38,10 +38,7 @@ func Int64ValueOrZero(r *http.Request, k string) int64 { func Int64ValueOrDefault(r *http.Request, field string, def int64) (int64, error) { if r.Form.Get(field) != "" { value, err := strconv.ParseInt(r.Form.Get(field), 10, 64) - if err != nil { - return value, err - } - return value, nil + return value, err } return def, nil } diff --git a/api/server/router/container/copy.go b/api/server/router/container/copy.go index ede6dff92c..72d8c4a679 100644 --- a/api/server/router/container/copy.go +++ b/api/server/router/container/copy.go @@ -50,11 +50,8 @@ func (s *containerRouter) postContainersCopy(ctx context.Context, w http.Respons defer data.Close() w.Header().Set("Content-Type", "application/x-tar") - if _, err := io.Copy(w, data); err != nil { - return err - } - - return nil + _, err = io.Copy(w, data) + return err } // // Encode the stat to JSON, base64 encode, and place in a header. diff --git a/cli/command/task/print.go b/cli/command/task/print.go index 0f1c2cf724..57c4e0c8c8 100644 --- a/cli/command/task/print.go +++ b/cli/command/task/print.go @@ -70,11 +70,7 @@ func Print(dockerCli *command.DockerCli, ctx context.Context, tasks []swarm.Task defer writer.Flush() fmt.Fprintln(writer, strings.Join([]string{"ID", "NAME", "IMAGE", "NODE", "DESIRED STATE", "CURRENT STATE", "ERROR", "PORTS"}, "\t")) - if err := print(writer, ctx, tasks, resolver, noTrunc); err != nil { - return err - } - - return nil + return print(writer, ctx, tasks, resolver, noTrunc) } // PrintQuiet shows task list in a quiet way. diff --git a/cmd/dockerd/service_windows.go b/cmd/dockerd/service_windows.go index 7ad7e389d8..9ecf3788ea 100644 --- a/cmd/dockerd/service_windows.go +++ b/cmd/dockerd/service_windows.go @@ -219,12 +219,7 @@ func registerService() error { return err } - err = eventlog.Install(*flServiceName, p, false, eventlog.Info|eventlog.Warning|eventlog.Error) - if err != nil { - return err - } - - return nil + return eventlog.Install(*flServiceName, p, false, eventlog.Info|eventlog.Warning|eventlog.Error) } func unregisterService() error { diff --git a/image/tarexport/save.go b/image/tarexport/save.go index 7cc3a8dddd..1ae931b8d2 100644 --- a/image/tarexport/save.go +++ b/image/tarexport/save.go @@ -215,10 +215,8 @@ func (s *saveSession) save(outStream io.Writer) error { } defer fs.Close() - if _, err := io.Copy(outStream, fs); err != nil { - return err - } - return nil + _, err = io.Copy(outStream, fs) + return err } func (s *saveSession) saveImage(id image.ID) (map[layer.DiffID]distribution.Descriptor, error) { diff --git a/integration-cli/docker_cli_external_volume_driver_unix_test.go b/integration-cli/docker_cli_external_volume_driver_unix_test.go index 466d376d95..9b13647a1b 100644 --- a/integration-cli/docker_cli_external_volume_driver_unix_test.go +++ b/integration-cli/docker_cli_external_volume_driver_unix_test.go @@ -103,10 +103,8 @@ func newVolumePlugin(c *check.C, name string) *volumePlugin { read := func(b io.ReadCloser) (pluginRequest, error) { defer b.Close() var pr pluginRequest - if err := json.NewDecoder(b).Decode(&pr); err != nil { - return pr, err - } - return pr, nil + err := json.NewDecoder(b).Decode(&pr) + return pr, err } send := func(w http.ResponseWriter, data interface{}) { diff --git a/integration-cli/requirements.go b/integration-cli/requirements.go index abddb9fe4f..6eb56b7e80 100644 --- a/integration-cli/requirements.go +++ b/integration-cli/requirements.go @@ -180,10 +180,7 @@ var ( defer f.Close() b := make([]byte, 1) _, _ = f.Read(b) - if string(b) == "N" { - return false - } - return true + return string(b) != "N" } return true @@ -193,10 +190,7 @@ var ( NotUserNamespace = testRequirement{ func() bool { root := os.Getenv("DOCKER_REMAP_ROOT") - if root != "" { - return false - } - return true + return root == "" }, "Test cannot be run when remapping root", } diff --git a/migrate/v1/migratev1.go b/migrate/v1/migratev1.go index bc42dd2ca4..54c1817e87 100644 --- a/migrate/v1/migratev1.go +++ b/migrate/v1/migratev1.go @@ -195,10 +195,7 @@ func saveMappings(root string, mappings map[string]image.ID) error { return err } defer f.Close() - if err := json.NewEncoder(f).Encode(mappings); err != nil { - return err - } - return nil + return json.NewEncoder(f).Encode(mappings) } func migrateImages(root string, ls graphIDRegistrar, is image.Store, ms metadata.Store, mappings map[string]image.ID) error { diff --git a/plugin/manager.go b/plugin/manager.go index aeb7cd7bca..dcf5ce1984 100644 --- a/plugin/manager.go +++ b/plugin/manager.go @@ -79,10 +79,7 @@ func Init(root string, ps *store.Store, remote libcontainerd.Remote, rs registry return err } manager.cMap = make(map[*v2.Plugin]*controller) - if err := manager.reload(); err != nil { - return err - } - return nil + return manager.reload() } // StateChanged updates plugin internals using libcontainerd events. diff --git a/runconfig/opts/parse.go b/runconfig/opts/parse.go index 71a89277ec..efdfa02c4c 100644 --- a/runconfig/opts/parse.go +++ b/runconfig/opts/parse.go @@ -859,10 +859,8 @@ func ParseLink(val string) (string, string, error) { // ValidateLink validates that the specified string has a valid link format (containerName:alias). func ValidateLink(val string) (string, error) { - if _, _, err := ParseLink(val); err != nil { - return val, err - } - return val, nil + _, _, err := ParseLink(val) + return val, err } // ValidDeviceMode checks if the mode for device is valid or not. diff --git a/volume/store/store.go b/volume/store/store.go index ab175238a7..ef7b2b971b 100644 --- a/volume/store/store.go +++ b/volume/store/store.go @@ -620,10 +620,7 @@ func (s *VolumeStore) FilterByUsed(vols []volume.Volume, used bool) []volume.Vol s.locks.Lock(v.Name()) hasRef := s.hasRef(v.Name()) s.locks.Unlock(v.Name()) - if used == hasRef { - return true - } - return false + return used == hasRef }) }