Hi Scott, does this look OK to you?

>From 859fc21576fa7fad252f065697a70fb633300fcd Mon Sep 17 00:00:00 2001
From: Greg Steuck <g...@nest.cx>
Date: Sat, 21 Nov 2020 15:51:01 -0800
Subject: [PATCH] Convert sysctl_tc to sysctl_bounded_arr

---
 sys/kern/kern_tc.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git sys/kern/kern_tc.c sys/kern/kern_tc.c
index d19381a669f..ccc726f2bbb 100644
--- sys/kern/kern_tc.c
+++ sys/kern/kern_tc.c
@@ -821,6 +821,11 @@ inittimecounter(void)
        (void)timecounter->tc_get_timecount(timecounter);
 }
 
+const struct sysctl_bounded_args tc_vars[] = {
+       { KERN_TIMECOUNTER_TICK, &tc_tick, 1, 0 },
+       { KERN_TIMECOUNTER_TIMESTEPWARNINGS, &timestepwarnings, 0, 1 },
+};
+
 /*
  * Return timecounter-related information.
  */
@@ -832,17 +837,13 @@ sysctl_tc(int *name, u_int namelen, void *oldp, size_t 
*oldlenp,
                return (ENOTDIR);
 
        switch (name[0]) {
-       case KERN_TIMECOUNTER_TICK:
-               return (sysctl_rdint(oldp, oldlenp, newp, tc_tick));
-       case KERN_TIMECOUNTER_TIMESTEPWARNINGS:
-               return (sysctl_int(oldp, oldlenp, newp, newlen,
-                   &timestepwarnings));
        case KERN_TIMECOUNTER_HARDWARE:
                return (sysctl_tc_hardware(oldp, oldlenp, newp, newlen));
        case KERN_TIMECOUNTER_CHOICE:
                return (sysctl_tc_choice(oldp, oldlenp, newp, newlen));
        default:
-               return (EOPNOTSUPP);
+               return (sysctl_bounded_arr(tc_vars, nitems(tc_vars), name,
+                   namelen, oldp, oldlenp, newp, newlen));
        }
        /* NOTREACHED */
 }
-- 
2.29.2

Reply via email to