Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/adb sanitize sysctl interface in order to appease gc...



details:   https://anonhg.NetBSD.org/src/rev/911043e4f780
branches:  trunk
changeset: 767737:911043e4f780
user:      macallan <macallan%NetBSD.org@localhost>
date:      Thu Jul 28 16:28:12 2011 +0000

description:
sanitize sysctl interface in order to appease gcc 4.5

diffstat:

 sys/dev/adb/adb_kbd.c |  63 +++++++++++++++++++++++++++++++++++---------------
 sys/dev/adb/adb_ms.c  |  20 +++++++--------
 2 files changed, 53 insertions(+), 30 deletions(-)

diffs (190 lines):

diff -r d8c42d63e1c5 -r 911043e4f780 sys/dev/adb/adb_kbd.c
--- a/sys/dev/adb/adb_kbd.c     Thu Jul 28 16:14:50 2011 +0000
+++ b/sys/dev/adb/adb_kbd.c     Thu Jul 28 16:28:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: adb_kbd.c,v 1.13 2009/03/18 10:22:39 cegger Exp $      */
+/*     $NetBSD: adb_kbd.c,v 1.14 2011/07/28 16:28:12 macallan Exp $    */
 
 /*
  * Copyright (C) 1998  Colin Wood
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adb_kbd.c,v 1.13 2009/03/18 10:22:39 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adb_kbd.c,v 1.14 2011/07/28 16:28:12 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -148,7 +148,8 @@
        adbkms_disable,
 };
 
-static int  adbkbd_sysctl_button(SYSCTLFN_ARGS);
+static int  adbkbd_sysctl_mid(SYSCTLFN_ARGS);
+static int  adbkbd_sysctl_right(SYSCTLFN_ARGS);
 static void adbkbd_setup_sysctl(struct adbkbd_softc *);
 
 #endif /* NWSMOUSE > 0 */
@@ -655,11 +656,11 @@
 static void
 adbkbd_setup_sysctl(struct adbkbd_softc *sc)
 {
-       struct sysctlnode *node, *me;
+       const struct sysctlnode *me, *node;
        int ret;
 
        DPRINTF("%s: sysctl setup\n", device_xname(sc->sc_dev));
-       ret = sysctl_createv(NULL, 0, NULL, (const struct sysctlnode **)&me,
+       ret = sysctl_createv(NULL, 0, NULL, &me,
               CTLFLAG_READWRITE,
               CTLTYPE_NODE, device_xname(sc->sc_dev), NULL,
               NULL, 0, NULL, 0,
@@ -667,42 +668,66 @@
 
        ret = sysctl_createv(NULL, 0, NULL,
            (const struct sysctlnode **)&node, 
-           CTLFLAG_READWRITE | CTLFLAG_OWNDESC | CTLFLAG_IMMEDIATE,
-           CTLTYPE_INT, "middle", "middle mouse button", adbkbd_sysctl_button, 
-                   1, NULL, 0, CTL_MACHDEP, me->sysctl_num, CTL_CREATE, 
+           CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+           CTLTYPE_INT, "middle", "middle mouse button", adbkbd_sysctl_mid, 
+                   1, sc, 0, CTL_MACHDEP, me->sysctl_num, CTL_CREATE, 
                    CTL_EOL);
-       node->sysctl_data = sc;
 
        ret = sysctl_createv(NULL, 0, NULL, 
            (const struct sysctlnode **)&node, 
-           CTLFLAG_READWRITE | CTLFLAG_OWNDESC | CTLFLAG_IMMEDIATE,
-           CTLTYPE_INT, "right", "right mouse button", adbkbd_sysctl_button, 
-                   2, NULL, 0, CTL_MACHDEP, me->sysctl_num, CTL_CREATE, 
+           CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+           CTLTYPE_INT, "right", "right mouse button", adbkbd_sysctl_right, 
+                   2, sc, 0, CTL_MACHDEP, me->sysctl_num, CTL_CREATE, 
                    CTL_EOL);
-       node->sysctl_data = sc;
 }
 
 static int
-adbkbd_sysctl_button(SYSCTLFN_ARGS)
+adbkbd_sysctl_mid(SYSCTLFN_ARGS)
 {
        struct sysctlnode node = *rnode;
        struct adbkbd_softc *sc=(struct adbkbd_softc *)node.sysctl_data;
        const int *np = newp;
-       int btn = node.sysctl_idata, reg;
+       int reg;
 
-       DPRINTF("adbkbd_sysctl_button %d\n", btn);
-       node.sysctl_idata = sc->sc_trans[btn];
-       reg = sc->sc_trans[btn];
+       DPRINTF("adbkbd_sysctl_mid\n");
+       reg = sc->sc_trans[1];
        if (np) {
                /* we're asked to write */      
                node.sysctl_data = &reg;
                if (sysctl_lookup(SYSCTLFN_CALL(&node)) == 0) {
                        
-                       sc->sc_trans[btn] = node.sysctl_idata;
+                       sc->sc_trans[1] = *(int *)node.sysctl_data;
                        return 0;
                }
                return EINVAL;
        } else {
+               node.sysctl_data = &reg;
+               node.sysctl_size = 4;
+               return (sysctl_lookup(SYSCTLFN_CALL(&node)));
+       }
+}
+
+static int
+adbkbd_sysctl_right(SYSCTLFN_ARGS)
+{
+       struct sysctlnode node = *rnode;
+       struct adbkbd_softc *sc=(struct adbkbd_softc *)node.sysctl_data;
+       const int *np = newp;
+       int reg;
+
+       DPRINTF("adbkbd_sysctl_right\n");
+       reg = sc->sc_trans[2];
+       if (np) {
+               /* we're asked to write */      
+               node.sysctl_data = &reg;
+               if (sysctl_lookup(SYSCTLFN_CALL(&node)) == 0) {
+                       
+                       sc->sc_trans[2] = *(int *)node.sysctl_data;
+                       return 0;
+               }
+               return EINVAL;
+       } else {
+               node.sysctl_data = &reg;
                node.sysctl_size = 4;
                return (sysctl_lookup(SYSCTLFN_CALL(&node)));
        }
diff -r d8c42d63e1c5 -r 911043e4f780 sys/dev/adb/adb_ms.c
--- a/sys/dev/adb/adb_ms.c      Thu Jul 28 16:14:50 2011 +0000
+++ b/sys/dev/adb/adb_ms.c      Thu Jul 28 16:28:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: adb_ms.c,v 1.9 2010/08/11 16:54:10 macallan Exp $      */
+/*     $NetBSD: adb_ms.c,v 1.10 2011/07/28 16:28:12 macallan Exp $     */
 
 /*
  * Copyright (C) 1998  Colin Wood
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adb_ms.c,v 1.9 2010/08/11 16:54:10 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adb_ms.c,v 1.10 2011/07/28 16:28:12 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -690,7 +690,7 @@
 static void
 init_trackpad(struct adbms_softc *sc)
 {
-       struct sysctlnode *me = NULL, *node = NULL;
+       const struct sysctlnode *me = NULL, *node = NULL;
        int cmd, addr, ret;
        uint8_t buffer[16];
        uint8_t b2[] = {0x99, 0x94, 0x19, 0xff, 0xb2, 0x8a, 0x1b, 0x50};
@@ -730,20 +730,17 @@
 
        sc->sc_tapping = 1;
        
-       ret = sysctl_createv(NULL, 0, NULL, (const struct sysctlnode **)&me,
+       ret = sysctl_createv(NULL, 0, NULL, &me,
            CTLFLAG_READWRITE,
            CTLTYPE_NODE, device_xname(sc->sc_dev), NULL,
            NULL, 0, NULL, 0,
            CTL_MACHDEP, CTL_CREATE, CTL_EOL);
 
-       ret = sysctl_createv(NULL, 0, NULL, (const struct sysctlnode **)&node,
-           CTLFLAG_READWRITE | CTLFLAG_OWNDESC | CTLFLAG_IMMEDIATE,
+       ret = sysctl_createv(NULL, 0, NULL, &node,
+           CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
            CTLTYPE_INT, "tapping", "tapping the pad causes button events",
-           sysctl_adbms_tap, 1, NULL, 0,
+           sysctl_adbms_tap, 1, sc, 0,
            CTL_MACHDEP, me->sysctl_num, CTL_CREATE, CTL_EOL);
-       if (node != NULL) {
-               node->sysctl_data = sc;
-       }       
 }
 
 static int
@@ -793,12 +790,13 @@
                node.sysctl_data = &sc->sc_tapping;
                if (sysctl_lookup(SYSCTLFN_CALL(&node)) == 0) {
 
-                       sc->sc_tapping = (node.sysctl_idata == 0) ? 0 : 1;
+                       sc->sc_tapping = (*(int *)node.sysctl_data == 0) ? 0 : 1;
                        return 0;
                }
                return EINVAL;
        } else {
 
+               node.sysctl_data = &sc->sc_tapping;
                node.sysctl_size = 4;
                return (sysctl_lookup(SYSCTLFN_CALL(&node)));
        }



Home | Main Index | Thread Index | Old Index