diff options
Diffstat (limited to 'src/account')
-rw-r--r-- | src/account/indication_common.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/account/indication_common.c b/src/account/indication_common.c index d999176..d9629b4 100644 --- a/src/account/indication_common.c +++ b/src/account/indication_common.c @@ -104,15 +104,15 @@ void watcher_destroy(AccountIndication *ind) bool watcher(AccountIndication *ind, void **data) { struct timespec curr_pwd, curr_grp; - char buffer[BUF_LEN]; char errbuf[STRERROR_BUF_LEN]; if (ind->inotify_fd < 0) return false; + char buffer[BUF_LEN]; do { - int len = 0, i = 0; - if ((len = read(ind->inotify_fd, buffer, BUF_LEN)) < 0 || len > (int) BUF_LEN) { + const int len = read(ind->inotify_fd, buffer, BUF_LEN); + if (len < 0) { warn("account watcher: error reading from inotify fd: %s", strerror_r(errno, errbuf, sizeof(errbuf))); watcher_destroy(ind); watcher_init(ind); @@ -124,6 +124,8 @@ bool watcher(AccountIndication *ind, void **data) watcher_init(ind); return true; } + + int i = 0; while (i + (ssize_t) EVENT_SIZE < len) { struct inotify_event *event = (struct inotify_event *) &buffer[i]; if (i + (ssize_t) EVENT_SIZE + event->len > len) { |