diff options
author | Rob Pike <r@golang.org> | 2009-01-16 11:36:44 -0800 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2009-01-16 11:36:44 -0800 |
commit | 272bd52ee862a8d2d4594f1b2304a89e9666db60 (patch) | |
tree | 439b4a96dbf9a16e0d4dc2e5ede96343c18a4a07 /src/lib/os/os_error.go | |
parent | b480e90a0efe366a2c1dc9467e98244e4cd6bacb (diff) | |
download | golang-272bd52ee862a8d2d4594f1b2304a89e9666db60.tar.gz |
casify syscall and sequelae
R=rsc
DELTA=337 (0 added, 1 deleted, 336 changed)
OCL=22950
CL=22950
Diffstat (limited to 'src/lib/os/os_error.go')
-rw-r--r-- | src/lib/os/os_error.go | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/lib/os/os_error.go b/src/lib/os/os_error.go index d12a5c118..f01b95db9 100644 --- a/src/lib/os/os_error.go +++ b/src/lib/os/os_error.go @@ -15,11 +15,11 @@ export type Error struct { // Indexed by errno. // If we worry about syscall speed (only relevant on failure), we could // make it an array, but it's probably not important. -var ErrorTab = make(map[int64] *Error); +var errorTab = make(map[int64] *Error); // Table of all known errors in system. Use the same error string twice, // get the same *os.Error. -var ErrorStringTab = make(map[string] *Error); +var errorStringTab = make(map[string] *Error); // These functions contain a race if two goroutines add identical // errors simultaneously but the consequences are unimportant. @@ -29,12 +29,12 @@ export func NewError(s string) *Error { if s == "" { return nil } - err, ok := ErrorStringTab[s]; + err, ok := errorStringTab[s]; if ok { return err } err = &Error{s}; - ErrorStringTab[s] = err; + errorStringTab[s] = err; return err; } @@ -44,12 +44,12 @@ export func ErrnoToError(errno int64) *Error { return nil } // Quick lookup by errno. - err, ok := ErrorTab[errno]; + err, ok := errorTab[errno]; if ok { return err } - err = NewError(syscall.errstr(errno)); - ErrorTab[errno] = err; + err = NewError(syscall.Errstr(errno)); + errorTab[errno] = err; return err; } @@ -91,11 +91,10 @@ export var ( ERANGE = ErrnoToError(syscall.ERANGE); EAGAIN = ErrnoToError(syscall.EAGAIN); ) -const NoError = "No Error" func (e *Error) String() string { if e == nil { - return NoError + return "No Error" } return e.s } |