diff options
author | Sebastiaan van Stijn <github@gone.nl> | 2018-01-15 00:42:25 +0100 |
---|---|---|
committer | Sebastiaan van Stijn <github@gone.nl> | 2018-01-15 00:42:25 +0100 |
commit | b4a63139696aea2c73ec361a9af8b36a118f0423 (patch) | |
tree | 60618aa0c95589570e08a01024c06e61a06de1e8 | |
parent | 63a0e88e8a61b5c0d5f698d5baf37f568ee01d50 (diff) | |
download | docker-b4a63139696aea2c73ec361a9af8b36a118f0423.tar.gz |
Golint: remove redundant ifs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
27 files changed, 35 insertions, 161 deletions
diff --git a/builder/fscache/fscache.go b/builder/fscache/fscache.go index 7cb4c5cbe9..679d5e457e 100644 --- a/builder/fscache/fscache.go +++ b/builder/fscache/fscache.go @@ -485,10 +485,7 @@ func (s *fsCacheStore) delete(id string) error { }); err != nil { return err } - if err := s.fs.Remove(src.BackendID); err != nil { - return err - } - return nil + return s.fs.Remove(src.BackendID) } type sourceMeta struct { diff --git a/container/view.go b/container/view.go index 913d9e7470..2d178e1888 100644 --- a/container/view.go +++ b/container/view.go @@ -14,9 +14,8 @@ import ( ) const ( - memdbContainersTable = "containers" - memdbNamesTable = "names" - + memdbContainersTable = "containers" + memdbNamesTable = "names" memdbIDIndex = "id" memdbContainerIDIndex = "containerid" ) @@ -191,11 +190,7 @@ func (db *memDB) ReserveName(name, containerID string) error { } return nil } - - if err := txn.Insert(memdbNamesTable, nameAssociation{name: name, containerID: containerID}); err != nil { - return err - } - return nil + return txn.Insert(memdbNamesTable, nameAssociation{name: name, containerID: containerID}) }) } diff --git a/daemon/cluster/executor/container/adapter.go b/daemon/cluster/executor/container/adapter.go index 7db47983cb..9ba64c486a 100644 --- a/daemon/cluster/executor/container/adapter.go +++ b/daemon/cluster/executor/container/adapter.go @@ -262,11 +262,7 @@ func (c *containerAdapter) create(ctx context.Context) error { return err } - if err := c.backend.UpdateContainerServiceConfig(cr.ID, c.container.serviceConfig()); err != nil { - return err - } - - return nil + return c.backend.UpdateContainerServiceConfig(cr.ID, c.container.serviceConfig()) } // checkMounts ensures that the provided mounts won't have any host-specific diff --git a/daemon/config/config.go b/daemon/config/config.go index 199fae6cf1..e3ed530028 100644 --- a/daemon/config/config.go +++ b/daemon/config/config.go @@ -511,11 +511,7 @@ func Validate(config *Config) error { } // validate platform-specific settings - if err := config.ValidatePlatformConfig(); err != nil { - return err - } - - return nil + return config.ValidatePlatformConfig() } // ModifiedDiscoverySettings returns whether the discovery configuration has been modified or not. diff --git a/daemon/daemon.go b/daemon/daemon.go index dd8c100c83..98d395d3dc 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -1046,11 +1046,7 @@ func (daemon *Daemon) Shutdown() error { daemon.netController.Stop() } - if err := daemon.cleanupMounts(); err != nil { - return err - } - - return nil + return daemon.cleanupMounts() } // Mount sets container.BaseFS diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index 51ea7c774f..82e721fe61 100644 --- a/daemon/daemon_unix.go +++ b/daemon/daemon_unix.go @@ -1501,10 +1501,7 @@ func (daemon *Daemon) initCgroupsPath(path string) error { if err := maybeCreateCPURealTimeFile(sysinfo.CPURealtimePeriod, daemon.configStore.CPURealtimePeriod, "cpu.rt_period_us", path); err != nil { return err } - if err := maybeCreateCPURealTimeFile(sysinfo.CPURealtimeRuntime, daemon.configStore.CPURealtimeRuntime, "cpu.rt_runtime_us", path); err != nil { - return err - } - return nil + return maybeCreateCPURealTimeFile(sysinfo.CPURealtimeRuntime, daemon.configStore.CPURealtimeRuntime, "cpu.rt_runtime_us", path) } func maybeCreateCPURealTimeFile(sysinfoPresent bool, configValue int64, file string, path string) error { diff --git a/daemon/graphdriver/aufs/aufs.go b/daemon/graphdriver/aufs/aufs.go index 248b8bf88d..f019e95558 100644 --- a/daemon/graphdriver/aufs/aufs.go +++ b/daemon/graphdriver/aufs/aufs.go @@ -579,10 +579,7 @@ func (a *Driver) unmount(mountPath string) error { if mounted, err := a.mounted(mountPath); err != nil || !mounted { return err } - if err := Unmount(mountPath); err != nil { - return err - } - return nil + return Unmount(mountPath) } func (a *Driver) mounted(mountpoint string) (bool, error) { diff --git a/daemon/graphdriver/aufs/mount.go b/daemon/graphdriver/aufs/mount.go index 100e7537a9..8198f95a89 100644 --- a/daemon/graphdriver/aufs/mount.go +++ b/daemon/graphdriver/aufs/mount.go @@ -14,8 +14,5 @@ func Unmount(target string) error { if err := exec.Command("auplink", target, "flush").Run(); err != nil { logrus.Warnf("Couldn't run auplink before unmount %s: %s", target, err) } - if err := unix.Unmount(target, 0); err != nil { - return err - } - return nil + return unix.Unmount(target, 0) } diff --git a/daemon/graphdriver/btrfs/btrfs.go b/daemon/graphdriver/btrfs/btrfs.go index 57313c94c6..d4b9b89124 100644 --- a/daemon/graphdriver/btrfs/btrfs.go +++ b/daemon/graphdriver/btrfs/btrfs.go @@ -598,16 +598,10 @@ func (d *Driver) setStorageSize(dir string, driver *Driver) error { if d.options.minSpace > 0 && driver.options.size < d.options.minSpace { return fmt.Errorf("btrfs: storage size cannot be less than %s", units.HumanSize(float64(d.options.minSpace))) } - if err := d.subvolEnableQuota(); err != nil { return err } - - if err := subvolLimitQgroup(dir, driver.options.size); err != nil { - return err - } - - return nil + return subvolLimitQgroup(dir, driver.options.size) } // Remove the filesystem with given id. @@ -634,10 +628,7 @@ func (d *Driver) Remove(id string) error { if err := system.EnsureRemoveAll(dir); err != nil { return err } - if err := d.subvolRescanQuota(); err != nil { - return err - } - return nil + return d.subvolRescanQuota() } // Get the requested filesystem id. diff --git a/daemon/graphdriver/copy/copy.go b/daemon/graphdriver/copy/copy.go index 7a98bec8ba..78518e8169 100644 --- a/daemon/graphdriver/copy/copy.go +++ b/daemon/graphdriver/copy/copy.go @@ -273,8 +273,5 @@ func doCopyXattrs(srcPath, dstPath string) error { // this function is used to copy those. It is set by overlay if a directory // is removed and then re-created and should not inherit anything from the // same dir in the lower dir. - if err := copyXattr(srcPath, dstPath, "trusted.overlay.opaque"); err != nil { - return err - } - return nil + return copyXattr(srcPath, dstPath, "trusted.overlay.opaque") } diff --git a/daemon/graphdriver/devmapper/device_setup.go b/daemon/graphdriver/devmapper/device_setup.go index 30463f23a2..ad61423651 100644 --- a/daemon/graphdriver/devmapper/device_setup.go +++ b/daemon/graphdriver/devmapper/device_setup.go @@ -129,15 +129,10 @@ func verifyBlockDevice(dev string, force bool) error { if err := checkDevInVG(dev); err != nil { return err } - if force { return nil } - - if err := checkDevHasFS(dev); err != nil { - return err - } - return nil + return checkDevHasFS(dev) } func readLVMConfig(root string) (directLVMConfig, error) { diff --git a/daemon/graphdriver/devmapper/deviceset.go b/daemon/graphdriver/devmapper/deviceset.go index 6659878bc6..4e850f0863 100644 --- a/daemon/graphdriver/devmapper/deviceset.go +++ b/daemon/graphdriver/devmapper/deviceset.go @@ -355,10 +355,7 @@ func (devices *DeviceSet) saveMetadata(info *devInfo) error { if err != nil { return fmt.Errorf("devmapper: Error encoding metadata to json: %s", err) } - if err := devices.writeMetaFile(jsonData, devices.metadataFile(info)); err != nil { - return err - } - return nil + return devices.writeMetaFile(jsonData, devices.metadataFile(info)) } func (devices *DeviceSet) markDeviceIDUsed(deviceID int) { @@ -889,11 +886,7 @@ func (devices *DeviceSet) takeSnapshot(hash string, baseInfo *devInfo, size uint defer devicemapper.ResumeDevice(baseInfo.Name()) } - if err = devices.createRegisterSnapDevice(hash, baseInfo, size); err != nil { - return err - } - - return nil + return devices.createRegisterSnapDevice(hash, baseInfo, size) } func (devices *DeviceSet) createRegisterSnapDevice(hash string, baseInfo *devInfo, size uint64) error { @@ -1233,12 +1226,7 @@ func (devices *DeviceSet) setupBaseImage() error { if err := devices.setupVerifyBaseImageUUIDFS(oldInfo); err != nil { return err } - - if err := devices.checkGrowBaseDeviceFS(oldInfo); err != nil { - return err - } - - return nil + return devices.checkGrowBaseDeviceFS(oldInfo) } logrus.Debug("devmapper: Removing uninitialized base image") @@ -1259,11 +1247,7 @@ func (devices *DeviceSet) setupBaseImage() error { } // Create new base image device - if err := devices.createBaseImage(); err != nil { - return err - } - - return nil + return devices.createBaseImage() } func setCloseOnExec(name string) { @@ -2082,11 +2066,7 @@ func (devices *DeviceSet) deleteDevice(info *devInfo, syncDelete bool) error { return err } - if err := devices.deleteTransaction(info, syncDelete); err != nil { - return err - } - - return nil + return devices.deleteTransaction(info, syncDelete) } // DeleteDevice will return success if device has been marked for deferred diff --git a/daemon/graphdriver/devmapper/driver.go b/daemon/graphdriver/devmapper/driver.go index 707094af3a..ab75974a98 100644 --- a/daemon/graphdriver/devmapper/driver.go +++ b/daemon/graphdriver/devmapper/driver.go @@ -146,12 +146,7 @@ func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error { if opts != nil { storageOpt = opts.StorageOpt } - - if err := d.DeviceSet.AddDevice(id, parent, storageOpt); err != nil { - return err - } - - return nil + return d.DeviceSet.AddDevice(id, parent, storageOpt) } // Remove removes a device with a given id, unmounts the filesystem. diff --git a/daemon/graphdriver/graphtest/testutil.go b/daemon/graphdriver/graphtest/testutil.go index 946313296b..c1ef1162b8 100644 --- a/daemon/graphdriver/graphtest/testutil.go +++ b/daemon/graphdriver/graphtest/testutil.go @@ -263,11 +263,7 @@ func addLayerFiles(drv graphdriver.Driver, layer, parent string, i int) error { if err := driver.WriteFile(root, root.Join(layerDir, "layer-id"), []byte(layer), 0755); err != nil { return err } - if err := driver.WriteFile(root, root.Join(layerDir, "parent-id"), []byte(parent), 0755); err != nil { - return err - } - - return nil + return driver.WriteFile(root, root.Join(layerDir, "parent-id"), []byte(parent), 0755) } func addManyLayers(drv graphdriver.Driver, baseLayer string, count int) (string, error) { diff --git a/daemon/graphdriver/overlay/overlay.go b/daemon/graphdriver/overlay/overlay.go index bcb21d87e4..e2789aff6d 100644 --- a/daemon/graphdriver/overlay/overlay.go +++ b/daemon/graphdriver/overlay/overlay.go @@ -309,10 +309,7 @@ func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) (retErr if err := idtools.MkdirAndChown(path.Join(dir, "work"), 0700, root); err != nil { return err } - if err := ioutil.WriteFile(path.Join(dir, "lower-id"), []byte(parent), 0666); err != nil { - return err - } - return nil + return ioutil.WriteFile(path.Join(dir, "lower-id"), []byte(parent), 0666) } // Otherwise, copy the upper and the lower-id from the parent diff --git a/daemon/pause.go b/daemon/pause.go index b751cc4880..0b2ff1d2ed 100644 --- a/daemon/pause.go +++ b/daemon/pause.go @@ -14,12 +14,7 @@ func (daemon *Daemon) ContainerPause(name string) error { if err != nil { return err } - - if err := daemon.containerPause(container); err != nil { - return err - } - - return nil + return daemon.containerPause(container) } // containerPause pauses the container execution without stopping the process. diff --git a/daemon/start.go b/daemon/start.go index 3b9f0f9f63..7f9d682f02 100644 --- a/daemon/start.go +++ b/daemon/start.go @@ -90,11 +90,7 @@ func (daemon *Daemon) ContainerStart(name string, hostConfig *containertypes.Hos return validationError{err} } } - - if err := daemon.containerStart(container, checkpoint, checkpointDir, true); err != nil { - return err - } - return nil + return daemon.containerStart(container, checkpoint, checkpointDir, true) } // containerStart prepares the container to run by setting up everything the diff --git a/daemon/unpause.go b/daemon/unpause.go index 2e41f2070b..b29a1f68da 100644 --- a/daemon/unpause.go +++ b/daemon/unpause.go @@ -14,12 +14,7 @@ func (daemon *Daemon) ContainerUnpause(name string) error { if err != nil { return err } - - if err := daemon.containerUnpause(container); err != nil { - return err - } - - return nil + return daemon.containerUnpause(container) } // containerUnpause resumes the container execution after the container is paused. diff --git a/image/fs.go b/image/fs.go index 92cdb2662a..68e052926d 100644 --- a/image/fs.go +++ b/image/fs.go @@ -133,10 +133,7 @@ func (s *fs) Delete(dgst digest.Digest) error { if err := os.RemoveAll(s.metadataDir(dgst)); err != nil { return err } - if err := os.Remove(s.contentFile(dgst)); err != nil { - return err - } - return nil + return os.Remove(s.contentFile(dgst)) } // SetMetadata sets metadata for a given ID. It fails if there's no base file. diff --git a/integration-cli/daemon/daemon.go b/integration-cli/daemon/daemon.go index f6ad6559b2..62150a1d28 100644 --- a/integration-cli/daemon/daemon.go +++ b/integration-cli/daemon/daemon.go @@ -348,11 +348,7 @@ func (d *Daemon) Kill() error { return err } - if err := os.Remove(fmt.Sprintf("%s/docker.pid", d.Folder)); err != nil { - return err - } - - return nil + return os.Remove(fmt.Sprintf("%s/docker.pid", d.Folder)) } // Pid returns the pid of the daemon @@ -459,11 +455,7 @@ out2: d.cmd.Wait() - if err := os.Remove(fmt.Sprintf("%s/docker.pid", d.Folder)); err != nil { - return err - } - - return nil + return os.Remove(fmt.Sprintf("%s/docker.pid", d.Folder)) } // Restart will restart the daemon by first stopping it and the starting it. diff --git a/integration-cli/docker_api_network_test.go b/integration-cli/docker_api_network_test.go index 2cdd2627af..f0c26e2d94 100644 --- a/integration-cli/docker_api_network_test.go +++ b/integration-cli/docker_api_network_test.go @@ -328,9 +328,8 @@ func createNetwork(c *check.C, config types.NetworkCreateRequest, expectedStatus c.Assert(err, checker.IsNil) return nr.ID - } else { - return "" } + return "" } func connectNetwork(c *check.C, nid, cid string) { diff --git a/layer/layer_test.go b/layer/layer_test.go index f632d44b90..f682035ce1 100644 --- a/layer/layer_test.go +++ b/layer/layer_test.go @@ -153,10 +153,7 @@ func (tf *testFile) ApplyFile(root containerfs.ContainerFS) error { return err } } - if err := driver.WriteFile(root, fullPath, tf.content, tf.permission); err != nil { - return err - } - return nil + return driver.WriteFile(root, fullPath, tf.content, tf.permission) } func initWithFiles(files ...FileApplier) layerInit { diff --git a/layer/migration.go b/layer/migration.go index f4c4adec4a..9c0c2c94ed 100644 --- a/layer/migration.go +++ b/layer/migration.go @@ -68,11 +68,7 @@ func (ls *layerStore) CreateRWLayerByGraphID(name string, graphID string, parent m.initID = initID } - if err = ls.saveMount(m); err != nil { - return err - } - - return nil + return ls.saveMount(m) } func (ls *layerStore) ChecksumForGraphID(id, parent, oldTarDataPath, newTarDataPath string) (diffID DiffID, size int64, err error) { diff --git a/layer/ro_layer.go b/layer/ro_layer.go index f634194b89..ca3e1189f3 100644 --- a/layer/ro_layer.go +++ b/layer/ro_layer.go @@ -143,11 +143,7 @@ func storeLayer(tx MetadataTransaction, layer *roLayer) error { return err } } - if err := tx.SetOS(layer.os); err != nil { - return err - } - - return nil + return tx.SetOS(layer.os) } func newVerifiedReadCloser(rc io.ReadCloser, dgst digest.Digest) (io.ReadCloser, error) { diff --git a/migrate/v1/migratev1.go b/migrate/v1/migratev1.go index 60dbfe0787..02fcd2c2cb 100644 --- a/migrate/v1/migratev1.go +++ b/migrate/v1/migratev1.go @@ -89,11 +89,7 @@ func Migrate(root, driverName string, ls layer.Store, is image.Store, rs refstor return err } - if err := migrateRefs(root, driverName, rs, mappings); err != nil { - return err - } - - return nil + return migrateRefs(root, driverName, rs, mappings) } // CalculateLayerChecksums walks an old graph directory and calculates checksums diff --git a/migrate/v1/migratev1_test.go b/migrate/v1/migratev1_test.go index 122a0805a3..bab176fe3c 100644 --- a/migrate/v1/migratev1_test.go +++ b/migrate/v1/migratev1_test.go @@ -323,10 +323,7 @@ func addContainer(dest, jsonConfig string) error { if err := os.MkdirAll(contDir, 0700); err != nil { return err } - if err := ioutil.WriteFile(filepath.Join(contDir, "config.json"), []byte(jsonConfig), 0600); err != nil { - return err - } - return nil + return ioutil.WriteFile(filepath.Join(contDir, "config.json"), []byte(jsonConfig), 0600) } type mockTagAdder struct { diff --git a/pkg/system/chtimes.go b/pkg/system/chtimes.go index 056d19954d..18378f1cae 100644 --- a/pkg/system/chtimes.go +++ b/pkg/system/chtimes.go @@ -27,9 +27,5 @@ func Chtimes(name string, atime time.Time, mtime time.Time) error { } // Take platform specific action for setting create time. - if err := setCTime(name, mtime); err != nil { - return err - } - - return nil + return setCTime(name, mtime) } |