Date: Sun, 22 Jul 2001 23:59:34 +0300 From: Peter Pentchev <roam@orbitel.bg> To: freebsd-gnats-submit@FreeBSD.org Cc: arch@FreeBSD.org Subject: Re: kern/29131: Current hungs in sysctl -a while booting + patch Message-ID: <20010722235934.G882@ringworld.oblivion.bg> In-Reply-To: <20010722034233.B49508@sneakerz.org>; from bright@sneakerz.org on Sun, Jul 22, 2001 at 03:42:33AM -0500 References: <200107220334.f6M3YRe01219@kan.dnsalias.net> <20010722110626.A819@ringworld.oblivion.bg> <20010722034233.B49508@sneakerz.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Jul 22, 2001 at 03:42:33AM -0500, Alfred Perlstein wrote: > * Peter Pentchev <roam@orbitel.bg> [010722 03:02] wrote: > > Hi, > > > > Can anyone envision any side effects from committing the patch > > in this PR? Seems like a trivial fix for a typo to me.. > > Shouldn't "magic" constants be put into the sysctl.h header? Good call! Attached are two patches: one to make sys/kern/kern_sysctl.c a bit more style(9)-compliant (what made me do it was the failed search for /^sysctl_register_oid/ when I saw it referenced), and one to put a magic constant into sysctl.h and make kern_sysctl.c use it and complain (albeit a bit harshly ;) about misbehaving static sysctl's. Comments? G'luck, Peter -- If I were you, who would be reading this sentence? --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="kern_sysctl.c-style.patch" Index: src/sys/kern/kern_sysctl.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_sysctl.c,v retrieving revision 1.110 diff -u -r1.110 kern_sysctl.c --- src/sys/kern/kern_sysctl.c 2001/06/22 19:54:38 1.110 +++ src/sys/kern/kern_sysctl.c 2001/07/22 20:38:15 @@ -87,7 +87,8 @@ * Order by number in each list. */ -void sysctl_register_oid(struct sysctl_oid *oidp) +void +sysctl_register_oid(struct sysctl_oid *oidp) { struct sysctl_oid_list *parent = oidp->oid_parent; struct sysctl_oid *p; @@ -135,7 +136,8 @@ SLIST_INSERT_HEAD(parent, oidp, oid_link); } -void sysctl_unregister_oid(struct sysctl_oid *oidp) +void +sysctl_unregister_oid(struct sysctl_oid *oidp) { SLIST_REMOVE(oidp->oid_parent, oidp, sysctl_oid, oid_link); } @@ -371,7 +373,8 @@ */ SET_DECLARE(sysctl_set, struct sysctl_oid); -static void sysctl_register_all(void *arg) +static void +sysctl_register_all(void *arg) { struct sysctl_oid **oidp; @@ -1084,7 +1087,8 @@ * must be in kernel space. */ int -userland_sysctl(struct proc *p, int *name, u_int namelen, void *old, size_t *oldlenp, int inkernel, void *new, size_t newlen, size_t *retval) +userland_sysctl(struct proc *p, int *name, u_int namelen, void *old, + size_t *oldlenp, int inkernel, void *new, size_t newlen, size_t *retval) { int error = 0; struct sysctl_req req, req2; --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sysctl-auto-start.patch" Index: src/sys/kern/kern_sysctl.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_sysctl.c,v retrieving revision 1.110 diff -u -r1.110 kern_sysctl.c --- src/sys/kern/kern_sysctl.c 2001/06/22 19:54:38 1.110 +++ src/sys/kern/kern_sysctl.c 2001/07/22 20:46:50 @@ -113,11 +113,13 @@ * 100 to leave space for pre-assigned oid numbers. */ if (oidp->oid_number == OID_AUTO) { - static int newoid = 100; + static int newoid = CTL_AUTO_START; oidp->oid_number = newoid++; if (newoid == 0x7fffffff) panic("out of oids"); + } else if (oidp->oid_number >= CTL_AUTO_START) { + panic("static sysctl oid too high: %d", oidp->oid_number); } /* Index: src/sys/sys/sysctl.h =================================================================== RCS file: /home/ncvs/src/sys/sys/sysctl.h,v retrieving revision 1.97 diff -u -r1.97 sysctl.h --- src/sys/sys/sysctl.h 2001/06/22 06:35:19 1.97 +++ src/sys/sys/sysctl.h 2001/07/22 20:46:55 @@ -95,6 +95,12 @@ */ #define OID_AUTO (-1) +/* + * The starting number for dynamically-assigned entries. WARNING! + * ALL static sysctl entries should have numbers LESS than this! + */ +#define CTL_AUTO_START 0x100 + #ifdef _KERNEL #define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, int arg2, \ struct sysctl_req *req --Nq2Wo0NMKNjxTN9z-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010722235934.G882>