tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
patch for minor issue in kern_sysctl.c
Hi all,
Attached is a patch that fixes a minor pointer handling issue in
kern_sysctl.c. It doesn't alter any behavior, it just eliminates an
ugly and unnecessary pointer cast.
I have tested it on a 6.0rc2 kernel. The patch is against 6.0rc2, but
I've verified that the issue still exists in current.
Should I file a PR about this?
Thanks,
Richard
fix incorrect pointer handling in sysctl_init()
sysctl_init() was using a pointer to a pointer to a pointer to a
function (three levels of indirection) when it should have been using
a pointer to a pointer to a function (two levels of indirection).
This required awkward casts to get it to compile. Fix this situation
by changing the `sysctl_setup_func` typedef to be a function type --
not a pointer to a function -- and eliminate the cast.
diff --git a/src/sys/kern/kern_sysctl.c b/src/sys/kern/kern_sysctl.c
index 6aefb18..20ac255 100644
--- a/src/sys/kern/kern_sysctl.c
+++ b/src/sys/kern/kern_sysctl.c
@@ -102,7 +102,7 @@ static int sysctl_cvt_out(struct lwp *, int, const struct
sysctlnode *,
static int sysctl_log_add(struct sysctllog **, const struct sysctlnode *);
static int sysctl_log_realloc(struct sysctllog *);
-typedef void (*sysctl_setup_func)(struct sysctllog **);
+typedef void sysctl_setup_func(struct sysctllog **);
struct sysctllog {
const struct sysctlnode *log_root;
@@ -223,7 +223,7 @@ sysctl_copyinstr(struct lwp *l, const void *uaddr, void
*kaddr,
void
sysctl_init(void)
{
- sysctl_setup_func * const *sysctl_setup, f;
+ sysctl_setup_func * const *sysctl_setup;
rw_init(&sysctl_treelock);
@@ -233,11 +233,7 @@ sysctl_init(void)
sysctl_root.sysctl_num = CREATE_BASE;
__link_set_foreach(sysctl_setup, sysctl_funcs) {
- /*
- * XXX - why do i have to coerce the pointers like this?
- */
- f = (void*)*sysctl_setup;
- (*f)(NULL);
+ (**sysctl_setup)(NULL);
}
mutex_init(&sysctl_file_marker_lock, MUTEX_DEFAULT, IPL_NONE);
Home |
Main Index |
Thread Index |
Old Index