This is trivial more-of-the-same. If somebody spots a bug, do speak up. I feel pretty good about committing this promptly.
>From f34f5853d7b8f58c677850766353fc72cb9ae5b8 Mon Sep 17 00:00:00 2001 From: Greg Steuck <g...@nest.cx> Date: Sat, 14 Nov 2020 16:00:53 -0800 Subject: [PATCH 1/3] Convert fusefs_sysctl to sysctl_bounded_args --- sys/miscfs/fuse/fuse_vfsops.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git sys/miscfs/fuse/fuse_vfsops.c sys/miscfs/fuse/fuse_vfsops.c index 561c77f9aa4..5e3becfc02b 100644 --- sys/miscfs/fuse/fuse_vfsops.c +++ sys/miscfs/fuse/fuse_vfsops.c @@ -353,30 +353,21 @@ fusefs_init(struct vfsconf *vfc) return (0); } +extern int stat_fbufs_in, stat_fbufs_wait, stat_opened_fusedev; + +const struct sysctl_bounded_args fusefs_vars[] = { + { FUSEFS_OPENDEVS, &stat_opened_fusedev, 1, 0 }, + { FUSEFS_INFBUFS, &stat_fbufs_in, 1, 0 }, + { FUSEFS_WAITFBUFS, &stat_fbufs_wait, 1, 0 }, + { FUSEFS_POOL_NBPAGES, &fusefs_fbuf_pool.pr_npages, 1, 0 }, +}; + int fusefs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen, struct proc *p) { - extern int stat_fbufs_in, stat_fbufs_wait, stat_opened_fusedev; - - /* all sysctl names at this level are terminal */ - if (namelen != 1) - return (ENOTDIR); /* overloaded */ - - switch (name[0]) { - case FUSEFS_OPENDEVS: - return (sysctl_rdint(oldp, oldlenp, newp, - stat_opened_fusedev)); - case FUSEFS_INFBUFS: - return (sysctl_rdint(oldp, oldlenp, newp, stat_fbufs_in)); - case FUSEFS_WAITFBUFS: - return (sysctl_rdint(oldp, oldlenp, newp, stat_fbufs_wait)); - case FUSEFS_POOL_NBPAGES: - return (sysctl_rdint(oldp, oldlenp, newp, - fusefs_fbuf_pool.pr_npages)); - default: - return (EOPNOTSUPP); - } + return sysctl_bounded_arr(fusefs_vars, nitems(fusefs_vars), name, + namelen, oldp, oldlenp, newp, newlen); } int -- 2.29.2