From 6056970e88cb0d5e6696abf7ae288c7fe2edfb53 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 28 Oct 2021 09:08:54 -0700 Subject: [PATCH] Fix errorlint warnings Errors returned from x/sys/unix are bare, so it's OK to compare directly. Fixes warnings like this one: > mount_unix.go:26:19: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint) > if err == nil || err == unix.EINVAL { > ^ Signed-off-by: Kir Kolyshkin --- mount/mount_unix.go | 2 +- mountinfo/mounted_linux.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mount/mount_unix.go b/mount/mount_unix.go index 1dc0deef..4053fbbe 100644 --- a/mount/mount_unix.go +++ b/mount/mount_unix.go @@ -23,7 +23,7 @@ func Mount(device, target, mType, options string) error { // a normal unmount. If target is not a mount point, no error is returned. func Unmount(target string) error { err := unix.Unmount(target, mntDetach) - if err == nil || err == unix.EINVAL { + if err == nil || err == unix.EINVAL { //nolint:errorlint // unix errors are bare // Ignore "not mounted" error here. Note the same error // can be returned if flags are invalid, so this code // assumes that the flags value is always correct. diff --git a/mountinfo/mounted_linux.go b/mountinfo/mounted_linux.go index ea3228f8..5c9e3e30 100644 --- a/mountinfo/mounted_linux.go +++ b/mountinfo/mounted_linux.go @@ -23,7 +23,7 @@ func mountedByOpenat2(path string) (bool, error) { Resolve: unix.RESOLVE_NO_XDEV, }) _ = unix.Close(dirfd) - switch err { + switch err { //nolint:errorlint // unix errors are bare case nil: // definitely not a mount _ = unix.Close(fd) return false, nil