[PATCH 2/4] Replace a few BUG_WARN with BUG_RETURN_VAL

Peter Hutterer peter.hutterer at who-t.net
Tue May 15 03:26:39 PDT 2012


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 Xi/exevents.c   |   25 ++++++++++---------------
 dix/getevents.c |    5 +----
 dix/touch.c     |   17 ++++++-----------
 3 files changed, 17 insertions(+), 30 deletions(-)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 3aa9030..7fbaa8f 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -948,10 +948,10 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent *event)
     else if (event->type == ET_ProximityOut)
         device->proximity->in_proximity = FALSE;
     else if (event->type == ET_TouchBegin) {
-        BUG_WARN(!b || !v);
-        BUG_WARN(!t);
+        BUG_RETURN_VAL(!b || !v, DONT_PROCESS);
+        BUG_RETURN_VAL(!t, DONT_PROCESS);
 
-        if (!b || !t || !b->map[key])
+        if (!b->map[key])
             return DONT_PROCESS;
 
         if (!(event->flags & TOUCH_POINTER_EMULATED) ||
@@ -963,10 +963,10 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent *event)
         UpdateDeviceMotionMask(device, t->state, DeviceButtonMotionMask);
     }
     else if (event->type == ET_TouchEnd) {
-        BUG_WARN(!b || !v);
-        BUG_WARN(!t);
+        BUG_RETURN_VAL(!b || !v, DONT_PROCESS);
+        BUG_RETURN_VAL(!t, DONT_PROCESS);
 
-        if (!b || !t || t->buttonsDown <= 0 || !b->map[key])
+        if (t->buttonsDown <= 0 || !b->map[key])
             return DONT_PROCESS;
 
         if (!(event->flags & TOUCH_POINTER_EMULATED))
@@ -1345,9 +1345,8 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
                                    wOtherInputMasks(*win)->inputClients, next)
                 if (xi2mask_isset(iclients->xi2mask, dev, evtype))
                 break;
-            BUG_WARN(!iclients);
-            if (!iclients)
-                return FALSE;
+
+            BUG_RETURN_VAL(!iclients, FALSE);
 
             *mask = iclients->xi2mask;
             *client = rClient(iclients);
@@ -1360,9 +1359,7 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
                                    wOtherInputMasks(*win)->inputClients, next)
                 if (iclients->mask[dev->id] & xi_filter)
                 break;
-            BUG_WARN(!iclients);
-            if (!iclients)
-                return FALSE;
+            BUG_RETURN_VAL(!iclients, FALSE);
 
             *client = rClient(iclients);
         }
@@ -1403,9 +1400,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
         return Success;
 
     nevents = TouchConvertToPointerEvent(ev, &motion, &button);
-    BUG_WARN(nevents == 0);
-    if (nevents == 0)
-        return BadValue;
+    BUG_RETURN_VAL(nevents == 0, BadValue);
 
     if (nevents > 1)
         ptrev = &button;
diff --git a/dix/getevents.c b/dix/getevents.c
index d466ebb..8fc1f8d 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1814,10 +1814,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
 
     if (flags & TOUCH_CLIENT_ID) {      /* A DIX-submitted TouchEnd */
         touchpoint.dix_ti = TouchFindByClientID(dev, ddx_touchid);
-        BUG_WARN(!touchpoint.dix_ti);
-
-        if (!touchpoint.dix_ti)
-            return 0;
+        BUG_RETURN_VAL(!touchpoint.dix_ti, 0);
 
         if (!mask_in ||
             !valuator_mask_isset(mask_in, 0) ||
diff --git a/dix/touch.c b/dix/touch.c
index b45aa24..eeb158e 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -598,8 +598,8 @@ TouchConvertToPointerEvent(const InternalEvent *event,
     int ptrtype;
     int nevents = 0;
 
-    BUG_WARN(!event);
-    BUG_WARN(!motion_event);
+    BUG_RETURN_VAL(!event, 0);
+    BUG_RETURN_VAL(!motion_event, 0);
 
     switch (event->any.type) {
     case ET_TouchUpdate:
@@ -627,7 +627,7 @@ TouchConvertToPointerEvent(const InternalEvent *event,
     motion_event->device_event.flags = XIPointerEmulated;
 
     if (nevents > 1) {
-        BUG_WARN(!button_event);
+        BUG_RETURN_VAL(!button_event, 0);
         *button_event = *event;
         button_event->any.type = ptrtype;
         button_event->device_event.flags = XIPointerEmulated;
@@ -966,10 +966,8 @@ TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti, int listener,
     int nev;
     int i;
 
-    BUG_WARN(listener < 0);
-    BUG_WARN(listener >= ti->num_listeners);
-    if (listener < 0 || listener >= ti->num_listeners)
-        return BadMatch;
+    BUG_RETURN_VAL(listener < 0, BadMatch);
+    BUG_RETURN_VAL(listener >= ti->num_listeners, BadMatch);
 
     if (listener > 0) {
         if (mode == XIRejectTouch)
@@ -981,10 +979,7 @@ TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti, int listener,
     }
 
     events = InitEventList(GetMaximumEventsNum());
-    if (!events) {
-        BUG_WARN_MSG(TRUE, "Failed to allocate touch ownership events\n");
-        return BadAlloc;
-    }
+    BUG_RETURN_VAL_MSG(!events, BadAlloc, "Failed to allocate touch ownership events\n");
 
     nev = GetTouchOwnershipEvents(events, dev, ti, mode,
                                   ti->listeners[0].listener, 0);
-- 
1.7.10.1



More information about the xorg-devel mailing list