]> go.fuhry.dev Git - fsnotify.git/commitdiff
Remove NewSyscallError
authorPieter Droogendijk <pieter@binky.org.uk>
Sat, 7 Feb 2015 21:10:39 +0000 (22:10 +0100)
committerNathan Youngman <git@nathany.com>
Sun, 8 Feb 2015 20:22:30 +0000 (13:22 -0700)
inotify.go
inotify_poller.go

index d2e671cb3118b18a169b31b222e300e79e9de4a5..d33b96adabfe52f9060972d132ed368ff05fb44a 100644 (file)
@@ -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
                        }
index 8fe3ed70a88981b767af6adf7c22f87243af2ea0..fbd664e0b02c42a1f97494fd8c5cd6d561e35e0e 100644 (file)
@@ -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
 }