summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2021-05-04 21:57:16 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2021-05-04 21:57:16 +0000
commit6d9f934b389c992a39a3c9a74c1a88f2c966bdf0 (patch)
tree5607dd4adf96921d8b127529f06875de4a6305cd
parentc76a340f1c4f6b735d4f08d15cfab9704cbb6ac2 (diff)
Reorder the integer sysctl functions. Then the traditional 4.4BSD
comment 'As above...' makes sense again. Improve comments for sysctl_int_bounded() and sysctl_bounded_arr(). OK gnezdo@ mvs@
-rw-r--r--sys/kern/kern_sysctl.c43
-rw-r--r--sys/sys/sysctl.h6
2 files changed, 26 insertions, 23 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 0ac4a787594..d2069599418 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.393 2021/05/04 19:04:56 bluhm Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.394 2021/05/04 21:57:15 bluhm Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -856,6 +856,27 @@ sysctl_int(void *oldp, size_t *oldlenp, void *newp, size_t newlen, int *valp)
return (error);
}
+/*
+ * As above, but read-only.
+ */
+int
+sysctl_rdint(void *oldp, size_t *oldlenp, void *newp, int val)
+{
+ int error = 0;
+
+ if (oldp && *oldlenp < sizeof(int))
+ return (ENOMEM);
+ if (newp)
+ return (EPERM);
+ *oldlenp = sizeof(int);
+ if (oldp)
+ error = copyout((caddr_t)&val, oldp, sizeof(int));
+ return (error);
+}
+
+/*
+ * Read-only or bounded integer values.
+ */
int
sysctl_int_bounded(void *oldp, size_t *oldlenp, void *newp, size_t newlen,
int *valp, int minimum, int maximum)
@@ -877,25 +898,7 @@ sysctl_int_bounded(void *oldp, size_t *oldlenp, void *newp, size_t newlen,
}
/*
- * As above, but read-only.
- */
-int
-sysctl_rdint(void *oldp, size_t *oldlenp, void *newp, int val)
-{
- int error = 0;
-
- if (oldp && *oldlenp < sizeof(int))
- return (ENOMEM);
- if (newp)
- return (EPERM);
- *oldlenp = sizeof(int);
- if (oldp)
- error = copyout((caddr_t)&val, oldp, sizeof(int));
- return (error);
-}
-
-/*
- * Array of bounded integer values.
+ * Array of read-only or bounded integer values.
*/
int
sysctl_bounded_arr(const struct sysctl_bounded_args *valpp, u_int valplen,
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index e53e7c63280..93a4b955d05 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.h,v 1.216 2021/05/01 16:18:58 gnezdo Exp $ */
+/* $OpenBSD: sysctl.h,v 1.217 2021/05/04 21:57:15 bluhm Exp $ */
/* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */
/*
@@ -1014,10 +1014,10 @@ struct sysctl_bounded_args {
*/
typedef int (sysctlfn)(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
-int sysctl_int(void *, size_t *, void *, size_t, int *);
-int sysctl_int_bounded(void *, size_t *, void *, size_t, int *, int, int);
int sysctl_int_lower(void *, size_t *, void *, size_t, int *);
+int sysctl_int(void *, size_t *, void *, size_t, int *);
int sysctl_rdint(void *, size_t *, void *, int);
+int sysctl_int_bounded(void *, size_t *, void *, size_t, int *, int, int);
int sysctl_bounded_arr(const struct sysctl_bounded_args *, u_int,
int *, u_int, void *, size_t *, void *, size_t);
int sysctl_quad(void *, size_t *, void *, size_t, int64_t *);