]> code.delx.au - gnu-emacs/blobdiff - src/inotify.c
* inotify.c (uninitialized): Remove. All uses replaced by -1.
[gnu-emacs] / src / inotify.c
index 01fb34a5c4a1289f88fa662ca43d71982e837f90..0bbcd4433320c654792b5aaf923b212bf4c09477 100644 (file)
@@ -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;