From 4878dff3e2c89382699c29c10dc5036367275575 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 5 Oct 2020 12:33:53 -0700 Subject: 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 --- libpod/lock/file/file_lock.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libpod/lock') 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 -- cgit v1.2.3-54-g00ecf