summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sysctl.c
diff options
context:
space:
mode:
authormdf <mdf@FreeBSD.org>2010-11-29 18:18:00 +0000
committermdf <mdf@FreeBSD.org>2010-11-29 18:18:00 +0000
commit41bb73b7efed6c592134073f9fbbfecab14a57e0 (patch)
tree54cd0a4d95118fd789873218b67416429db0722b /sys/kern/kern_sysctl.c
parentfdb72b2e1f3f5262fb4bb115e57b929361a47827 (diff)
downloadFreeBSD-src-41bb73b7efed6c592134073f9fbbfecab14a57e0.zip
FreeBSD-src-41bb73b7efed6c592134073f9fbbfecab14a57e0.tar.gz
Slightly modify the logic in sysctl_find_oid to reduce the indentation.
There should be no functional change. MFC after: 3 days
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r--sys/kern/kern_sysctl.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 352bd92..77699c4 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1303,36 +1303,39 @@ int
sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid,
int *nindx, struct sysctl_req *req)
{
+ struct sysctl_oid_list *lsp;
struct sysctl_oid *oid;
int indx;
SYSCTL_ASSERT_LOCKED();
- oid = SLIST_FIRST(&sysctl__children);
+ lsp = &sysctl__children;
indx = 0;
- while (oid && indx < CTL_MAXNAME) {
- if (oid->oid_number == name[indx]) {
- indx++;
- if (oid->oid_kind & CTLFLAG_NOLOCK)
- req->lock = REQ_UNLOCKED;
- if ((oid->oid_kind & CTLTYPE) == CTLTYPE_NODE) {
- if (oid->oid_handler != NULL ||
- indx == namelen) {
- *noid = oid;
- if (nindx != NULL)
- *nindx = indx;
- return (0);
- }
- oid = SLIST_FIRST(SYSCTL_CHILDREN(oid));
- } else if (indx == namelen) {
+ while (indx < CTL_MAXNAME) {
+ SLIST_FOREACH(oid, lsp, oid_link) {
+ if (oid->oid_number == name[indx])
+ break;
+ }
+ if (oid == NULL)
+ return (ENOENT);
+
+ indx++;
+ if (oid->oid_kind & CTLFLAG_NOLOCK)
+ req->lock = REQ_UNLOCKED;
+ if ((oid->oid_kind & CTLTYPE) == CTLTYPE_NODE) {
+ if (oid->oid_handler != NULL || indx == namelen) {
*noid = oid;
if (nindx != NULL)
*nindx = indx;
return (0);
- } else {
- return (ENOTDIR);
}
+ lsp = SYSCTL_CHILDREN(oid);
+ } else if (indx == namelen) {
+ *noid = oid;
+ if (nindx != NULL)
+ *nindx = indx;
+ return (0);
} else {
- oid = SLIST_NEXT(oid, oid_link);
+ return (ENOTDIR);
}
}
return (ENOENT);
OpenPOWER on IntegriCloud