daemon: return directly without ifs where possible

Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
This commit is contained in:
unclejack 2016-12-14 22:36:58 +02:00
parent 8415aeb39a
commit 3a42518042
6 changed files with 10 additions and 36 deletions

View file

@ -204,10 +204,7 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes.
w, err := verifyContainerResources(&hostConfig.Resources, hyperv)
warnings = append(warnings, w...)
if err != nil {
return warnings, err
}
return warnings, nil
return warnings, err
}
// platformReload update configuration with platform specific options

View file

@ -380,10 +380,7 @@ func (devices *DeviceSet) isDeviceIDFree(deviceID int) bool {
var mask byte
i := deviceID % 8
mask = (1 << uint(i))
if (devices.deviceIDMap[deviceID/8] & mask) != 0 {
return false
}
return true
return (devices.deviceIDMap[deviceID/8] & mask) == 0
}
// Should be called with devices.Lock() held.
@ -1400,10 +1397,7 @@ func (devices *DeviceSet) saveTransactionMetaData() error {
}
func (devices *DeviceSet) removeTransactionMetaData() error {
if err := os.RemoveAll(devices.transactionMetaFile()); err != nil {
return err
}
return nil
return os.RemoveAll(devices.transactionMetaFile())
}
func (devices *DeviceSet) rollbackTransaction() error {
@ -2408,11 +2402,7 @@ func (devices *DeviceSet) UnmountDevice(hash, mountPath string) error {
}
logrus.Debug("devmapper: Unmount done")
if err := devices.deactivateDevice(info); err != nil {
return err
}
return nil
return devices.deactivateDevice(info)
}
// HasDevice returns true if the device metadata exists.

View file

@ -775,11 +775,7 @@ func (d *Driver) resolveID(id string) (string, error) {
// setID stores the layerId in disk.
func (d *Driver) setID(id, altID string) error {
err := ioutil.WriteFile(filepath.Join(d.dir(id), "layerId"), []byte(altID), 0600)
if err != nil {
return err
}
return nil
return ioutil.WriteFile(filepath.Join(d.dir(id), "layerId"), []byte(altID), 0600)
}
// getLayerChain returns the layer chain information.

View file

@ -155,8 +155,5 @@ func callEventWriteString(message string) error {
func callEventUnregister() bool {
ret, _, _ := procEventUnregister.Call(uintptr(providerHandle))
if ret != win32CallSuccess {
return false
}
return true
return ret == win32CallSuccess
}

View file

@ -182,11 +182,8 @@ func ValidateLogOpt(cfg map[string]string) error {
}
}
if _, err := parseAddress(cfg["fluentd-address"]); err != nil {
return err
}
return nil
_, err := parseAddress(cfg["fluentd-address"])
return err
}
func parseAddress(address string) (*location, error) {

View file

@ -172,11 +172,8 @@ func ValidateLogOpt(cfg map[string]string) error {
}
}
if _, err := parseAddress(cfg["gelf-address"]); err != nil {
return err
}
return nil
_, err := parseAddress(cfg["gelf-address"])
return err
}
func parseAddress(address string) (string, error) {