input: print warnings if drivers don't initialize properly
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 <peter.hutterer@who-t.net> Reviewed-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
8a88b0ab52
commit
2f1aedcaed
|
@ -2023,6 +2023,9 @@ InitProximityClassDeviceStruct(DeviceIntPtr dev)
|
||||||
{
|
{
|
||||||
ProximityClassPtr proxc;
|
ProximityClassPtr proxc;
|
||||||
|
|
||||||
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
|
BUG_RETURN_VAL(dev->proximity != NULL, FALSE);
|
||||||
|
|
||||||
proxc = (ProximityClassPtr) malloc(sizeof(ProximityClassRec));
|
proxc = (ProximityClassPtr) malloc(sizeof(ProximityClassRec));
|
||||||
if (!proxc)
|
if (!proxc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -2048,10 +2051,10 @@ InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval,
|
||||||
{
|
{
|
||||||
AxisInfoPtr ax;
|
AxisInfoPtr ax;
|
||||||
|
|
||||||
if (!dev || !dev->valuator || (minval > maxval && mode == Absolute))
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
return FALSE;
|
BUG_RETURN_VAL(dev->valuator == NULL, FALSE);
|
||||||
if (axnum >= dev->valuator->numAxes)
|
BUG_RETURN_VAL(axnum >= dev->valuator->numAxes, FALSE);
|
||||||
return FALSE;
|
BUG_RETURN_VAL(minval > maxval && mode == Absolute, FALSE);
|
||||||
|
|
||||||
ax = dev->valuator->axes + axnum;
|
ax = dev->valuator->axes + axnum;
|
||||||
|
|
||||||
|
@ -2081,8 +2084,9 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type,
|
||||||
InternalEvent dce;
|
InternalEvent dce;
|
||||||
DeviceIntPtr master;
|
DeviceIntPtr master;
|
||||||
|
|
||||||
if (!dev || !dev->valuator || axnum >= dev->valuator->numAxes)
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
return FALSE;
|
BUG_RETURN_VAL(dev->valuator == NULL, FALSE);
|
||||||
|
BUG_RETURN_VAL(axnum >= dev->valuator->numAxes, FALSE);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SCROLL_TYPE_VERTICAL:
|
case SCROLL_TYPE_VERTICAL:
|
||||||
|
|
|
@ -1277,6 +1277,9 @@ InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons, Atom *labels,
|
||||||
ButtonClassPtr butc;
|
ButtonClassPtr butc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
|
BUG_RETURN_VAL(dev->button != NULL, FALSE);
|
||||||
|
|
||||||
butc = calloc(1, sizeof(ButtonClassRec));
|
butc = calloc(1, sizeof(ButtonClassRec));
|
||||||
if (!butc)
|
if (!butc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1337,8 +1340,7 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
|
||||||
int i;
|
int i;
|
||||||
ValuatorClassPtr valc;
|
ValuatorClassPtr valc;
|
||||||
|
|
||||||
if (!dev)
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (numAxes > MAX_VALUATORS) {
|
if (numAxes > MAX_VALUATORS) {
|
||||||
LogMessage(X_WARNING,
|
LogMessage(X_WARNING,
|
||||||
|
@ -1447,6 +1449,9 @@ InitFocusClassDeviceStruct(DeviceIntPtr dev)
|
||||||
{
|
{
|
||||||
FocusClassPtr focc;
|
FocusClassPtr focc;
|
||||||
|
|
||||||
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
|
BUG_RETURN_VAL(dev->focus != NULL, FALSE);
|
||||||
|
|
||||||
focc = malloc(sizeof(FocusClassRec));
|
focc = malloc(sizeof(FocusClassRec));
|
||||||
if (!focc)
|
if (!focc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1466,6 +1471,9 @@ InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, PtrCtrlProcPtr controlProc)
|
||||||
{
|
{
|
||||||
PtrFeedbackPtr feedc;
|
PtrFeedbackPtr feedc;
|
||||||
|
|
||||||
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
|
BUG_RETURN_VAL(dev->ptrfeed != NULL, FALSE);
|
||||||
|
|
||||||
feedc = malloc(sizeof(PtrFeedbackClassRec));
|
feedc = malloc(sizeof(PtrFeedbackClassRec));
|
||||||
if (!feedc)
|
if (!feedc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1507,6 +1515,9 @@ InitStringFeedbackClassDeviceStruct(DeviceIntPtr dev,
|
||||||
int i;
|
int i;
|
||||||
StringFeedbackPtr feedc;
|
StringFeedbackPtr feedc;
|
||||||
|
|
||||||
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
|
BUG_RETURN_VAL(dev->stringfeed != NULL, FALSE);
|
||||||
|
|
||||||
feedc = malloc(sizeof(StringFeedbackClassRec));
|
feedc = malloc(sizeof(StringFeedbackClassRec));
|
||||||
if (!feedc)
|
if (!feedc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1541,6 +1552,9 @@ InitBellFeedbackClassDeviceStruct(DeviceIntPtr dev, BellProcPtr bellProc,
|
||||||
{
|
{
|
||||||
BellFeedbackPtr feedc;
|
BellFeedbackPtr feedc;
|
||||||
|
|
||||||
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
|
BUG_RETURN_VAL(dev->bell != NULL, FALSE);
|
||||||
|
|
||||||
feedc = malloc(sizeof(BellFeedbackClassRec));
|
feedc = malloc(sizeof(BellFeedbackClassRec));
|
||||||
if (!feedc)
|
if (!feedc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1560,6 +1574,9 @@ InitLedFeedbackClassDeviceStruct(DeviceIntPtr dev, LedCtrlProcPtr controlProc)
|
||||||
{
|
{
|
||||||
LedFeedbackPtr feedc;
|
LedFeedbackPtr feedc;
|
||||||
|
|
||||||
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
|
BUG_RETURN_VAL(dev->leds != NULL, FALSE);
|
||||||
|
|
||||||
feedc = malloc(sizeof(LedFeedbackClassRec));
|
feedc = malloc(sizeof(LedFeedbackClassRec));
|
||||||
if (!feedc)
|
if (!feedc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1580,6 +1597,9 @@ InitIntegerFeedbackClassDeviceStruct(DeviceIntPtr dev,
|
||||||
{
|
{
|
||||||
IntegerFeedbackPtr feedc;
|
IntegerFeedbackPtr feedc;
|
||||||
|
|
||||||
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
|
BUG_RETURN_VAL(dev->intfeed != NULL, FALSE);
|
||||||
|
|
||||||
feedc = malloc(sizeof(IntegerFeedbackClassRec));
|
feedc = malloc(sizeof(IntegerFeedbackClassRec));
|
||||||
if (!feedc)
|
if (!feedc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1600,6 +1620,11 @@ InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons,
|
||||||
{
|
{
|
||||||
DeviceIntPtr dev = (DeviceIntPtr) device;
|
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) &&
|
return (InitButtonClassDeviceStruct(dev, numButtons, btn_labels, map) &&
|
||||||
InitValuatorClassDeviceStruct(dev, numAxes, axes_labels,
|
InitValuatorClassDeviceStruct(dev, numAxes, axes_labels,
|
||||||
numMotionEvents, Relative) &&
|
numMotionEvents, Relative) &&
|
||||||
|
@ -1620,14 +1645,12 @@ InitTouchClassDeviceStruct(DeviceIntPtr device, unsigned int max_touches,
|
||||||
TouchClassPtr touch;
|
TouchClassPtr touch;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (device->touch || !device->valuator)
|
BUG_RETURN_VAL(device == NULL, FALSE);
|
||||||
return FALSE;
|
BUG_RETURN_VAL(device->touch != NULL, FALSE);
|
||||||
|
|
||||||
/* Check the mode is valid, and at least X and Y axes. */
|
/* Check the mode is valid, and at least X and Y axes. */
|
||||||
if (mode != XIDirectTouch && mode != XIDependentTouch)
|
BUG_RETURN_VAL(mode != XIDirectTouch && mode != XIDependentTouch, FALSE);
|
||||||
return FALSE;
|
BUG_RETURN_VAL(num_axes < 2, FALSE);
|
||||||
if (num_axes < 2)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (num_axes > MAX_VALUATORS) {
|
if (num_axes > MAX_VALUATORS) {
|
||||||
LogMessage(X_WARNING,
|
LogMessage(X_WARNING,
|
||||||
|
|
|
@ -503,8 +503,9 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
|
||||||
XkbEventCauseRec cause;
|
XkbEventCauseRec cause;
|
||||||
XkbRMLVOSet rmlvo_dflts = { NULL };
|
XkbRMLVOSet rmlvo_dflts = { NULL };
|
||||||
|
|
||||||
if (dev->key || dev->kbdfeed)
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
return FALSE;
|
BUG_RETURN_VAL(dev->key != NULL, FALSE);
|
||||||
|
BUG_RETURN_VAL(dev->kbdfeed != NULL, FALSE);
|
||||||
|
|
||||||
if (!rmlvo) {
|
if (!rmlvo) {
|
||||||
rmlvo = &rmlvo_dflts;
|
rmlvo = &rmlvo_dflts;
|
||||||
|
|
Loading…
Reference in New Issue