Source-Changes-HG archive

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

[src/trunk]: src/sys Add some pre-processor magic to verify that the type of ...



details:   https://anonhg.NetBSD.org/src/rev/1a6cbad8068b
branches:  trunk
changeset: 779552:1a6cbad8068b
user:      dsl <dsl%NetBSD.org@localhost>
date:      Sat Jun 02 21:36:41 2012 +0000

description:
Add some pre-processor magic to verify that the type of the data item
  passed to sysctl_createv() actually matches the declared type for
  the item itself.
In the places where the caller specifies a function and a structure
  address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
  sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
  AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
  fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.

diffstat:

 sys/arch/evbppc/obs405/dev/obsled.c             |   6 ++--
 sys/arch/i386/i386/machdep.c                    |   6 ++--
 sys/arch/macppc/dev/obio.c                      |  10 ++++----
 sys/arch/sparc64/dev/lom.c                      |   6 ++--
 sys/arch/x86/x86/est.c                          |   8 +++---
 sys/arch/x86/x86/odcm.c                         |   8 +++---
 sys/arch/x86/x86/powernow.c                     |   8 +++---
 sys/ddb/db_variables.c                          |   6 ++--
 sys/dev/acpi/acpi_display.c                     |  14 ++++++------
 sys/dev/acpi/acpi_power.c                       |   6 ++--
 sys/dev/acpi/asus_acpi.c                        |   8 +++---
 sys/dev/acpi/fujbp_acpi.c                       |   8 +++---
 sys/dev/acpi/fujhk_acpi.c                       |   6 ++--
 sys/dev/acpi/sony_acpi.c                        |   6 ++--
 sys/dev/adb/adb_kbd.c                           |   8 +++---
 sys/dev/adb/adb_ms.c                            |   6 ++--
 sys/dev/bluetooth/bcsp.c                        |   6 ++--
 sys/dev/bluetooth/btmagic.c                     |   8 +++---
 sys/dev/gpio/gpiopwm.c                          |   6 ++--
 sys/dev/gpio/gpiosim.c                          |   4 +-
 sys/dev/i2c/dbcool.c                            |  12 +++++-----
 sys/dev/i2c/lm75.c                              |   6 ++--
 sys/dev/ic/ac97.c                               |   8 +++---
 sys/dev/ic/ath_netbsd.h                         |   4 +-
 sys/dev/isa/toaster.c                           |  10 ++++----
 sys/dev/pci/auich.c                             |   6 ++--
 sys/dev/pci/if_iwi.c                            |   6 ++--
 sys/dev/pci/if_jme.c                            |  12 +++++-----
 sys/dev/pci/if_msk.c                            |   6 ++--
 sys/dev/pci/if_sk.c                             |   6 ++--
 sys/dev/pci/if_vte.c                            |   8 +++---
 sys/dev/pci/if_wpi.c                            |   6 ++--
 sys/dev/pci/ixgbe/ixgbe.c                       |   6 ++--
 sys/dev/pci/voyager/pwmclock.c                  |  10 ++++----
 sys/dev/pckbport/synaptics.c                    |   8 +++---
 sys/dev/usb/ubt.c                               |   6 ++--
 sys/external/bsd/acpica/dist/include/acglobal.h |   2 +-
 sys/external/bsd/acpica/dist/include/acpixf.h   |   2 +-
 sys/external/bsd/drm/dist/bsd-core/drm_sysctl.c |   2 +-
 sys/kern/init_sysctl.c                          |  10 ++++----
 sys/kern/kern_sysctl.c                          |   5 ++-
 sys/kern/vfs_bio.c                              |  10 ++++----
 sys/miscfs/syncfs/sync_subr.c                   |  12 +++++-----
 sys/net/if_etherip.c                            |   6 ++--
 sys/net/if_tap.c                                |   6 ++--
 sys/net80211/ieee80211_netbsd.c                 |   6 ++--
 sys/netinet/in_selsrc.c                         |   6 ++--
 sys/netinet/ip_input.c                          |   6 ++--
 sys/netinet/tcp_usrreq.c                        |   6 ++--
 sys/netipsec/ipsec_netbsd.c                     |   6 ++--
 sys/sys/sysctl.h                                |  29 ++++++++++++++++++++++++-
 sys/uvm/uvm_meter.c                             |   6 ++--
 52 files changed, 206 insertions(+), 178 deletions(-)

diffs (truncated from 1657 to 300 lines):

diff -r 4d92268a1c03 -r 1a6cbad8068b sys/arch/evbppc/obs405/dev/obsled.c
--- a/sys/arch/evbppc/obs405/dev/obsled.c       Sat Jun 02 21:27:51 2012 +0000
+++ b/sys/arch/evbppc/obs405/dev/obsled.c       Sat Jun 02 21:36:41 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: obsled.c,v 1.8 2011/06/18 06:44:27 matt Exp $  */
+/*     $NetBSD: obsled.c,v 1.9 2012/06/02 21:36:41 dsl Exp $   */
 
 /*
  * Copyright (c) 2004 Shigeyuki Fukushima.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: obsled.c,v 1.8 2011/06/18 06:44:27 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: obsled.c,v 1.9 2012/06/02 21:36:41 dsl Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -122,7 +122,7 @@
                        CTLFLAG_READWRITE, CTLTYPE_INT,
                        led_name,
                        SYSCTL_DESCR("OpenBlockS LED state (0=off, 1=on)"),
-                       obsled_sysctl_verify, 0, sc, 0,
+                       obsled_sysctl_verify, 0, (void *)sc, 0,
                        CTL_HW, node_mib, CTL_CREATE, CTL_EOL);
        if (err  != 0)
                return;
diff -r 4d92268a1c03 -r 1a6cbad8068b sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Sat Jun 02 21:27:51 2012 +0000
+++ b/sys/arch/i386/i386/machdep.c      Sat Jun 02 21:36:41 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.727 2012/05/21 14:15:17 martin Exp $     */
+/*     $NetBSD: machdep.c,v 1.728 2012/06/02 21:36:41 dsl Exp $        */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.727 2012/05/21 14:15:17 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.728 2012/06/02 21:36:41 dsl Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -696,7 +696,7 @@
        sysctl_createv(clog, 0, NULL, NULL, 
                       CTLFLAG_PERMANENT,
                       CTLTYPE_STRING, "cpu_brand", NULL,
-                      NULL, 0, &cpu_brand_string, 0,
+                      NULL, 0, cpu_brand_string, 0,
                       CTL_MACHDEP, CTL_CREATE, CTL_EOL);
        sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
diff -r 4d92268a1c03 -r 1a6cbad8068b sys/arch/macppc/dev/obio.c
--- a/sys/arch/macppc/dev/obio.c        Sat Jun 02 21:27:51 2012 +0000
+++ b/sys/arch/macppc/dev/obio.c        Sat Jun 02 21:36:41 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: obio.c,v 1.36 2011/10/19 21:12:50 macallan Exp $       */
+/*     $NetBSD: obio.c,v 1.37 2012/06/02 21:36:42 dsl Exp $    */
 
 /*-
  * Copyright (C) 1998  Internet Research Institute, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.36 2011/10/19 21:12:50 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.37 2012/06/02 21:36:42 dsl Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -431,7 +431,7 @@
            &sysctl_node, 
            CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
            CTLTYPE_INT, "target", "CPU speed", sysctl_cpuspeed_temp, 
-           0, sc, 0, CTL_MACHDEP, me->sysctl_num, freq->sysctl_num, 
+           0, (void *)sc, 0, CTL_MACHDEP, me->sysctl_num, freq->sysctl_num, 
            CTL_CREATE, CTL_EOL) == 0) {
        } else
                printf("couldn't create 'target' node\n");
@@ -440,7 +440,7 @@
            &sysctl_node, 
            CTLFLAG_READWRITE,
            CTLTYPE_INT, "current", NULL, sysctl_cpuspeed_cur, 
-           1, sc, 0, CTL_MACHDEP, me->sysctl_num, freq->sysctl_num, 
+           1, (void *)sc, 0, CTL_MACHDEP, me->sysctl_num, freq->sysctl_num, 
            CTL_CREATE, CTL_EOL) == 0) {
        } else
                printf("couldn't create 'current' node\n");
@@ -449,7 +449,7 @@
            &sysctl_node, 
            CTLFLAG_READWRITE,
            CTLTYPE_STRING, "available", NULL, sysctl_cpuspeed_available, 
-           2, sc, 0, CTL_MACHDEP, me->sysctl_num, freq->sysctl_num, 
+           2, (void *)sc, 0, CTL_MACHDEP, me->sysctl_num, freq->sysctl_num, 
            CTL_CREATE, CTL_EOL) == 0) {
        } else
                printf("couldn't create 'available' node\n");
diff -r 4d92268a1c03 -r 1a6cbad8068b sys/arch/sparc64/dev/lom.c
--- a/sys/arch/sparc64/dev/lom.c        Sat Jun 02 21:27:51 2012 +0000
+++ b/sys/arch/sparc64/dev/lom.c        Sat Jun 02 21:36:41 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lom.c,v 1.9 2011/06/20 17:01:45 pgoyette Exp $ */
+/*     $NetBSD: lom.c,v 1.10 2012/06/02 21:36:42 dsl Exp $     */
 /*     $OpenBSD: lom.c,v 1.21 2010/02/28 20:44:39 kettenis Exp $       */
 /*
  * Copyright (c) 2009 Mark Kettenis
@@ -17,7 +17,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.9 2011/06/20 17:01:45 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.10 2012/06/02 21:36:42 dsl Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -363,7 +363,7 @@
                        sysctl_createv(NULL, 0, NULL, &newnode,
                            CTLFLAG_READWRITE, CTLTYPE_INT, nodename[i],
                            SYSCTL_DESCR(nodedesc[i]),
-                           lom_sysctl_alarm, 0, sc, 0,
+                           lom_sysctl_alarm, 0, (void *)sc, 0,
                            CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL);
                        if (newnode != NULL)
                                sc->sc_sysctl_num[i] = newnode->sysctl_num;
diff -r 4d92268a1c03 -r 1a6cbad8068b sys/arch/x86/x86/est.c
--- a/sys/arch/x86/x86/est.c    Sat Jun 02 21:27:51 2012 +0000
+++ b/sys/arch/x86/x86/est.c    Sat Jun 02 21:36:41 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: est.c,v 1.24 2011/03/04 04:53:28 jruoho Exp $  */
+/*     $NetBSD: est.c,v 1.25 2012/06/02 21:36:42 dsl Exp $     */
 /*
  * Copyright (c) 2003 Michael Eriksson.
  * All rights reserved.
@@ -76,7 +76,7 @@
  *   http://www.codemonkey.org.uk/projects/cpufreq/cpufreq-2.4.22-pre6-1.gz
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.24 2011/03/04 04:53:28 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.25 2012/06/02 21:36:42 dsl Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -1333,7 +1333,7 @@
 
        rv = sysctl_createv(&sc->sc_log, 0, &freqnode, &node,
            CTLFLAG_READWRITE, CTLTYPE_INT, "target", NULL,
-           est_sysctl_helper, 0, sc, 0, CTL_CREATE, CTL_EOL);
+           est_sysctl_helper, 0, (void *)sc, 0, CTL_CREATE, CTL_EOL);
 
        if (rv != 0)
                goto fail;
@@ -1342,7 +1342,7 @@
 
        rv = sysctl_createv(&sc->sc_log, 0, &freqnode, &node,
            0, CTLTYPE_INT, "current", NULL,
-           est_sysctl_helper, 0, sc, 0, CTL_CREATE, CTL_EOL);
+           est_sysctl_helper, 0, (void *)sc, 0, CTL_CREATE, CTL_EOL);
 
        if (rv != 0)
                goto fail;
diff -r 4d92268a1c03 -r 1a6cbad8068b sys/arch/x86/x86/odcm.c
--- a/sys/arch/x86/x86/odcm.c   Sat Jun 02 21:27:51 2012 +0000
+++ b/sys/arch/x86/x86/odcm.c   Sat Jun 02 21:36:41 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: odcm.c,v 1.1 2011/03/04 04:48:39 jruoho Exp $ */
+/*     $NetBSD: odcm.c,v 1.2 2012/06/02 21:36:42 dsl Exp $ */
 /*      $OpenBSD: p4tcc.c,v 1.13 2006/12/20 17:50:40 gwk Exp $ */
 
 /*
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: odcm.c,v 1.1 2011/03/04 04:48:39 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: odcm.c,v 1.2 2012/06/02 21:36:42 dsl Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -243,7 +243,7 @@
        rv = sysctl_createv(&sc->sc_log, 0, &odcmnode, &node,
            CTLFLAG_READWRITE, CTLTYPE_INT, "target",
            SYSCTL_DESCR("target duty cycle (0 = lowest, 7 highest)"),
-           odcm_sysctl_helper, 0, sc, 0, CTL_CREATE, CTL_EOL);
+           odcm_sysctl_helper, 0, (void *)sc, 0, CTL_CREATE, CTL_EOL);
 
        if (rv != 0)
                goto fail;
@@ -253,7 +253,7 @@
        rv = sysctl_createv(&sc->sc_log, 0, &odcmnode, &node,
            0, CTLTYPE_INT, "current",
            SYSCTL_DESCR("current duty cycle"),
-           odcm_sysctl_helper, 0, sc, 0, CTL_CREATE, CTL_EOL);
+           odcm_sysctl_helper, 0, (void *)sc, 0, CTL_CREATE, CTL_EOL);
 
        if (rv != 0)
                goto fail;
diff -r 4d92268a1c03 -r 1a6cbad8068b sys/arch/x86/x86/powernow.c
--- a/sys/arch/x86/x86/powernow.c       Sat Jun 02 21:27:51 2012 +0000
+++ b/sys/arch/x86/x86/powernow.c       Sat Jun 02 21:36:41 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: powernow.c,v 1.4 2011/10/29 09:58:23 jnemeth Exp $ */
+/*     $NetBSD: powernow.c,v 1.5 2012/06/02 21:36:42 dsl Exp $ */
 /*     $OpenBSD: powernow-k8.c,v 1.8 2006/06/16 05:58:50 gwk Exp $ */
 
 /*-
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: powernow.c,v 1.4 2011/10/29 09:58:23 jnemeth Exp $");
+__KERNEL_RCSID(0, "$NetBSD: powernow.c,v 1.5 2012/06/02 21:36:42 dsl Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -279,7 +279,7 @@
 
        rv = sysctl_createv(&sc->sc_log, 0, &freqnode, &node,
            CTLFLAG_READWRITE, CTLTYPE_INT, "target", NULL,
-           powernow_sysctl_helper, 0, sc, 0, CTL_CREATE, CTL_EOL);
+           powernow_sysctl_helper, 0, (void *)sc, 0, CTL_CREATE, CTL_EOL);
 
        if (rv != 0)
                goto fail;
@@ -288,7 +288,7 @@
 
        rv = sysctl_createv(&sc->sc_log, 0, &freqnode, &node,
            0, CTLTYPE_INT, "current", NULL,
-           powernow_sysctl_helper, 0, sc, 0, CTL_CREATE, CTL_EOL);
+           powernow_sysctl_helper, 0, (void *)sc, 0, CTL_CREATE, CTL_EOL);
 
        if (rv != 0)
                goto fail;
diff -r 4d92268a1c03 -r 1a6cbad8068b sys/ddb/db_variables.c
--- a/sys/ddb/db_variables.c    Sat Jun 02 21:27:51 2012 +0000
+++ b/sys/ddb/db_variables.c    Sat Jun 02 21:36:41 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_variables.c,v 1.42 2009/03/11 23:22:57 martin Exp $ */
+/*     $NetBSD: db_variables.c,v 1.43 2012/06/02 21:36:42 dsl Exp $    */
 
 /*
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_variables.c,v 1.42 2009/03/11 23:22:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_variables.c,v 1.43 2012/06/02 21:36:42 dsl Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddbparam.h"
@@ -165,7 +165,7 @@
                       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
                       CTLTYPE_STRING, "commandonenter",
                       SYSCTL_DESCR("Command to be executed on each ddb enter"),
-                      NULL, 0, &db_cmd_on_enter, DB_LINE_MAXLEN,
+                      NULL, 0, db_cmd_on_enter, DB_LINE_MAXLEN,
                       CTL_DDB, CTL_CREATE, CTL_EOL);
 }
 #endif /* _KERNEL */
diff -r 4d92268a1c03 -r 1a6cbad8068b sys/dev/acpi/acpi_display.c
--- a/sys/dev/acpi/acpi_display.c       Sat Jun 02 21:27:51 2012 +0000
+++ b/sys/dev/acpi/acpi_display.c       Sat Jun 02 21:36:41 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_display.c,v 1.9 2011/02/16 09:05:12 jruoho Exp $  */
+/*     $NetBSD: acpi_display.c,v 1.10 2012/06/02 21:36:43 dsl Exp $    */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_display.c,v 1.9 2011/02/16 09:05:12 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_display.c,v 1.10 2012/06/02 21:36:43 dsl Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -1133,14 +1133,14 @@
                (void)sysctl_createv(&asc->sc_log, 0, &rnode, NULL,
                    CTLFLAG_READWRITE | CTLFLAG_HEX, CTLTYPE_INT, "bios_policy",
                    SYSCTL_DESCR("Current BIOS switch policies (debug)"),
-                   acpidisp_vga_sysctl_policy, 0, asc, 0,
+                   acpidisp_vga_sysctl_policy, 0, (void *)asc, 0,
                    CTL_CREATE, CTL_EOL);
 #endif
 
                (void)sysctl_createv(&asc->sc_log, 0, &rnode, NULL,
                    CTLFLAG_READWRITE, CTLTYPE_BOOL, "bios_switch",
                    SYSCTL_DESCR("Current BIOS output switching policy"),
-                   acpidisp_vga_sysctl_policy_output, 0, asc, 0,
+                   acpidisp_vga_sysctl_policy_output, 0, (void *)asc, 0,
                    CTL_CREATE, CTL_EOL);
        }
 
@@ -1186,7 +1186,7 @@
                (void)sysctl_createv(&osc->sc_log, 0, &rnode, NULL,
                    CTLFLAG_READWRITE, CTLTYPE_INT, "brightness",
                    SYSCTL_DESCR("Current brightness level"),



Home | Main Index | Thread Index | Old Index