From: Joerg Sonnenberger Date: Sat, 5 Feb 2005 23:04:28 +0000 (+0000) Subject: Add a macro SYSCTL_SET_CHILDREN. Use it to avoid lhs cast. X-Git-Tag: v2.0.1~8881 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/6d9b622edc0d7953b7951ad992d3ea663e3ca695 Add a macro SYSCTL_SET_CHILDREN. Use it to avoid lhs cast. --- diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index a45054fd35..a1e491cd85 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -38,7 +38,7 @@ * * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94 * $FreeBSD: src/sys/kern/kern_sysctl.c,v 1.92.2.9 2003/05/01 22:48:09 trhodes Exp $ - * $DragonFly: src/sys/kern/kern_sysctl.c,v 1.17 2004/05/10 10:51:31 hmp Exp $ + * $DragonFly: src/sys/kern/kern_sysctl.c,v 1.18 2005/02/05 23:04:28 joerg Exp $ */ #include @@ -429,10 +429,12 @@ sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, oidp->oid_handler = handler; oidp->oid_kind = CTLFLAG_DYN | kind; if ((kind & CTLTYPE) == CTLTYPE_NODE) { + struct sysctl_oid_list *children; + /* Allocate space for children */ - SYSCTL_CHILDREN(oidp) = malloc(sizeof(struct sysctl_oid_list), - M_SYSCTLOID, M_WAITOK); - SLIST_INIT(SYSCTL_CHILDREN(oidp)); + children = malloc(sizeof(*children), M_SYSCTLOID, M_WAITOK); + SYSCTL_SET_CHILDREN(oidp, children); + SLIST_INIT(children); } else { oidp->oid_arg1 = arg1; oidp->oid_arg2 = arg2; diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index e047d58435..a0ded8149b 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -35,7 +35,7 @@ * * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 * $FreeBSD: src/sys/sys/sysctl.h,v 1.81.2.10 2003/05/01 22:48:09 trhodes Exp $ - * $DragonFly: src/sys/sys/sysctl.h,v 1.12 2004/11/09 17:52:45 joerg Exp $ + * $DragonFly: src/sys/sys/sysctl.h,v 1.13 2005/02/05 23:04:28 joerg Exp $ */ #ifndef _SYS_SYSCTL_H_ @@ -158,6 +158,9 @@ void sysctl_unregister_oid(struct sysctl_oid *oidp); extern struct sysctl_oid_list sysctl_##name##_children /* Hide these in macros */ +#define SYSCTL_SET_CHILDREN(oid_ptr, children) do { \ + (oid_ptr)->oid_arg1 = (children); \ +} while(0) #define SYSCTL_CHILDREN(oid_ptr) (struct sysctl_oid_list *) \ (oid_ptr)->oid_arg1 #define SYSCTL_STATIC_CHILDREN(oid_name) \