Commit c71b2cbf authored by Aaron Jacobs's avatar Aaron Jacobs

Fixed two bugs.

parent c3601bff
...@@ -46,7 +46,7 @@ type FS interface { ...@@ -46,7 +46,7 @@ type FS interface {
func New() (fs FS, err error) { func New() (fs FS, err error) {
fs = &errorFS{ fs = &errorFS{
errors: make(map[string]syscall.Errno), errors: make(map[reflect.Type]syscall.Errno),
} }
return return
...@@ -57,10 +57,8 @@ type errorFS struct { ...@@ -57,10 +57,8 @@ type errorFS struct {
mu sync.Mutex mu sync.Mutex
// Keys are reflect.Type.Name strings.
//
// GUARDED_BY(mu) // GUARDED_BY(mu)
errors map[string]syscall.Errno errors map[reflect.Type]syscall.Errno
} }
// LOCKS_EXCLUDED(fs.mu) // LOCKS_EXCLUDED(fs.mu)
...@@ -68,7 +66,7 @@ func (fs *errorFS) SetError(t reflect.Type, err syscall.Errno) { ...@@ -68,7 +66,7 @@ func (fs *errorFS) SetError(t reflect.Type, err syscall.Errno) {
fs.mu.Lock() fs.mu.Lock()
defer fs.mu.Unlock() defer fs.mu.Unlock()
fs.errors[t.Name()] = err fs.errors[t] = err
} }
// LOCKS_EXCLUDED(fs.mu) // LOCKS_EXCLUDED(fs.mu)
...@@ -76,9 +74,13 @@ func (fs *errorFS) transformError(op interface{}, err *error) bool { ...@@ -76,9 +74,13 @@ func (fs *errorFS) transformError(op interface{}, err *error) bool {
fs.mu.Lock() fs.mu.Lock()
defer fs.mu.Unlock() defer fs.mu.Unlock()
var ok bool cannedErr, ok := fs.errors[reflect.TypeOf(op)]
*err, ok = fs.errors[reflect.TypeOf(op).Name()] if ok {
return ok *err = cannedErr
return true
}
return false
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment