On Thu, May 9, 2013 at 2:30 PM, Peter Hutterer <[email protected]> wrote: > If drivers supply incorrect values don't just quietly return False, spew to > the log so we can detect what's going on. All these cases are driver bugs > and should be fixed immediately. > > Signed-off-by: Peter Hutterer <[email protected]>
yay logged asserts. Reviewed-by: Dave Airlie <[email protected]> > --- > Xi/exevents.c | 16 ++++++++++------ > dix/devices.c | 39 +++++++++++++++++++++++++++++++-------- > xkb/xkbInit.c | 5 +++-- > 3 files changed, 44 insertions(+), 16 deletions(-) > > diff --git a/Xi/exevents.c b/Xi/exevents.c > index 06f309a..e93b016 100644 > --- a/Xi/exevents.c > +++ b/Xi/exevents.c > @@ -2020,6 +2020,9 @@ InitProximityClassDeviceStruct(DeviceIntPtr dev) > { > ProximityClassPtr proxc; > > + BUG_RETURN_VAL(dev == NULL, FALSE); > + BUG_RETURN_VAL(dev->proximity != NULL, FALSE); > + > proxc = (ProximityClassPtr) malloc(sizeof(ProximityClassRec)); > if (!proxc) > return FALSE; > @@ -2045,10 +2048,10 @@ InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, > Atom label, int minval, > { > AxisInfoPtr ax; > > - if (!dev || !dev->valuator || (minval > maxval && mode == Absolute)) > - return FALSE; > - if (axnum >= dev->valuator->numAxes) > - return FALSE; > + BUG_RETURN_VAL(dev == NULL, FALSE); > + BUG_RETURN_VAL(dev->valuator == NULL, FALSE); > + BUG_RETURN_VAL(axnum >= dev->valuator->numAxes, FALSE); > + BUG_RETURN_VAL(minval > maxval && mode == Absolute, FALSE); > > ax = dev->valuator->axes + axnum; > > @@ -2078,8 +2081,9 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum > ScrollType type, > InternalEvent dce; > DeviceIntPtr master; > > - if (!dev || !dev->valuator || axnum >= dev->valuator->numAxes) > - return FALSE; > + BUG_RETURN_VAL(dev == NULL, FALSE); > + BUG_RETURN_VAL(dev->valuator == NULL, FALSE); > + BUG_RETURN_VAL(axnum >= dev->valuator->numAxes, FALSE); > > switch (type) { > case SCROLL_TYPE_VERTICAL: > diff --git a/dix/devices.c b/dix/devices.c > index 3188fb7..b507fe0 100644 > --- a/dix/devices.c > +++ b/dix/devices.c > @@ -1276,6 +1276,9 @@ InitButtonClassDeviceStruct(DeviceIntPtr dev, int > numButtons, Atom *labels, > ButtonClassPtr butc; > int i; > > + BUG_RETURN_VAL(dev == NULL, FALSE); > + BUG_RETURN_VAL(dev->button != NULL, FALSE); > + > butc = calloc(1, sizeof(ButtonClassRec)); > if (!butc) > return FALSE; > @@ -1336,8 +1339,7 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int > numAxes, Atom *labels, > int i; > ValuatorClassPtr valc; > > - if (!dev) > - return FALSE; > + BUG_RETURN_VAL(dev == NULL, FALSE); > > if (numAxes > MAX_VALUATORS) { > LogMessage(X_WARNING, > @@ -1446,6 +1448,9 @@ InitFocusClassDeviceStruct(DeviceIntPtr dev) > { > FocusClassPtr focc; > > + BUG_RETURN_VAL(dev == NULL, FALSE); > + BUG_RETURN_VAL(dev->focus != NULL, FALSE); > + > focc = malloc(sizeof(FocusClassRec)); > if (!focc) > return FALSE; > @@ -1465,6 +1470,9 @@ InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, > PtrCtrlProcPtr controlProc) > { > PtrFeedbackPtr feedc; > > + BUG_RETURN_VAL(dev == NULL, FALSE); > + BUG_RETURN_VAL(dev->ptrfeed != NULL, FALSE); > + > feedc = malloc(sizeof(PtrFeedbackClassRec)); > if (!feedc) > return FALSE; > @@ -1506,6 +1514,9 @@ InitStringFeedbackClassDeviceStruct(DeviceIntPtr dev, > int i; > StringFeedbackPtr feedc; > > + BUG_RETURN_VAL(dev == NULL, FALSE); > + BUG_RETURN_VAL(dev->stringfeed != NULL, FALSE); > + > feedc = malloc(sizeof(StringFeedbackClassRec)); > if (!feedc) > return FALSE; > @@ -1540,6 +1551,9 @@ InitBellFeedbackClassDeviceStruct(DeviceIntPtr dev, > BellProcPtr bellProc, > { > BellFeedbackPtr feedc; > > + BUG_RETURN_VAL(dev == NULL, FALSE); > + BUG_RETURN_VAL(dev->bell != NULL, FALSE); > + > feedc = malloc(sizeof(BellFeedbackClassRec)); > if (!feedc) > return FALSE; > @@ -1559,6 +1573,9 @@ InitLedFeedbackClassDeviceStruct(DeviceIntPtr dev, > LedCtrlProcPtr controlProc) > { > LedFeedbackPtr feedc; > > + BUG_RETURN_VAL(dev == NULL, FALSE); > + BUG_RETURN_VAL(dev->leds != NULL, FALSE); > + > feedc = malloc(sizeof(LedFeedbackClassRec)); > if (!feedc) > return FALSE; > @@ -1579,6 +1596,9 @@ InitIntegerFeedbackClassDeviceStruct(DeviceIntPtr dev, > { > IntegerFeedbackPtr feedc; > > + BUG_RETURN_VAL(dev == NULL, FALSE); > + BUG_RETURN_VAL(dev->intfeed != NULL, FALSE); > + > feedc = malloc(sizeof(IntegerFeedbackClassRec)); > if (!feedc) > return FALSE; > @@ -1599,6 +1619,11 @@ InitPointerDeviceStruct(DevicePtr device, CARD8 *map, > int numButtons, > { > DeviceIntPtr dev = (DeviceIntPtr) device; > > + BUG_RETURN_VAL(dev == NULL, FALSE); > + BUG_RETURN_VAL(dev->button != NULL, FALSE); > + BUG_RETURN_VAL(dev->valuator != NULL, FALSE); > + BUG_RETURN_VAL(dev->ptrfeed != NULL, FALSE); > + > return (InitButtonClassDeviceStruct(dev, numButtons, btn_labels, map) && > InitValuatorClassDeviceStruct(dev, numAxes, axes_labels, > numMotionEvents, Relative) && > @@ -1619,14 +1644,12 @@ InitTouchClassDeviceStruct(DeviceIntPtr device, > unsigned int max_touches, > TouchClassPtr touch; > int i; > > - if (device->touch || !device->valuator) > - return FALSE; > + BUG_RETURN_VAL(device == NULL, FALSE); > + BUG_RETURN_VAL(device->touch != NULL, FALSE); > > /* Check the mode is valid, and at least X and Y axes. */ > - if (mode != XIDirectTouch && mode != XIDependentTouch) > - return FALSE; > - if (num_axes < 2) > - return FALSE; > + BUG_RETURN_VAL(mode != XIDirectTouch && mode != XIDependentTouch, FALSE); > + BUG_RETURN_VAL(num_axes < 2, FALSE); > > if (num_axes > MAX_VALUATORS) { > LogMessage(X_WARNING, > diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c > index ed01114..8f36fff 100644 > --- a/xkb/xkbInit.c > +++ b/xkb/xkbInit.c > @@ -488,8 +488,9 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet * > rmlvo, > XkbEventCauseRec cause; > XkbRMLVOSet rmlvo_dflts = { NULL }; > > - if (dev->key || dev->kbdfeed) > - return FALSE; > + BUG_RETURN_VAL(dev == NULL, FALSE); > + BUG_RETURN_VAL(dev->key != NULL, FALSE); > + BUG_RETURN_VAL(dev->kbdfeed != NULL, FALSE); > > if (!rmlvo) { > rmlvo = &rmlvo_dflts; > -- > 1.8.1.4 > > _______________________________________________ > [email protected]: X.Org development > Archives: http://lists.x.org/archives/xorg-devel > Info: http://lists.x.org/mailman/listinfo/xorg-devel _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
