summaryrefslogtreecommitdiff
authorPeter Hutterer <peter.hutterer@redhat.com>2008-11-26 04:15:04 (GMT)
committer Peter Hutterer <peter.hutterer@redhat.com>2008-12-02 05:50:38 (GMT)
commitd507f60689f4e14383b0d24e63afc8cf836360d5 (patch) (side-by-side diff)
tree075fb14c8af08737f61a2e502a45fc4538083aa7
parent9bf761468fa3baf4c5fa40efa717b4b581d920f9 (diff)
downloadxserver-d507f60689f4e14383b0d24e63afc8cf836360d5.zip
xserver-d507f60689f4e14383b0d24e63afc8cf836360d5.tar.gz
xfree86: don't FatalError on "too many input devices".
Just ignore devices after MAXDEVICES has been reached, but warn the user that the devices are ignored. Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--hw/xfree86/common/xf86InPriv.h2
-rw-r--r--hw/xfree86/common/xf86Init.c4
-rw-r--r--hw/xfree86/common/xf86Xinput.c29
-rw-r--r--hw/xfree86/common/xf86Xinput.h2
4 files changed, 29 insertions, 8 deletions
diff --git a/hw/xfree86/common/xf86InPriv.h b/hw/xfree86/common/xf86InPriv.h
index 62e4820..3838d69 100644
--- a/hw/xfree86/common/xf86InPriv.h
+++ b/hw/xfree86/common/xf86InPriv.h
@@ -38,7 +38,7 @@ extern InputDriverPtr *xf86InputDriverList;
extern int xf86NumInputDrivers;
/* xf86Xinput.c */
-void xf86ActivateDevice(InputInfoPtr pInfo);
+int xf86ActivateDevice(InputInfoPtr pInfo);
/* xf86Helper.c */
InputDriverPtr xf86LookupInputDriver(const char *name);
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index b2bf8db..01acb8e 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1322,7 +1322,9 @@ InitInput(argc, argv)
strcpy((*pDev)->driver, "kbd");
}
- xf86NewInputDevice(*pDev, &dev, TRUE);
+ /* If one fails, the others will too */
+ if (xf86NewInputDevice(*pDev, &dev, TRUE) == BadAlloc)
+ break;
}
mieqInit();
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 376af77..89a27c7 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -287,12 +287,13 @@ xf86ProcessCommonOptions(LocalDevicePtr local,
/***********************************************************************
*
* xf86ActivateDevice --
- *
+ *
* Initialize an input device.
*
+ * Returns TRUE on success, or FALSE otherwise.
***********************************************************************
*/
-_X_EXPORT void
+_X_EXPORT int
xf86ActivateDevice(LocalDevicePtr local)
{
DeviceIntPtr dev;
@@ -301,8 +302,13 @@ xf86ActivateDevice(LocalDevicePtr local)
dev = AddInputDevice(serverClient, local->device_control, TRUE);
if (dev == NULL)
- FatalError("Too many input devices");
-
+ {
+ xf86Msg(X_ERROR, "Too many input devices. Ignoring %s\n",
+ local->name);
+ local->dev = NULL;
+ return FALSE;
+ }
+
local->atom = MakeAtom(local->type_name,
strlen(local->type_name),
TRUE);
@@ -334,6 +340,8 @@ xf86ActivateDevice(LocalDevicePtr local)
xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n",
local->name, local->type_name);
}
+
+ return TRUE;
}
@@ -470,6 +478,13 @@ AddOtherInputDevices()
/**
* Create a new input device, activate and enable it.
*
+ * Possible return codes:
+ * BadName .. a bad driver name was supplied.
+ * BadImplementation ... The driver does not have a PreInit function. This
+ * is a driver bug.
+ * BadMatch .. device initialization failed.
+ * BadAlloc .. too many input devices
+ *
* @param idev The device, already set up with identifier, driver, and the
* options.
* @param pdev Pointer to the new device, if Success was reported.
@@ -519,7 +534,11 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
goto unwind;
}
- xf86ActivateDevice(pInfo);
+ if (!xf86ActivateDevice(pInfo))
+ {
+ rval = BadAlloc;
+ goto unwind;
+ }
dev = pInfo->dev;
ActivateDevice(dev);
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index d7f50e0..bfd7f89 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -169,7 +169,7 @@ void xf86PostKeyEvent(DeviceIntPtr device, unsigned int key_code, int is_down,
...);
void xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int key_code,
int is_down);
-void xf86ActivateDevice(LocalDevicePtr local);
+int xf86ActivateDevice(LocalDevicePtr local);
LocalDevicePtr xf86FirstLocalDevice(void);
int xf86ScaleAxis(int Cx, int Sxhigh, int Sxlow, int Rxhigh, int Rxlow);
void xf86XInputSetScreen(LocalDevicePtr local, int screen_number, int x, int y);