diff options
| author | macallan <macallan@NetBSD.org> | 2011-07-28 16:28:12 +0000 |
|---|---|---|
| committer | macallan <macallan@NetBSD.org> | 2011-07-28 16:28:12 +0000 |
| commit | 4c68fd8bfe7070c838b375046f64a5805effea90 (patch) | |
| tree | e51e99a1141fd6eb101fdcbe150c11f46ac6c679 /sys/dev | |
| parent | 89bf745fcd53a00ec1447f9a5ab5016cea579975 (diff) | |
sanitize sysctl interface in order to appease gcc 4.5
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/adb/adb_kbd.c | 63 | ||||
| -rw-r--r-- | sys/dev/adb/adb_ms.c | 20 |
2 files changed, 53 insertions, 30 deletions
diff --git a/sys/dev/adb/adb_kbd.c b/sys/dev/adb/adb_kbd.c index 391e1274699..1d5ab17d0b1 100644 --- a/sys/dev/adb/adb_kbd.c +++ b/sys/dev/adb/adb_kbd.c @@ -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 @@ const struct wsmouse_accessops adbkms_accessops = { 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 @@ adbkms_disable(void *v) 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 @@ adbkbd_setup_sysctl(struct adbkbd_softc *sc) 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 = ® 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 = ® + 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 = ® + if (sysctl_lookup(SYSCTLFN_CALL(&node)) == 0) { + + sc->sc_trans[2] = *(int *)node.sysctl_data; + return 0; + } + return EINVAL; + } else { + node.sysctl_data = ® node.sysctl_size = 4; return (sysctl_lookup(SYSCTLFN_CALL(&node))); } diff --git a/sys/dev/adb/adb_ms.c b/sys/dev/adb/adb_ms.c index 960fa230427..9e65808647f 100644 --- a/sys/dev/adb/adb_ms.c +++ b/sys/dev/adb/adb_ms.c @@ -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 @@ adbms_disable(void *v) 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 @@ init_trackpad(struct adbms_softc *sc) 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 @@ sysctl_adbms_tap(SYSCTLFN_ARGS) 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))); } |
