From 94f90dc4f48ee7f6bc1aa3a1116f20b714df89c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Thu, 22 Jul 2021 11:10:41 +0200 Subject: Clean up code --- LICENSE | 2 +- Makefile | 2 +- watch.c | 20 +++++++++----------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/LICENSE b/LICENSE index 528ccbf..f900ed6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019, John Ankarström +Copyright (c) 2019-2021 John Ankarström All rights reserved. diff --git a/Makefile b/Makefile index 752c0a7..1770934 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ BINDIR = /usr/local/bin MANDIR = /usr/local/man -CFLAGS = -Wall -Wno-missing-braces -Wextra -Wpedantic -O2 +CFLAGS = -Wall -Wextra -pedantic -O2 all: watch diff --git a/watch.c b/watch.c index 7e3d256..12cfbee 100644 --- a/watch.c +++ b/watch.c @@ -1,23 +1,21 @@ #include #include #include -#include #include #include -#include -#include -#include #include #define FD 27 -#define LIMIT 100 +#define MAXFILES 100 +#define MAXFD 127 /* FD + MAXFILES */ int -main(int argc, char *argv[argc]) { - char *filenames[LIMIT+FD]; +main(int argc, char *argv[argc]) +{ + char *filenames[MAXFD]; int fd, i, kq, n; - struct kevent evs[LIMIT]; - struct kevent ev[LIMIT]; + struct kevent evs[MAXFILES]; + struct kevent ev[MAXFILES]; /* parse arguments */ if (argc-1 == 0) goto usage; @@ -30,8 +28,8 @@ main(int argc, char *argv[argc]) { argv++; argc--; } if (argc-1 == 0) goto usage; - if (argc-1 > LIMIT) - errx(1, "more than %d files", LIMIT); + if (argc-1 > MAXFILES) + errx(1, "more than %d files", MAXFILES); /* disable buffering even non-interactively */ setbuf(stdout, NULL); -- cgit v1.2.3