From: Pieter Droogendijk Date: Sat, 7 Feb 2015 21:10:39 +0000 (+0100) Subject: Remove NewSyscallError X-Git-Tag: v1.7.2~235 X-Git-Url: https://go.fuhry.dev/?a=commitdiff_plain;h=6b87dc796c2b145d31bd6048526e03315ad21502;p=fsnotify.git Remove NewSyscallError --- diff --git a/inotify.go b/inotify.go index d2e671c..d33b96a 100644 --- a/inotify.go +++ b/inotify.go @@ -99,7 +99,7 @@ func (w *Watcher) Add(name string) error { } wd, errno := syscall.InotifyAddWatch(w.poller.fd, name, flags) if wd == -1 { - return os.NewSyscallError("inotify_add_watch", errno) + return errno } w.mu.Lock() @@ -125,7 +125,7 @@ func (w *Watcher) Remove(name string) error { } success, errno := syscall.InotifyRmWatch(w.poller.fd, watch.wd) if success == -1 { - return os.NewSyscallError("inotify_rm_watch", errno) + return errno } delete(w.watches, name) return nil @@ -196,7 +196,7 @@ func (w *Watcher) readEvents() { if n < 0 { select { - case w.Errors <- os.NewSyscallError("read", errno): + case w.Errors <- errno: case <-w.done: return } diff --git a/inotify_poller.go b/inotify_poller.go index 8fe3ed7..fbd664e 100644 --- a/inotify_poller.go +++ b/inotify_poller.go @@ -8,7 +8,6 @@ package fsnotify import ( "errors" - "os" "syscall" ) @@ -27,20 +26,20 @@ func newFdPoller() (*fdPoller, error) { // Create inotify fd poller.fd, errno = syscall.InotifyInit() if poller.fd == -1 { - return nil, os.NewSyscallError("inotify_init", errno) + return nil, errno } // Create epoll fd poller.epfd, errno = syscall.EpollCreate(1) if poller.epfd == -1 { syscall.Close(poller.fd) - return nil, os.NewSyscallError("epoll_create", errno) + return nil, errno } // Create pipe; pipe[0] is the read end, pipe[1] the write end. errno = syscall.Pipe(poller.pipe[:]) if errno != nil { syscall.Close(poller.fd) syscall.Close(poller.epfd) - return nil, os.NewSyscallError("pipe", errno) + return nil, errno } // Register inotify fd with epoll @@ -54,7 +53,7 @@ func newFdPoller() (*fdPoller, error) { syscall.Close(poller.epfd) syscall.Close(poller.pipe[0]) syscall.Close(poller.pipe[1]) - return nil, os.NewSyscallError("epoll_ctl", errno) + return nil, errno } // Register pipe fd with epoll @@ -68,7 +67,7 @@ func newFdPoller() (*fdPoller, error) { syscall.Close(poller.epfd) syscall.Close(poller.pipe[0]) syscall.Close(poller.pipe[1]) - return nil, os.NewSyscallError("epoll_ctl", errno) + return nil, errno } return poller, nil @@ -85,7 +84,7 @@ func (poller *fdPoller) wait() (bool, error) { if errno == syscall.EINTR { continue } - return false, os.NewSyscallError("epoll_wait", errno) + return false, errno } if n == 0 { // If there are no events, try again. @@ -158,7 +157,7 @@ func (poller *fdPoller) wake() error { buf := make([]byte, 1) n, errno := syscall.Write(poller.pipe[1], buf) if n == -1 { - return os.NewSyscallError("write", errno) + return errno } return nil } @@ -167,7 +166,7 @@ func (poller *fdPoller) clearWake() error { buf := make([]byte, 100) n, errno := syscall.Read(poller.pipe[0], buf) if n == -1 { - return os.NewSyscallError("read", errno) + return errno } return nil }