Merge pull request #29422 from unclejack/daemon_return_directly
daemon: return directly without ifs where possible
This commit is contained in:
commit
6e6016f581
6 changed files with 10 additions and 36 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue