aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2017-05-27 10:54:25 -0700
committerPaul Eggert2017-05-27 11:14:30 -0700
commit8f59ff2461b54e29c9389cee5851f348b867a281 (patch)
tree63b5d83818a3150c5ddf3ed45fc26746f5647b7e /src
parentebe0bdae9ded4eab974faefb54a6ba5260523489 (diff)
downloademacs-8f59ff2461b54e29c9389cee5851f348b867a281.tar.gz
emacs-8f59ff2461b54e29c9389cee5851f348b867a281.zip
Simplify computation of inotify mask
* src/inotify.c (add_watch): Accept uint32_t imask instead of Lisp_Object aspect. Caller changed. (Finotify_add_watch): Use aspect_to_inotifymask earlier, to simplify the code.
Diffstat (limited to 'src')
-rw-r--r--src/inotify.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/inotify.c b/src/inotify.c
index 1165293d24c..bcf30ad2b3c 100644
--- a/src/inotify.c
+++ b/src/inotify.c
@@ -215,16 +215,15 @@ inotifyevent_to_event (Lisp_Object watch, struct inotify_event const *ev)
215} 215}
216 216
217/* Add a new watch to watch-descriptor WD watching FILENAME and using 217/* Add a new watch to watch-descriptor WD watching FILENAME and using
218 CALLBACK. Returns a cons (DESCRIPTOR . ID) uniquely identifying the 218 IMASK and CALLBACK. Return a cons (DESCRIPTOR . ID) uniquely
219 new watch. */ 219 identifying the new watch. */
220static Lisp_Object 220static Lisp_Object
221add_watch (int wd, Lisp_Object filename, 221add_watch (int wd, Lisp_Object filename,
222 Lisp_Object aspect, Lisp_Object callback) 222 uint32_t imask, Lisp_Object callback)
223{ 223{
224 Lisp_Object descriptor = INTEGER_TO_CONS (wd); 224 Lisp_Object descriptor = INTEGER_TO_CONS (wd);
225 Lisp_Object tail = assoc_no_quit (descriptor, watch_list); 225 Lisp_Object tail = assoc_no_quit (descriptor, watch_list);
226 Lisp_Object watch, watch_id; 226 Lisp_Object watch, watch_id;
227 uint32_t imask = aspect_to_inotifymask (aspect);
228 Lisp_Object mask = INTEGER_TO_CONS (imask); 227 Lisp_Object mask = INTEGER_TO_CONS (imask);
229 228
230 EMACS_INT id = 0; 229 EMACS_INT id = 0;
@@ -436,12 +435,10 @@ IN_ONLYDIR */)
436 (Lisp_Object filename, Lisp_Object aspect, Lisp_Object callback) 435 (Lisp_Object filename, Lisp_Object aspect, Lisp_Object callback)
437{ 436{
438 Lisp_Object encoded_file_name; 437 Lisp_Object encoded_file_name;
439 bool dont_follow = (CONSP (aspect)
440 ? ! NILP (Fmemq (Qdont_follow, aspect))
441 : EQ (Qdont_follow, aspect));
442 int wd = -1; 438 int wd = -1;
439 uint32_t imask = aspect_to_inotifymask (aspect);
443 uint32_t mask = (INOTIFY_DEFAULT_MASK 440 uint32_t mask = (INOTIFY_DEFAULT_MASK
444 | (dont_follow ? IN_DONT_FOLLOW : 0)); 441 | (imask & IN_DONT_FOLLOW));
445 442
446 CHECK_STRING (filename); 443 CHECK_STRING (filename);
447 444
@@ -459,7 +456,7 @@ IN_ONLYDIR */)
459 if (wd < 0) 456 if (wd < 0)
460 report_file_notify_error ("Could not add watch for file", filename); 457 report_file_notify_error ("Could not add watch for file", filename);
461 458
462 return add_watch (wd, filename, aspect, callback); 459 return add_watch (wd, filename, imask, callback);
463} 460}
464 461
465static bool 462static bool