diff options
author | Kir Kolyshkin <kolyshkin@gmail.com> | 2020-10-05 12:33:53 -0700 |
---|---|---|
committer | Kir Kolyshkin <kolyshkin@gmail.com> | 2020-10-05 15:30:37 -0700 |
commit | 4878dff3e2c89382699c29c10dc5036367275575 (patch) | |
tree | 5215fd4238ac12dc81af595d1ee3b174430769c5 /libpod/lock/file | |
parent | 1b16fcfd14b9e761849e53ac2b83c964ad8ac5a9 (diff) | |
download | podman-4878dff3e2c89382699c29c10dc5036367275575.tar.gz podman-4878dff3e2c89382699c29c10dc5036367275575.tar.bz2 podman-4878dff3e2c89382699c29c10dc5036367275575.zip |
Remove excessive error wrapping
In case os.Open[File], os.Mkdir[All], ioutil.ReadFile and the like
fails, the error message already contains the file name and the
operation that fails, so there is no need to wrap the error with
something like "open %s failed".
While at it
- replace a few places with os.Open, ioutil.ReadAll with
ioutil.ReadFile.
- replace errors.Wrapf with errors.Wrap for cases where there
are no %-style arguments.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Diffstat (limited to 'libpod/lock/file')
-rw-r--r-- | libpod/lock/file/file_lock.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libpod/lock/file/file_lock.go b/libpod/lock/file/file_lock.go index e50d67321..2643c9211 100644 --- a/libpod/lock/file/file_lock.go +++ b/libpod/lock/file/file_lock.go @@ -26,7 +26,7 @@ func CreateFileLock(path string) (*FileLocks, error) { return nil, errors.Wrapf(syscall.EEXIST, "directory %s exists", path) } if err := os.MkdirAll(path, 0711); err != nil { - return nil, errors.Wrapf(err, "cannot create %s", path) + return nil, err } locks := new(FileLocks) @@ -40,7 +40,7 @@ func CreateFileLock(path string) (*FileLocks, error) { func OpenFileLock(path string) (*FileLocks, error) { _, err := os.Stat(path) if err != nil { - return nil, errors.Wrapf(err, "accessing directory %s", path) + return nil, err } locks := new(FileLocks) @@ -84,7 +84,7 @@ func (locks *FileLocks) AllocateLock() (uint32, error) { if os.IsExist(err) { continue } - return 0, errors.Wrapf(err, "creating lock file") + return 0, errors.Wrap(err, "creating lock file") } f.Close() break |