[PATCH 5/6] xserver: Small interface change (xf86ActivateDevice)

Magnus Vigerlöf Magnus.Vigerlof at home.se
Wed Mar 28 15:11:21 PDT 2007


Return type change on xf86ActivateDevice

Changed the behaviour of the function to return a fault value instead
of calling 'FatalError' when too many devices are attached.

--
 hw/xfree86/common/xf86InPriv.h |    2 +-
 hw/xfree86/common/xf86Xinput.c |   19 ++++++++++++-------
 hw/xfree86/common/xf86Xinput.h |    2 +-
 3 files changed, 14 insertions(+), 9 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 *xf86InputDriverLi
 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/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 7ccca97..82e4793 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -145,7 +145,7 @@ xf86ProcessCommonOptions(LocalDevicePtr 
  *
  ***********************************************************************
  */
-_X_EXPORT void
+_X_EXPORT int
 xf86ActivateDevice(LocalDevicePtr local)
 {
     DeviceIntPtr	dev;
@@ -153,16 +153,17 @@ xf86ActivateDevice(LocalDevicePtr local)
     if (local->flags & XI86_CONFIGURED) {
         dev = AddInputDevice(local->device_control, TRUE);
 
-        if (dev == NULL)
-            FatalError("Too many input devices");
-        
+        if (!dev) {
+            xf86Msg(X_ERROR, "%s: too many input devices\n", local->name);
+            return BadAlloc;
+        }
         local->atom = MakeAtom(local->type_name,
                                strlen(local->type_name),
                                TRUE);
         AssignTypeAndName(dev, local->atom, local->name);
         dev->public.devicePrivate = (pointer) local;
-        local->dev = dev;      
-        
+        local->dev = dev;
+
         dev->coreEvents = local->flags & XI86_ALWAYS_CORE;
         RegisterOtherDevice(dev);
 
@@ -170,6 +171,7 @@ xf86ActivateDevice(LocalDevicePtr local)
             xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" 
(type: %s)\n",
                     local->name, local->type_name);
     }
+    return Success;
 }
 
 
@@ -402,7 +404,10 @@ NewInputDeviceRequest (InputOption *opti
         goto unwind;
     }
 
-    xf86ActivateDevice(pInfo);
+    if(xf86ActivateDevice(pInfo) != Success) {
+        rval = BadAlloc;
+        goto unwind;
+    }
 
     dev = pInfo->dev;
     ActivateDevice(dev);
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index b2bc8de..b5b21e5 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -174,7 +174,7 @@ void xf86PostKeyEvent(DeviceIntPtr devic
 void xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int key_code,
                            int is_down);
 void xf86XinputFinalizeInit(DeviceIntPtr dev);
-void xf86ActivateDevice(LocalDevicePtr local);
+int xf86ActivateDevice(LocalDevicePtr local);
 Bool xf86CheckButton(int button, int down);
 void xf86SwitchCoreDevice(LocalDevicePtr device, DeviceIntPtr core);
 LocalDevicePtr xf86FirstLocalDevice(void);



More information about the xorg mailing list