Skip to content

Commit

Permalink
Fix errorlint warnings
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
kolyshkin committed Nov 3, 2021
1 parent d8b4e64 commit 6056970
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mount/mount_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion mountinfo/mounted_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6056970

Please sign in to comment.