From 52ab266b8930d2b82554c8df87f8146a07e5f33b Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 26 Sep 2006 13:41:49 +0200 Subject: Add check for the case that no file produced the inotify event This could use an unlikely() --- inotail.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/inotail.c b/inotail.c index da793db..c0c5302 100644 --- a/inotail.c +++ b/inotail.c @@ -235,7 +235,7 @@ static int watch_files(struct file_struct *f, int n_files) inev = (struct inotify_event *) &buf; while (len > 0) { - struct file_struct *fil; + struct file_struct *fil = NULL; /* Which file has produced the event? */ for (i = 0; i < n_files; i++) { @@ -245,7 +245,10 @@ static int watch_files(struct file_struct *f, int n_files) } } - /* XXX: Is it possible that no file in the list produced the event? */ + /* Very unlikely! */ + if (!fil) + break; + if (inev->mask & IN_MODIFY) { int rc; char fbuf[BUFFER_SIZE]; -- cgit v1.2.3-54-g00ecf