summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2019-12-31 13:48:33 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2019-12-31 13:48:33 +0000
commite1d46407d705bb612ebbeebddbe85779b52a42a5 (patch)
treeb128da7e2130d5eeae1d5918b1cc8692523d852b /sys/kern
parenta2985aa5fb51f9899868daaf2cde0dfa5a0f449f (diff)
Use C99 designated initializers with struct filterops. In addition,
make the structs const so that the data are put in .rodata. OK mpi@, deraadt@, anton@, bluhm@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_event.c54
-rw-r--r--sys/kern/kern_sig.c10
-rw-r--r--sys/kern/subr_log.c10
-rw-r--r--sys/kern/sys_pipe.c19
-rw-r--r--sys/kern/tty.c19
-rw-r--r--sys/kern/tty_pty.c19
-rw-r--r--sys/kern/uipc_socket.c28
-rw-r--r--sys/kern/vfs_default.c10
8 files changed, 120 insertions, 49 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index fd6876626b2..92ee7adcf57 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_event.c,v 1.111 2019/12/29 07:14:06 visa Exp $ */
+/* $OpenBSD: kern_event.c,v 1.112 2019/12/31 13:48:32 visa Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
@@ -98,14 +98,33 @@ void filt_timerdetach(struct knote *kn);
int filt_timer(struct knote *kn, long hint);
void filt_seltruedetach(struct knote *kn);
-struct filterops kqread_filtops =
- { 1, NULL, filt_kqdetach, filt_kqueue };
-struct filterops proc_filtops =
- { 0, filt_procattach, filt_procdetach, filt_proc };
-struct filterops file_filtops =
- { 1, filt_fileattach, NULL, NULL };
-struct filterops timer_filtops =
- { 0, filt_timerattach, filt_timerdetach, filt_timer };
+const struct filterops kqread_filtops = {
+ .f_isfd = 1,
+ .f_attach = NULL,
+ .f_detach = filt_kqdetach,
+ .f_event = filt_kqueue,
+};
+
+const struct filterops proc_filtops = {
+ .f_isfd = 0,
+ .f_attach = filt_procattach,
+ .f_detach = filt_procdetach,
+ .f_event = filt_proc,
+};
+
+const struct filterops file_filtops = {
+ .f_isfd = 1,
+ .f_attach = filt_fileattach,
+ .f_detach = NULL,
+ .f_event = NULL,
+};
+
+const struct filterops timer_filtops = {
+ .f_isfd = 0,
+ .f_attach = filt_timerattach,
+ .f_detach = filt_timerdetach,
+ .f_event = filt_timer,
+};
struct pool knote_pool;
struct pool kqueue_pool;
@@ -114,15 +133,10 @@ int kq_timeoutmax = (4 * 1024);
#define KN_HASH(val, mask) (((val) ^ (val >> 8)) & (mask))
-extern struct filterops sig_filtops;
-#ifdef notyet
-extern struct filterops aio_filtops;
-#endif
-
/*
* Table for for all system-defined filters.
*/
-struct filterops *sysfilt_ops[] = {
+const struct filterops *const sysfilt_ops[] = {
&file_filtops, /* EVFILT_READ */
&file_filtops, /* EVFILT_WRITE */
NULL, /*&aio_filtops,*/ /* EVFILT_AIO */
@@ -415,8 +429,12 @@ filt_seltruedetach(struct knote *kn)
/* Nothing to do */
}
-const struct filterops seltrue_filtops =
- { 1, NULL, filt_seltruedetach, filt_seltrue };
+const struct filterops seltrue_filtops = {
+ .f_isfd = 1,
+ .f_attach = NULL,
+ .f_detach = filt_seltruedetach,
+ .f_event = filt_seltrue,
+};
int
seltrue_kqfilter(dev_t dev, struct knote *kn)
@@ -602,7 +620,7 @@ int
kqueue_register(struct kqueue *kq, struct kevent *kev, struct proc *p)
{
struct filedesc *fdp = kq->kq_fdp;
- struct filterops *fops = NULL;
+ const struct filterops *fops = NULL;
struct file *fp = NULL;
struct knote *kn = NULL;
int s, error = 0;
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 1db70dbcbfd..776ef7382bf 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sig.c,v 1.237 2019/12/19 17:40:11 mpi Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.238 2019/12/31 13:48:32 visa Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
@@ -75,8 +75,12 @@ int filt_sigattach(struct knote *kn);
void filt_sigdetach(struct knote *kn);
int filt_signal(struct knote *kn, long hint);
-struct filterops sig_filtops =
- { 0, filt_sigattach, filt_sigdetach, filt_signal };
+const struct filterops sig_filtops = {
+ .f_isfd = 0,
+ .f_attach = filt_sigattach,
+ .f_detach = filt_sigdetach,
+ .f_event = filt_signal,
+};
void proc_stop(struct proc *p, int);
void proc_stop_sweep(void *);
diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c
index 6f5d2be7b44..aead8b3b7e8 100644
--- a/sys/kern/subr_log.c
+++ b/sys/kern/subr_log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_log.c,v 1.60 2019/12/24 12:56:07 bluhm Exp $ */
+/* $OpenBSD: subr_log.c,v 1.61 2019/12/31 13:48:32 visa Exp $ */
/* $NetBSD: subr_log.c,v 1.11 1996/03/30 22:24:44 christos Exp $ */
/*
@@ -88,8 +88,12 @@ struct file *syslogf;
void filt_logrdetach(struct knote *kn);
int filt_logread(struct knote *kn, long hint);
-struct filterops logread_filtops =
- { 1, NULL, filt_logrdetach, filt_logread};
+const struct filterops logread_filtops = {
+ .f_isfd = 1,
+ .f_attach = NULL,
+ .f_detach = filt_logrdetach,
+ .f_event = filt_logread,
+};
int dosendsyslog(struct proc *, const char *, size_t, int, enum uio_seg);
void logtick(void *);
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 2229aee7cf7..295ff28ac32 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_pipe.c,v 1.105 2019/12/27 09:29:50 anton Exp $ */
+/* $OpenBSD: sys_pipe.c,v 1.106 2019/12/31 13:48:32 visa Exp $ */
/*
* Copyright (c) 1996 John S. Dyson
@@ -74,10 +74,19 @@ void filt_pipedetach(struct knote *kn);
int filt_piperead(struct knote *kn, long hint);
int filt_pipewrite(struct knote *kn, long hint);
-struct filterops pipe_rfiltops =
- { 1, NULL, filt_pipedetach, filt_piperead };
-struct filterops pipe_wfiltops =
- { 1, NULL, filt_pipedetach, filt_pipewrite };
+const struct filterops pipe_rfiltops = {
+ .f_isfd = 1,
+ .f_attach = NULL,
+ .f_detach = filt_pipedetach,
+ .f_event = filt_piperead,
+};
+
+const struct filterops pipe_wfiltops = {
+ .f_isfd = 1,
+ .f_attach = NULL,
+ .f_detach = filt_pipedetach,
+ .f_event = filt_pipewrite,
+};
/*
* Default pipe buffer size(s), this can be kind-of large now because pipe
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index a21f7f2741f..d73714f77d8 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.148 2019/07/19 00:17:15 cheloha Exp $ */
+/* $OpenBSD: tty.c,v 1.149 2019/12/31 13:48:32 visa Exp $ */
/* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */
/*-
@@ -1062,10 +1062,19 @@ ttpoll(dev_t device, int events, struct proc *p)
return (revents);
}
-struct filterops ttyread_filtops =
- { 1, NULL, filt_ttyrdetach, filt_ttyread };
-struct filterops ttywrite_filtops =
- { 1, NULL, filt_ttywdetach, filt_ttywrite };
+const struct filterops ttyread_filtops = {
+ .f_isfd = 1,
+ .f_attach = NULL,
+ .f_detach = filt_ttyrdetach,
+ .f_event = filt_ttyread,
+};
+
+const struct filterops ttywrite_filtops = {
+ .f_isfd = 1,
+ .f_attach = NULL,
+ .f_detach = filt_ttywdetach,
+ .f_event = filt_ttywrite,
+};
int
ttkqfilter(dev_t dev, struct knote *kn)
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c
index 6c0ba70d018..e30b7cebe5d 100644
--- a/sys/kern/tty_pty.c
+++ b/sys/kern/tty_pty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty_pty.c,v 1.94 2019/07/19 00:17:16 cheloha Exp $ */
+/* $OpenBSD: tty_pty.c,v 1.95 2019/12/31 13:48:32 visa Exp $ */
/* $NetBSD: tty_pty.c,v 1.33.4.1 1996/06/02 09:08:11 mrg Exp $ */
/*
@@ -717,10 +717,19 @@ filt_ptcwrite(struct knote *kn, long hint)
return (kn->kn_data > 0);
}
-struct filterops ptcread_filtops =
- { 1, NULL, filt_ptcrdetach, filt_ptcread };
-struct filterops ptcwrite_filtops =
- { 1, NULL, filt_ptcwdetach, filt_ptcwrite };
+const struct filterops ptcread_filtops = {
+ .f_isfd = 1,
+ .f_attach = NULL,
+ .f_detach = filt_ptcrdetach,
+ .f_event = filt_ptcread,
+};
+
+const struct filterops ptcwrite_filtops = {
+ .f_isfd = 1,
+ .f_attach = NULL,
+ .f_detach = filt_ptcwdetach,
+ .f_event = filt_ptcwrite,
+};
int
ptckqfilter(dev_t dev, struct knote *kn)
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index a61d407030d..58d78fbd5d4 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.237 2019/12/12 16:33:02 visa Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.238 2019/12/31 13:48:32 visa Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -72,12 +72,26 @@ void filt_sowdetach(struct knote *kn);
int filt_sowrite(struct knote *kn, long hint);
int filt_solisten(struct knote *kn, long hint);
-struct filterops solisten_filtops =
- { 1, NULL, filt_sordetach, filt_solisten };
-struct filterops soread_filtops =
- { 1, NULL, filt_sordetach, filt_soread };
-struct filterops sowrite_filtops =
- { 1, NULL, filt_sowdetach, filt_sowrite };
+const struct filterops solisten_filtops = {
+ .f_isfd = 1,
+ .f_attach = NULL,
+ .f_detach = filt_sordetach,
+ .f_event = filt_solisten,
+};
+
+const struct filterops soread_filtops = {
+ .f_isfd = 1,
+ .f_attach = NULL,
+ .f_detach = filt_sordetach,
+ .f_event = filt_soread,
+};
+
+const struct filterops sowrite_filtops = {
+ .f_isfd = 1,
+ .f_attach = NULL,
+ .f_detach = filt_sowdetach,
+ .f_event = filt_sowrite,
+};
#ifndef SOMINCONN
diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c
index 92fbd818636..a8ca01b337a 100644
--- a/sys/kern/vfs_default.c
+++ b/sys/kern/vfs_default.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_default.c,v 1.45 2019/12/27 22:17:01 bluhm Exp $ */
+/* $OpenBSD: vfs_default.c,v 1.46 2019/12/31 13:48:32 visa Exp $ */
/*
* Portions of this code are:
@@ -185,8 +185,12 @@ vop_generic_islocked(void *v)
return (0);
}
-struct filterops generic_filtops =
- { 1, NULL, filt_generic_detach, filt_generic_readwrite };
+const struct filterops generic_filtops = {
+ .f_isfd = 1,
+ .f_attach = NULL,
+ .f_detach = filt_generic_detach,
+ .f_event = filt_generic_readwrite,
+};
int
vop_generic_kqfilter(void *v)