[PATCH:xf86-input-mouse] Fix Solaris issues with new ABI12 init process.

Alan Coopersmith alan.coopersmith at oracle.com
Fri Jun 24 22:52:59 PDT 2011


Based on BSD changes in commit a22879c6779283684fe4a61543fc95179b4f5d0b
by Alexandr Shadchin

Fix segfaults when mouse device fails to open.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 src/mouse.c     |    2 +
 src/mouse.h     |    1 +
 src/sun_mouse.c |   68 -------------------------------------------------------
 3 files changed, 3 insertions(+), 68 deletions(-)

diff --git a/src/mouse.c b/src/mouse.c
index c3498ea..d981f6f 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -253,6 +253,7 @@ static MouseProtocolRec mouseProtocols[] = {
     /* Misc (usually OS-specific) */
     { "SysMouse",		MSE_MISC,	mlDefaults,	PROT_SYSMOUSE },
     { "WSMouse",		MSE_MISC,	NULL,		PROT_WSMOUSE },
+    { "VUID",			MSE_MISC,	NULL,		PROT_VUID },
 
     /* end of list */
     { NULL,			MSE_NONE,	NULL,		PROT_UNKNOWN }
@@ -819,6 +820,7 @@ MousePickProtocol(InputInfoPtr pInfo, const char* device,
 
     switch (protocolID) {
         case PROT_WSMOUSE:
+        case PROT_VUID:
             if (osInfo->PreInit)
                 osInfo->PreInit(pInfo, protocol, 0);
             break;
diff --git a/src/mouse.h b/src/mouse.h
index 6e63c54..2cc588a 100644
--- a/src/mouse.h
+++ b/src/mouse.h
@@ -78,6 +78,7 @@ typedef enum {
     PROT_AUTO,
     PROT_SYSMOUSE,
     PROT_WSMOUSE,
+    PROT_VUID,
     PROT_NUMPROTOS	/* This must always be last. */
 } MouseProtocolID;
 
diff --git a/src/sun_mouse.c b/src/sun_mouse.c
index dd545c7..b0d53e8 100644
--- a/src/sun_mouse.c
+++ b/src/sun_mouse.c
@@ -212,77 +212,9 @@ vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
 	return FALSE;
     }
 
-    pMse->protocol = protocol;
-    xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
-
-    /* Collect the options, and process the common options. */
-    COLLECT_INPUT_OPTIONS(pInfo, NULL);
-    xf86ProcessCommonOptions(pInfo, pInfo->options);
-
     pVuidMse->buffer = (unsigned char *)&pVuidMse->event;
     pVuidMse->strmod = xf86SetStrOption(pInfo->options, "StreamsModule", NULL);
 
-    /* Check if the device can be opened. */
-    pInfo->fd = xf86OpenSerial(pInfo->options);
-    if (pInfo->fd == -1) {
-	if (xf86GetAllowMouseOpenFail()) {
-	    xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
-	} else {
-	    xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
-	    free(pVuidMse->strmod);
-	    free(pVuidMse);
-	    free(pMse);
-	    return FALSE;
-	}
-    } else {
-	if (pVuidMse->strmod) {
-	    /* Check to see if module is already pushed */
-	    SYSCALL(i = ioctl(pInfo->fd, I_FIND, pVuidMse->strmod));
-
-	    if (i == 0) { /* Not already pushed */
-		SYSCALL(i = ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod));
-		if (i < 0) {
-		    xf86Msg(X_ERROR,
-			"%s: cannot push module '%s' onto mouse device: %s\n",
-			pInfo->name, pVuidMse->strmod, strerror(errno));
-		    xf86CloseSerial(pInfo->fd);
-		    pInfo->fd = -1;
-		    free(pVuidMse->strmod);
-		    free(pVuidMse);
-		    free(pMse);
-		    return FALSE;
-		}
-	    }
-	}
-
-	buttons = xf86SetIntOption(pInfo->options, "Buttons", 0);
-	if (buttons == 0) {
-	    SYSCALL(i = ioctl(pInfo->fd, MSIOBUTTONS, &buttons));
-	    if (i == 0) {
-		pInfo->options =
-		    xf86ReplaceIntOption(pInfo->options,
-					 "Buttons", buttons);
-		xf86Msg(X_INFO, "%s: Setting Buttons option to \"%d\"\n",
-			pInfo->name, buttons);
-	    }
-	}
-
-	if (pVuidMse->strmod) {
-	    SYSCALL(i = ioctl(pInfo->fd, I_POP, pVuidMse->strmod));
-	    if (i == -1) {
-		xf86Msg(X_WARNING,
-			"%s: cannot pop module '%s' off mouse device: %s\n",
-			pInfo->name, pVuidMse->strmod, strerror(errno));
-	    }
-	}
-
-	xf86CloseSerial(pInfo->fd);
-	pInfo->fd = -1;
-    }
-
-    /* Process common mouse options (like Emulate3Buttons, etc). */
-    pMse->CommonOptions(pInfo);
-
     /* Setup the local procs. */
     pVuidMse->wrapped_device_control = pInfo->device_control;
     pInfo->device_control = vuidMouseProc;
-- 
1.7.3.2



More information about the xorg-devel mailing list