summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-07-23 16:13:03 -0400
committerJune McEnroe <june@causal.agency>2018-07-23 16:13:03 -0400
commitdf97ddc9338bef46b27732ac0d4550550b76d578 (patch)
tree6db4b427ca01e56d2028d5d32a3538f91eebc926
parentLink with -lcurses (diff)
downloadsrc-df97ddc9338bef46b27732ac0d4550550b76d578.tar.gz
src-df97ddc9338bef46b27732ac0d4550550b76d578.zip
Use EV_SET in watch
On NetBSD, kevent.udata is intptr_t rather than void *, and their EV_SET
macro does the cast.
Diffstat (limited to '')
-rw-r--r--bin/watch.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/bin/watch.c b/bin/watch.c
index 4701068f..9a0c378b 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]);