From f7c1ad4fd4190bee32db0aa26c8e9fe7e19d8816 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 10 Dec 2014 01:45:43 +0100 Subject: core: unify how we iterate over inotify events Let's add some syntactic sugar for iterating through inotify events, and use it everywhere. --- src/shared/util.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/shared/util.h') diff --git a/src/shared/util.h b/src/shared/util.h index b6fdf83302..61094cca2f 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -1031,3 +1031,10 @@ int unquote_many_words(const char **p, ...) _sentinel_; int free_and_strdup(char **p, const char *s); int sethostname_idempotent(const char *s); + +#define INOTIFY_EVENT_MAX (sizeof(struct inotify_event) + NAME_MAX + 1) + +#define FOREACH_INOTIFY_EVENT(e, buffer, sz) \ + for ((e) = (struct inotify_event*) (buffer); \ + (uint8_t*) (e) < (uint8_t*) (buffer) + (sz); \ + (e) = (struct inotify_event*) ((uint8_t*) (e) + sizeof(struct inotify_event) + (e)->len)) -- cgit v1.2.3-54-g00ecf