Source-Changes-HG archive

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

[src/trunk]: src/sys Add void * function pointer casts. There are different w...



details:   https://anonhg.NetBSD.org/src/rev/0c96a11f8f2d
branches:  trunk
changeset: 1004201:0c96a11f8f2d
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Oct 16 15:27:38 2019 +0000

description:
Add void * function pointer casts. There are different ways to "fix" those
warnings:
    1. this one: add a void * cast (which I think is the least intrusive)
    2. add pragmas to elide the warning
    3. add intermediate inline conversion functions
    4. change the called function prototypes, adding unused arguments and
       converting some of the pointer arguments to void *.
    5. make the functions varyadic (which defeats the purpose of checking)
    6. pass command line flags to elide the warning
I did try 3 and 4 and I was not pleased with the result (sys_ptrace_common.c)
(3) added too much code and defines, and (4) made the regular use clumsy.

diffstat:

 sys/kern/kern_core.c         |   6 +++---
 sys/kern/kern_hook.c         |  14 +++++++-------
 sys/kern/kern_sig.c          |   6 +++---
 sys/kern/kern_veriexec.c     |   8 ++++----
 sys/kern/subr_ipi.c          |   6 +++---
 sys/kern/subr_pool.c         |  10 +++++-----
 sys/kern/subr_vmem.c         |  10 +++++-----
 sys/kern/sys_ptrace_common.c |  12 ++++++------
 sys/net/if_ethersubr.c       |   6 +++---
 9 files changed, 39 insertions(+), 39 deletions(-)

diffs (truncated from 315 to 300 lines):

diff -r 7641689facfd -r 0c96a11f8f2d sys/kern/kern_core.c
--- a/sys/kern/kern_core.c      Wed Oct 16 15:08:09 2019 +0000
+++ b/sys/kern/kern_core.c      Wed Oct 16 15:27:38 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_core.c,v 1.24 2016/07/07 06:55:43 msaitoh Exp $   */
+/*     $NetBSD: kern_core.c,v 1.25 2019/10/16 15:27:38 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.24 2016/07/07 06:55:43 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.25 2019/10/16 15:27:38 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/vnode.h>
@@ -78,7 +78,7 @@
                 * 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 *))enosys;
+               coredump_vec = (int (*)(struct lwp *, const char *))(void *)enosys;
                return 0;
        default:
                return ENOTTY;
diff -r 7641689facfd -r 0c96a11f8f2d sys/kern/kern_hook.c
--- a/sys/kern/kern_hook.c      Wed Oct 16 15:08:09 2019 +0000
+++ b/sys/kern/kern_hook.c      Wed Oct 16 15:27:38 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_hook.c,v 1.6 2013/11/22 21:04:11 christos Exp $   */
+/*     $NetBSD: kern_hook.c,v 1.7 2019/10/16 15:27:38 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.6 2013/11/22 21:04:11 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_hook.c,v 1.7 2019/10/16 15:27:38 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -102,7 +102,7 @@
        struct hook_desc *hd;
 
        LIST_FOREACH(hd, list, hk_list)
-               ((void (*)(struct proc *, void *))*hd->hk_fn)(p, hd->hk_arg);
+               ((void (*)(struct proc *, void *))(void *)*hd->hk_fn)(p, hd->hk_arg);
 }
 
 /*
@@ -201,7 +201,7 @@
 void *
 exechook_establish(void (*fn)(struct proc *, void *), void *arg)
 {
-       return hook_establish(&exechook_list, (void (*)(void *))fn, arg);
+       return hook_establish(&exechook_list, (void (*)(void *))(void *)fn, arg);
 }
 
 void
@@ -228,7 +228,7 @@
        void *rv;
 
        rw_enter(&exec_lock, RW_WRITER);
-       rv = hook_establish(&exithook_list, (void (*)(void *))fn, arg);
+       rv = hook_establish(&exithook_list, (void (*)(void *))(void *)fn, arg);
        rw_exit(&exec_lock);
        return rv;
 }
@@ -256,7 +256,7 @@
 void *
 forkhook_establish(void (*fn)(struct proc *, struct proc *))
 {
-       return hook_establish(&forkhook_list, (void (*)(void *))fn, NULL);
+       return hook_establish(&forkhook_list, (void (*)(void *))(void *)fn, NULL);
 }
 
 void
@@ -274,7 +274,7 @@
        struct hook_desc *hd;
 
        LIST_FOREACH(hd, &forkhook_list, hk_list) {
-               ((void (*)(struct proc *, struct proc *))*hd->hk_fn)
+               ((void (*)(struct proc *, struct proc *))(void *)*hd->hk_fn)
                    (p2, p1);
        }
 }
diff -r 7641689facfd -r 0c96a11f8f2d sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c       Wed Oct 16 15:08:09 2019 +0000
+++ b/sys/kern/kern_sig.c       Wed Oct 16 15:27:38 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sig.c,v 1.373 2019/10/15 13:59:57 kamil Exp $     */
+/*     $NetBSD: kern_sig.c,v 1.374 2019/10/16 15:27:38 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.373 2019/10/15 13:59:57 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.374 2019/10/16 15:27:38 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 *))enosys;
+    (int (*)(struct lwp *, const char *))(void *)enosys;
 
 /*
  * DTrace SDT provider definitions
diff -r 7641689facfd -r 0c96a11f8f2d sys/kern/kern_veriexec.c
--- a/sys/kern/kern_veriexec.c  Wed Oct 16 15:08:09 2019 +0000
+++ b/sys/kern/kern_veriexec.c  Wed Oct 16 15:27:38 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_veriexec.c,v 1.20 2019/04/28 21:36:19 alnsn Exp $ */
+/*     $NetBSD: kern_veriexec.c,v 1.21 2019/10/16 15:27:38 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.20 2019/04/28 21:36:19 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_veriexec.c,v 1.21 2019/10/16 15:27:38 christos Exp $");
 
 #include "opt_veriexec.h"
 
@@ -351,8 +351,8 @@
        rw_init(&veriexec_op_lock);
 
 #define        FPOPS_ADD(a, b, c, d, e, f)     \
-       veriexec_fpops_add(a, b, c, (veriexec_fpop_init_t)d, \
-        (veriexec_fpop_update_t)e, (veriexec_fpop_final_t)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)
 
 #ifdef VERIFIED_EXEC_FP_SHA256
        FPOPS_ADD("SHA256", SHA256_DIGEST_LENGTH, sizeof(SHA256_CTX),
diff -r 7641689facfd -r 0c96a11f8f2d sys/kern/subr_ipi.c
--- a/sys/kern/subr_ipi.c       Wed Oct 16 15:08:09 2019 +0000
+++ b/sys/kern/subr_ipi.c       Wed Oct 16 15:27:38 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_ipi.c,v 1.5 2019/09/05 09:20:05 ryo Exp $ */
+/*     $NetBSD: subr_ipi.c,v 1.6 2019/10/16 15:27:38 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.5 2019/09/05 09:20:05 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_ipi.c,v 1.6 2019/10/16 15:27:38 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)nullop };
+       ipi_msg_t ipimsg = { .func = (ipi_func_t)(void *)nullop };
 
        KASSERT(ipi_id != IPI_SYNCH_ID);
        KASSERT(ipi_id < IPI_MAXREG);
diff -r 7641689facfd -r 0c96a11f8f2d sys/kern/subr_pool.c
--- a/sys/kern/subr_pool.c      Wed Oct 16 15:08:09 2019 +0000
+++ b/sys/kern/subr_pool.c      Wed Oct 16 15:27:38 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_pool.c,v 1.259 2019/09/23 05:39:59 skrll Exp $    */
+/*     $NetBSD: subr_pool.c,v 1.260 2019/10/16 15:27:38 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.259 2019/09/23 05:39:59 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.260 2019/10/16 15:27:38 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -2063,10 +2063,10 @@
        mutex_init(&pc->pc_lock, MUTEX_DEFAULT, ipl);
 
        if (ctor == NULL) {
-               ctor = (int (*)(void *, void *, int))nullop;
+               ctor = (int (*)(void *, void *, int))(void *)nullop;
        }
        if (dtor == NULL) {
-               dtor = (void (*)(void *, void *))nullop;
+               dtor = (void (*)(void *, void *))(void *)nullop;
        }
 
        pc->pc_emptygroups = NULL;
@@ -2339,7 +2339,7 @@
                 * cache back to the global pool then wait for the xcall to
                 * complete.
                 */
-               where = xc_broadcast(0, (xcfunc_t)pool_cache_transfer,
+               where = xc_broadcast(0, (xcfunc_t)(void *)pool_cache_transfer,
                    pc, NULL);
                xc_wait(where);
        }
diff -r 7641689facfd -r 0c96a11f8f2d sys/kern/subr_vmem.c
--- a/sys/kern/subr_vmem.c      Wed Oct 16 15:08:09 2019 +0000
+++ b/sys/kern/subr_vmem.c      Wed Oct 16 15:27:38 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_vmem.c,v 1.97 2018/02/08 09:05:20 dholland Exp $  */
+/*     $NetBSD: subr_vmem.c,v 1.98 2019/10/16 15:27:38 christos Exp $  */
 
 /*-
  * Copyright (c)2006,2007,2008,2009 YAMAMOTO Takashi,
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.97 2018/02/08 09:05:20 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.98 2019/10/16 15:27:38 christos Exp $");
 
 #if defined(_KERNEL) && defined(_KERNEL_OPT)
 #include "opt_ddb.h"
@@ -769,8 +769,8 @@
        }
 
        if (vm->vm_flags & VM_XIMPORT) {
-               rc = ((vmem_ximport_t *)vm->vm_importfn)(vm->vm_arg, size,
-                   &size, flags, &addr);
+               rc = ((vmem_ximport_t *)(void *)vm->vm_importfn)(vm->vm_arg,
+                   size, &size, flags, &addr);
        } else {
                rc = (vm->vm_importfn)(vm->vm_arg, size, flags, &addr);
        }
@@ -1005,7 +1005,7 @@
        KASSERT((flags & (VM_XIMPORT)) == 0);
 
        return vmem_init(NULL, name, base, size, quantum,
-           (vmem_import_t *)importfn, releasefn, source,
+           (vmem_import_t *)(void *)importfn, releasefn, source,
            qcache_max, flags | VM_XIMPORT, ipl);
 }
 
diff -r 7641689facfd -r 0c96a11f8f2d sys/kern/sys_ptrace_common.c
--- a/sys/kern/sys_ptrace_common.c      Wed Oct 16 15:08:09 2019 +0000
+++ b/sys/kern/sys_ptrace_common.c      Wed Oct 16 15:27:38 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_ptrace_common.c,v 1.67 2019/10/12 12:04:37 kamil Exp $     */
+/*     $NetBSD: sys_ptrace_common.c,v 1.68 2019/10/16 15:27:38 christos Exp $  */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.67 2019/10/12 12:04:37 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.68 2019/10/16 15:27:38 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -1505,14 +1505,14 @@
                        return EINVAL;
                }
                s = sizeof(process_reg32);
-               r = (regrfunc_t)process_read_regs32;
-               w = (regwfunc_t)process_write_regs32;
+               r = (regrfunc_t)(void *)process_read_regs32;
+               w = (regwfunc_t)(void *)process_write_regs32;
        } else
 #endif
        {
                s = sizeof(struct reg);
-               r = (regrfunc_t)process_read_regs;
-               w = (regwfunc_t)process_write_regs;
+               r = (regrfunc_t)(void *)process_read_regs;
+               w = (regwfunc_t)(void *)process_write_regs;
        }
        return proc_regio(l, uio, s, r, w);
 #else
diff -r 7641689facfd -r 0c96a11f8f2d sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Wed Oct 16 15:08:09 2019 +0000
+++ b/sys/net/if_ethersubr.c    Wed Oct 16 15:27:38 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ethersubr.c,v 1.278 2019/10/02 04:17:16 msaitoh Exp $       */
+/*     $NetBSD: if_ethersubr.c,v 1.279 2019/10/16 15:27:39 christos Exp $      */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 



Home | Main Index | Thread Index | Old Index