summaryrefslogtreecommitdiff
path: root/libpod/runtime.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-01-13 13:01:45 +0100
committerValentin Rothberg <rothberg@redhat.com>2020-01-13 14:27:02 +0100
commit67165b76753f65b6f58d471f314678ae12a4c722 (patch)
tree72580ee08e5d9d2e57b97a7293deaf8a2a0f2e67 /libpod/runtime.go
parent270d892c3d77de4fd8e6341193175c0572fb5f99 (diff)
downloadpodman-67165b76753f65b6f58d471f314678ae12a4c722.tar.gz
podman-67165b76753f65b6f58d471f314678ae12a4c722.tar.bz2
podman-67165b76753f65b6f58d471f314678ae12a4c722.zip
make lint: enable gocritic
`gocritic` is a powerful linter that helps in preventing certain kinds of errors as well as enforcing a coding style. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r--libpod/runtime.go25
1 files changed, 10 insertions, 15 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index b4cbde28e..8dcec82db 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -180,12 +180,13 @@ func getLockManager(runtime *Runtime) (lock.Manager, error) {
// Set up the lock manager
manager, err = lock.OpenSHMLockManager(lockPath, runtime.config.NumLocks)
if err != nil {
- if os.IsNotExist(errors.Cause(err)) {
+ switch {
+ case os.IsNotExist(errors.Cause(err)):
manager, err = lock.NewSHMLockManager(lockPath, runtime.config.NumLocks)
if err != nil {
return nil, errors.Wrapf(err, "failed to get new shm lock manager")
}
- } else if errors.Cause(err) == syscall.ERANGE && runtime.doRenumber {
+ case errors.Cause(err) == syscall.ERANGE && runtime.doRenumber:
logrus.Debugf("Number of locks does not match - removing old locks")
// ERANGE indicates a lock numbering mismatch.
@@ -199,7 +200,7 @@ func getLockManager(runtime *Runtime) (lock.Manager, error) {
if err != nil {
return nil, err
}
- } else {
+ default:
return nil, err
}
}
@@ -289,10 +290,8 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (err error) {
logrus.Debug("Not configuring container store")
} else if runtime.noStore {
logrus.Debug("No store required. Not opening container store.")
- } else {
- if err := runtime.configureStore(); err != nil {
- return err
- }
+ } else if err := runtime.configureStore(); err != nil {
+ return err
}
defer func() {
if err != nil && store != nil {
@@ -718,18 +717,14 @@ func (r *Runtime) generateName() (string, error) {
// Make sure container with this name does not exist
if _, err := r.state.LookupContainer(name); err == nil {
continue
- } else {
- if errors.Cause(err) != define.ErrNoSuchCtr {
- return "", err
- }
+ } else if errors.Cause(err) != define.ErrNoSuchCtr {
+ return "", err
}
// Make sure pod with this name does not exist
if _, err := r.state.LookupPod(name); err == nil {
continue
- } else {
- if errors.Cause(err) != define.ErrNoSuchPod {
- return "", err
- }
+ } else if errors.Cause(err) != define.ErrNoSuchPod {
+ return "", err
}
return name, nil
}