diff options
Diffstat (limited to 'pkg/errors')
-rw-r--r-- | pkg/errors/linuxerr/BUILD | 4 | ||||
-rw-r--r-- | pkg/errors/linuxerr/linuxerr.go | 8 | ||||
-rw-r--r-- | pkg/errors/linuxerr/linuxerr_test.go | 2 |
3 files changed, 11 insertions, 3 deletions
diff --git a/pkg/errors/linuxerr/BUILD b/pkg/errors/linuxerr/BUILD index 201727780..f99544afd 100644 --- a/pkg/errors/linuxerr/BUILD +++ b/pkg/errors/linuxerr/BUILD @@ -4,7 +4,9 @@ package(licenses = ["notice"]) go_library( name = "linuxerr", - srcs = ["linuxerr.go"], + srcs = [ + "linuxerr.go", + ], visibility = ["//visibility:public"], deps = [ "//pkg/abi/linux/errno", diff --git a/pkg/errors/linuxerr/linuxerr.go b/pkg/errors/linuxerr/linuxerr.go index f9f8412e0..5905ef593 100644 --- a/pkg/errors/linuxerr/linuxerr.go +++ b/pkg/errors/linuxerr/linuxerr.go @@ -27,6 +27,12 @@ import ( const maxErrno uint32 = errno.EHWPOISON + 1 +// The following errors are semantically identical to Errno of type unix.Errno +// or sycall.Errno. However, since the type are distinct ( these are +// *errors.Error), they are not directly comperable. However, the Errno method +// returns an Errno number such that the error can be compared to unix/syscall.Errno +// (e.g. unix.Errno(EPERM.Errno()) == unix.EPERM is true). Converting unix/syscall.Errno +// to the errors should be done via the lookup methods provided. var ( NOERROR = errors.New(errno.NOERRNO, "not an error") EPERM = errors.New(errno.EPERM, "operation not permitted") @@ -177,7 +183,7 @@ var ( var errNotValidError = errors.New(errno.Errno(maxErrno), "not a valid error") // The following errorSlice holds errors by errno for fast translation between -// errnos (especially uint32(sycall.Errno)) and *Error. +// errnos (especially uint32(sycall.Errno)) and *errors.Error. var errorSlice = []*errors.Error{ // Errno values from include/uapi/asm-generic/errno-base.h. errno.NOERRNO: NOERROR, diff --git a/pkg/errors/linuxerr/linuxerr_test.go b/pkg/errors/linuxerr/linuxerr_test.go index f09d61b02..5390c8a12 100644 --- a/pkg/errors/linuxerr/linuxerr_test.go +++ b/pkg/errors/linuxerr/linuxerr_test.go @@ -115,7 +115,7 @@ func BenchmarkSwitchSyserror(b *testing.B) { switch globalError { case linuxerr.EACCES: j++ - case syserror.EINTR: + case linuxerr.EINTR: j += 2 case linuxerr.EAGAIN: j += 3 |