From: Pieter Droogendijk Date: Sun, 8 Feb 2015 00:36:12 +0000 (+0100) Subject: Reduce repeated error code in inotify X-Git-Tag: v1.7.2~225 X-Git-Url: https://go.fuhry.dev/?a=commitdiff_plain;h=ed0cc8d55917ed0122bedf96fe7b44f6437edea7;p=fsnotify.git Reduce repeated error code in inotify --- diff --git a/inotify.go b/inotify.go index 4198c3e..3978fb5 100644 --- a/inotify.go +++ b/inotify.go @@ -194,27 +194,20 @@ func (w *Watcher) readEvents() { return } - // If EOF is received. This should really never happen. - if n == 0 { - select { - case w.Errors <- io.EOF: - case <-w.done: - return - } - continue - } - - if n < 0 { - select { - case w.Errors <- errno: - case <-w.done: - return - } - continue - } if n < syscall.SizeofInotifyEvent { + var err error + if n == 0 { + // If EOF is received. This should really never happen. + err = io.EOF + } else if n < 0 { + // If an error occured while reading. + err = errno + } else { + // Read was too short. + err = errors.New("notify: short read in readEvents()") + } select { - case w.Errors <- errors.New("inotify: short read in readEvents()"): + case w.Errors <- err: case <-w.done: return }