mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
return directly without ifs in remaining packages
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
This commit is contained in:
parent
8415aeb39a
commit
2c187a24e0
11 changed files with 16 additions and 52 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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{}) {
|
||||
|
|
|
@ -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",
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -623,10 +623,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
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue