From 5649f07fff728086dce6e1cdd22cbcdb91582986 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Mon, 23 Jul 2018 16:13:03 -0400 Subject: Use EV_SET in watch On NetBSD, kevent.udata is intptr_t rather than void *, and their EV_SET macro does the cast. --- bin/watch.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/bin/watch.c b/bin/watch.c index 3308edc9..08a4ae9e 100644 --- a/bin/watch.c +++ b/bin/watch.c @@ -28,13 +28,16 @@ static void watch(int kq, char *path) { int fd = open(path, O_CLOEXEC); if (fd < 0) err(EX_NOINPUT, "%s", path); - struct kevent event = { - .ident = fd, - .filter = EVFILT_VNODE, - .flags = EV_ADD | EV_CLEAR, - .fflags = NOTE_WRITE | NOTE_DELETE, - .udata = path, - }; + struct kevent event; + EV_SET( + &event, + fd, + EVFILT_VNODE, + EV_ADD | EV_CLEAR, + NOTE_WRITE | NOTE_DELETE, + 0, + path + ); int nevents = kevent(kq, &event, 1, NULL, 0, NULL); if (nevents < 0) err(EX_OSERR, "kevent"); } @@ -86,7 +89,7 @@ int main(int argc, char *argv[]) { if (event.fflags & NOTE_DELETE) { close(event.ident); sleep(1); - watch(kq, event.udata); + watch(kq, (char *)event.udata); } exec(&argv[i]); -- cgit 1.4.1