Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys Add and use __FPTRCAST, requested by uwe@



details:   https://anonhg.NetBSD.org/src/rev/3e904668cf0c
branches:  trunk
changeset: 966167:3e904668cf0c
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Oct 16 18:29:49 2019 +0000

description:
Add and use __FPTRCAST, requested by uwe@

diffstat:

 sys/arch/x86/isa/clock.c     |   6 +++---
 sys/arch/xen/xen/clock.c     |   7 ++++---
 sys/kern/kern_core.c         |   7 ++++---
 sys/kern/kern_hook.c         |  24 +++++++++++++++---------
 sys/kern/kern_sig.c          |   6 +++---
 sys/kern/kern_veriexec.c     |  12 +++++++-----
 sys/kern/subr_ipi.c          |   6 +++---
 sys/kern/subr_pool.c         |  23 +++++++++++++----------
 sys/kern/subr_vmem.c         |   8 ++++----
 sys/kern/sys_ptrace_common.c |  12 ++++++------
 sys/net/if_ethersubr.c       |   7 ++++---
 sys/sys/cdefs.h              |   8 +++++++-
 sys/sys/sdt.h                |  12 ++++++------
 13 files changed, 79 insertions(+), 59 deletions(-)

diffs (truncated from 466 to 300 lines):

diff -r 535ab3d4a8da -r 3e904668cf0c sys/arch/x86/isa/clock.c
--- a/sys/arch/x86/isa/clock.c  Wed Oct 16 15:27:38 2019 +0000
+++ b/sys/arch/x86/isa/clock.c  Wed Oct 16 18:29:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clock.c,v 1.35 2019/10/16 15:01:10 christos Exp $      */
+/*     $NetBSD: clock.c,v 1.36 2019/10/16 18:29:49 christos Exp $      */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -121,7 +121,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.35 2019/10/16 15:01:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.36 2019/10/16 18:29:49 christos Exp $");
 
 /* #define CLOCKDEBUG */
 /* #define CLOCK_PARANOIA */
@@ -554,7 +554,7 @@
         * want to keep track of clock handlers.
         */
        (void)isa_intr_establish(NULL, 0, IST_PULSE, IPL_CLOCK,
-           (int (*)(void *))(void *)clockintr, 0);
+           __FPTRCAST(int (*)(void *), clockintr), 0);
 }
 
 void
diff -r 535ab3d4a8da -r 3e904668cf0c sys/arch/xen/xen/clock.c
--- a/sys/arch/xen/xen/clock.c  Wed Oct 16 15:27:38 2019 +0000
+++ b/sys/arch/xen/xen/clock.c  Wed Oct 16 18:29:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clock.c,v 1.79 2019/10/16 15:01:10 christos Exp $      */
+/*     $NetBSD: clock.c,v 1.80 2019/10/16 18:29:49 christos Exp $      */
 
 /*-
  * Copyright (c) 2017, 2018 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.79 2019/10/16 15:01:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.80 2019/10/16 18:29:49 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -765,7 +765,8 @@
        /* XXX sketchy function pointer cast -- fix the API, please */
        ci->ci_xen_timer_intrhand = xen_intr_establish_xname(-1, &xen_pic,
            evtch, IST_LEVEL, IPL_CLOCK,
-           (int (*)(void *))(void *)xen_timer_handler, ci, true, intr_xname);
+           __FPTRCAST(int (*)(void *), xen_timer_handler),
+           ci, true, intr_xname);
        if (ci->ci_xen_timer_intrhand == NULL)
                panic("failed to establish timer interrupt handler");
 
diff -r 535ab3d4a8da -r 3e904668cf0c sys/kern/kern_core.c
--- a/sys/kern/kern_core.c      Wed Oct 16 15:27:38 2019 +0000
+++ b/sys/kern/kern_core.c      Wed Oct 16 18:29:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_core.c,v 1.25 2019/10/16 15:27:38 christos Exp $  */
+/*     $NetBSD: kern_core.c,v 1.26 2019/10/16 18:29:49 christos Exp $  */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.25 2019/10/16 15:27:38 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.26 2019/10/16 18:29:49 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/vnode.h>
@@ -78,7 +78,8 @@
                 * no references, and so can be unloaded, no user programs
                 * can be running and so nothing can call *coredump_vec.
                 */
-               coredump_vec = (int (*)(struct lwp *, const char *))(void *)enosys;
+               coredump_vec = __FPTRCAST(
+                   int (*)(struct lwp *, const char *), enosys);
                return 0;
        default:
                return ENOTTY;
diff -r 535ab3d4a8da -r 3e904668cf0c sys/kern/kern_hook.c
--- a/sys/kern/kern_hook.c      Wed Oct 16 15:27:38 2019 +0000
+++ b/sys/kern/kern_hook.c      Wed Oct 16 18:29:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_hook.c,v 1.7 2019/10/16 15:27:38 christos Exp $   */
+/*     $NetBSD: kern_hook.c,v 1.8 2019/10/16 18:29:49 christos Exp $   */
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_hook.c,v 1.7 2019/10/16 15:27:38 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_hook.c,v 1.8 2019/10/16 18:29:49 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -101,8 +101,10 @@
 {
        struct hook_desc *hd;
 
-       LIST_FOREACH(hd, list, hk_list)
-               ((void (*)(struct proc *, void *))(void *)*hd->hk_fn)(p, hd->hk_arg);
+       LIST_FOREACH(hd, list, hk_list) {
+               __FPTRCAST(void (*)(struct proc *, void *), *hd->hk_fn)(p,
+                   hd->hk_arg);
+       }
 }
 
 /*
@@ -168,7 +170,8 @@
 void *
 mountroothook_establish(void (*fn)(device_t), device_t dev)
 {
-       return hook_establish(&mountroothook_list, (void (*)(void *))fn, dev);
+       return hook_establish(&mountroothook_list, __FPTRCAST(void (*), fn),
+           dev);
 }
 
 void
@@ -201,7 +204,8 @@
 void *
 exechook_establish(void (*fn)(struct proc *, void *), void *arg)
 {
-       return hook_establish(&exechook_list, (void (*)(void *))(void *)fn, arg);
+       return hook_establish(&exechook_list, __FPTRCAST(void (*)(void *), fn),
+           arg);
 }
 
 void
@@ -228,7 +232,8 @@
        void *rv;
 
        rw_enter(&exec_lock, RW_WRITER);
-       rv = hook_establish(&exithook_list, (void (*)(void *))(void *)fn, arg);
+       rv = hook_establish(&exithook_list, __FPTRCAST(void (*)(void *), fn),
+           arg);
        rw_exit(&exec_lock);
        return rv;
 }
@@ -256,7 +261,8 @@
 void *
 forkhook_establish(void (*fn)(struct proc *, struct proc *))
 {
-       return hook_establish(&forkhook_list, (void (*)(void *))(void *)fn, NULL);
+       return hook_establish(&forkhook_list, __FPTRCAST(void (*)(void *), fn),
+           NULL);
 }
 
 void
@@ -274,7 +280,7 @@
        struct hook_desc *hd;
 
        LIST_FOREACH(hd, &forkhook_list, hk_list) {
-               ((void (*)(struct proc *, struct proc *))(void *)*hd->hk_fn)
+               __FPTRCAST(void (*)(struct proc *, struct proc *), *hd->hk_fn)
                    (p2, p1);
        }
 }
diff -r 535ab3d4a8da -r 3e904668cf0c sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c       Wed Oct 16 15:27:38 2019 +0000
+++ b/sys/kern/kern_sig.c       Wed Oct 16 18:29:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sig.c,v 1.374 2019/10/16 15:27:38 christos Exp $  */
+/*     $NetBSD: kern_sig.c,v 1.375 2019/10/16 18:29:49 christos Exp $  */
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.374 2019/10/16 15:27:38 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.375 2019/10/16 18:29:49 christos Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -133,7 +133,7 @@
 
 void (*sendsig_sigcontext_vec)(const struct ksiginfo *, const sigset_t *);
 int (*coredump_vec)(struct lwp *, const char *) =
-    (int (*)(struct lwp *, const char *))(void *)enosys;
+    __FPTRCAST(int (*)(struct lwp *, const char *), enosys);
 
 /*
  * DTrace SDT provider definitions
diff -r 535ab3d4a8da -r 3e904668cf0c sys/kern/kern_veriexec.c
--- a/sys/kern/kern_veriexec.c  Wed Oct 16 15:27:38 2019 +0000
+++ b/sys/kern/kern_veriexec.c  Wed Oct 16 18:29:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_veriexec.c,v 1.21 2019/10/16 15:27:38 christos Exp $      */
+/*     $NetBSD: kern_veriexec.c,v 1.22 2019/10/16 18:29:49 christos Exp $      */
 
 /*-
  * Copyright (c) 2005, 2006 Elad Efrat <elad%NetBSD.org@localhost>
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_veriexec.c,v 1.21 2019/10/16 15:27:38 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_veriexec.c,v 1.22 2019/10/16 18:29:49 christos Exp $");
 
 #include "opt_veriexec.h"
 
@@ -350,9 +350,11 @@
 
        rw_init(&veriexec_op_lock);
 
-#define        FPOPS_ADD(a, b, c, d, e, f)     \
-       veriexec_fpops_add(a, b, c, (veriexec_fpop_init_t)(void *)d, \
-        (veriexec_fpop_update_t)(void *)e, (veriexec_fpop_final_t)(void *)f)
+#define        FPOPS_ADD(a, b, c, d, e, f)                     \
+       veriexec_fpops_add(a, b, c,                     \
+           __FPTRCAST(veriexec_fpop_init_t, d),        \
+           __FPTRCAST(veriexec_fpop_update_t, e),      \
+           __FPTRCAST(veriexec_fpop_final_t, f))
 
 #ifdef VERIFIED_EXEC_FP_SHA256
        FPOPS_ADD("SHA256", SHA256_DIGEST_LENGTH, sizeof(SHA256_CTX),
diff -r 535ab3d4a8da -r 3e904668cf0c sys/kern/subr_ipi.c
--- a/sys/kern/subr_ipi.c       Wed Oct 16 15:27:38 2019 +0000
+++ b/sys/kern/subr_ipi.c       Wed Oct 16 18:29:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_ipi.c,v 1.6 2019/10/16 15:27:38 christos Exp $    */
+/*     $NetBSD: subr_ipi.c,v 1.7 2019/10/16 18:29:49 christos Exp $    */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_ipi.c,v 1.6 2019/10/16 15:27:38 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_ipi.c,v 1.7 2019/10/16 18:29:49 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -150,7 +150,7 @@
 void
 ipi_unregister(u_int ipi_id)
 {
-       ipi_msg_t ipimsg = { .func = (ipi_func_t)(void *)nullop };
+       ipi_msg_t ipimsg = { .func = __FPTRCAST(ipi_func_t, nullop) };
 
        KASSERT(ipi_id != IPI_SYNCH_ID);
        KASSERT(ipi_id < IPI_MAXREG);
diff -r 535ab3d4a8da -r 3e904668cf0c sys/kern/subr_pool.c
--- a/sys/kern/subr_pool.c      Wed Oct 16 15:27:38 2019 +0000
+++ b/sys/kern/subr_pool.c      Wed Oct 16 18:29:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_pool.c,v 1.260 2019/10/16 15:27:38 christos Exp $ */
+/*     $NetBSD: subr_pool.c,v 1.261 2019/10/16 18:29:49 christos Exp $ */
 
 /*
  * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010, 2014, 2015, 2018
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.260 2019/10/16 15:27:38 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.261 2019/10/16 18:29:49 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -125,10 +125,13 @@
 #define pool_cache_put_quarantine(a, b, c)     false
 #endif
 
-#define pc_has_ctor(pc) \
-       (pc->pc_ctor != (int (*)(void *, void *, int))nullop)
-#define pc_has_dtor(pc) \
-       (pc->pc_dtor != (void (*)(void *, void *))nullop)
+#define NO_CTOR        __FPTRCAST(int (*)(void *, void *, int), nullop)
+#define NO_DTOR        __FPTRCAST(void (*)(void *, void *), nullop)
+
+#if defined(KASAN) || defined(KLEAK)
+#define pc_has_ctor(pc) ((pc)->pc_ctor != NO_CTOR)
+#define pc_has_dtor(pc) ((pc)->pc_dtor != NO_DTOR)
+#endif
 
 /*
  * Pool backend allocators.
@@ -2063,10 +2066,10 @@
        mutex_init(&pc->pc_lock, MUTEX_DEFAULT, ipl);
 
        if (ctor == NULL) {
-               ctor = (int (*)(void *, void *, int))(void *)nullop;
+               ctor = NO_CTOR;
        }
        if (dtor == NULL) {
-               dtor = (void (*)(void *, void *))(void *)nullop;
+               dtor = NO_DTOR;
        }
 
        pc->pc_emptygroups = NULL;
@@ -2339,8 +2342,8 @@



Home | Main Index | Thread Index | Old Index