From c8536ec4058302765b1259da83d5699b1e421c21 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 11 Jul 2013 10:28:58 -0700 Subject: [PATCH] * inotify.c (uninitialized): Remove. All uses replaced by -1. (Finotify_add_watch): Simplify, since -1 means uninitialized now. Touch up doc a bit. --- src/ChangeLog | 4 ++++ src/inotify.c | 31 ++++++++++++++----------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 7b54b6195a9..04d5a024672 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2013-07-11 Paul Eggert + * inotify.c (uninitialized): Remove. All uses replaced by -1. + (Finotify_add_watch): Simplify, since -1 means uninitialized now. + Touch up doc a bit. + * eval.c (backtrace_function, backtrace_args): Now EXTERNALLY_VISIBLE. This is for .gdbinit xbacktrace. diff --git a/src/inotify.c b/src/inotify.c index 01fb34a5c4a..0bbcd443332 100644 --- a/src/inotify.c +++ b/src/inotify.c @@ -71,9 +71,8 @@ static Lisp_Object Qunmount; /* IN_UNMOUNT */ # define IN_ONLYDIR 0 #endif -enum { uninitialized = -100 }; /* File handle for inotify. */ -static int inotifyfd = uninitialized; +static int inotifyfd = -1; /* Assoc list of files being watched. Format: @@ -268,8 +267,10 @@ aspect_to_inotifymask (Lisp_Object aspect) DEFUN ("inotify-add-watch", Finotify_add_watch, Sinotify_add_watch, 3, 3, 0, doc: /* Add a watch for FILE-NAME to inotify. -A WATCH-DESCRIPTOR is returned on success. ASPECT might be one of the following -symbols or a list of those symbols: +Return a watch descriptor. The watch will look for ASPECT events and +invoke CALLBACK when an event occurs. + +ASPECT might be one of the following symbols or a list of those symbols: access attrib @@ -288,7 +289,7 @@ all-events or t move close -The following symbols can also be added to a list of aspects +The following symbols can also be added to a list of aspects: dont-follow excl-unlink @@ -296,9 +297,8 @@ mask-add oneshot onlydir -Watching a directory is not recursive. CALLBACK gets called in case of an -event. It gets passed a single argument EVENT which contains an event structure -of the format +Watching a directory is not recursive. CALLBACK is passed a single argument +EVENT which contains an event structure of the format (WATCH-DESCRIPTOR ASPECTS NAME COOKIE) @@ -331,16 +331,13 @@ is managed internally and there is no corresponding inotify_init. Use CHECK_STRING (file_name); - if (inotifyfd == uninitialized) + if (inotifyfd < 0) { inotifyfd = inotify_init1 (IN_NONBLOCK|IN_CLOEXEC); - if (inotifyfd == -1) - { - inotifyfd = uninitialized; - xsignal1 - (Qfile_notify_error, - build_string ("File watching feature (inotify) is not available")); - } + if (inotifyfd < 0) + xsignal1 + (Qfile_notify_error, + build_string ("File watching feature (inotify) is not available")); watch_list = Qnil; add_read_fd (inotifyfd, &inotify_callback, NULL); } @@ -392,7 +389,7 @@ See inotify_rm_watch(2) for more information. { close (inotifyfd); delete_read_fd (inotifyfd); - inotifyfd = uninitialized; + inotifyfd = -1; } return Qt; -- 2.11.4.GIT