From: bluhm Date: Tue, 4 May 2021 21:57:15 +0000 (+0000) Subject: Reorder the integer sysctl functions. Then the traditional 4.4BSD X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=70de0cbd3647ada3a01cd9a7542d1ade7fec26ab;p=openbsd 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@ --- 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 *);