diff options
author | Eamon Walsh <ewalsh@tycho.nsa.gov> | 2007-09-24 13:33:01 -0400 |
---|---|---|
committer | Eamon Walsh <ewalsh@moss-charon.epoch.ncsc.mil> | 2007-09-26 07:26:59 -0400 |
commit | 31a7994ac7365562ef1d00e0a7b25f967a961a4e (patch) | |
tree | a2054c0e371e9c62396f2e09df469142dca0a633 /Xi/chgfctl.c | |
parent | 56ffc381d32687242dd094395fcf2216339bab2a (diff) |
Input: Return errors to the dispatcher instead of sending them ourself.
Also fixed two "unused variable: stuff" warnings.
Diffstat (limited to 'Xi/chgfctl.c')
-rw-r--r-- | Xi/chgfctl.c | 179 |
1 files changed, 58 insertions, 121 deletions
diff --git a/Xi/chgfctl.c b/Xi/chgfctl.c index 2e0e13cad..46bb8e78f 100644 --- a/Xi/chgfctl.c +++ b/Xi/chgfctl.c @@ -56,13 +56,10 @@ SOFTWARE. #include <dix-config.h> #endif -#include <X11/X.h> /* for inputstr.h */ -#include <X11/Xproto.h> /* Request macro */ #include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> /* control constants */ -#include "extnsionst.h" #include "extinit.h" /* LookupDeviceIntRec */ #include "exglobals.h" @@ -119,9 +116,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, t = defaultKeyboardControl.click; else if (t < 0 || t > 100) { client->errorValue = t; - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadValue); - return Success; + return BadValue; } kctrl.click = t; } @@ -132,9 +127,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, t = defaultKeyboardControl.bell; else if (t < 0 || t > 100) { client->errorValue = t; - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadValue); - return Success; + return BadValue; } kctrl.bell = t; } @@ -145,9 +138,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, t = defaultKeyboardControl.bell_pitch; else if (t < 0) { client->errorValue = t; - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadValue); - return Success; + return BadValue; } kctrl.bell_pitch = t; } @@ -158,9 +149,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, t = defaultKeyboardControl.bell_duration; else if (t < 0) { client->errorValue = t; - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadValue); - return Success; + return BadValue; } kctrl.bell_duration = t; } @@ -174,15 +163,10 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, key = (KeyCode) f->key; if (key < 8 || key > 255) { client->errorValue = key; - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadValue); - return Success; - } - if (!(mask & DvAutoRepeatMode)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadMatch); - return Success; + return BadValue; } + if (!(mask & DvAutoRepeatMode)) + return BadMatch; } if (mask & DvAutoRepeatMode) { @@ -210,9 +194,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, (defaultKeyboardControl.autoRepeats[inx] & kmask); } else { client->errorValue = t; - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadValue); - return Success; + return BadValue; } } @@ -250,9 +232,7 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, pctrl.num = defaultPointerControl.num; else if (accelNum < 0) { client->errorValue = accelNum; - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadValue); - return Success; + return BadValue; } else pctrl.num = accelNum; } @@ -265,9 +245,7 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, pctrl.den = defaultPointerControl.den; else if (accelDenom <= 0) { client->errorValue = accelDenom; - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadValue); - return Success; + return BadValue; } else pctrl.den = accelDenom; } @@ -280,9 +258,7 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, pctrl.threshold = defaultPointerControl.threshold; else if (threshold < 0) { client->errorValue = threshold; - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadValue); - return Success; + return BadValue; } else pctrl.threshold = threshold; } @@ -341,21 +317,16 @@ ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev, } } - if (f->num_keysyms > s->ctrl.max_symbols) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadValue); - return Success; - } + if (f->num_keysyms > s->ctrl.max_symbols) + return BadValue; + sup_syms = s->ctrl.symbols_supported; for (i = 0; i < f->num_keysyms; i++) { for (j = 0; j < s->ctrl.num_symbols_supported; j++) if (*(syms + i) == *(sup_syms + j)) break; - if (j == s->ctrl.num_symbols_supported) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadMatch); - return Success; - } + if (j == s->ctrl.num_symbols_supported) + return BadMatch; } s->ctrl.num_symbols_displayed = f->num_keysyms; @@ -393,9 +364,7 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev, t = defaultKeyboardControl.bell; else if (t < 0 || t > 100) { client->errorValue = t; - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadValue); - return Success; + return BadValue; } bctrl.percent = t; } @@ -406,9 +375,7 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev, t = defaultKeyboardControl.bell_pitch; else if (t < 0) { client->errorValue = t; - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadValue); - return Success; + return BadValue; } bctrl.pitch = t; } @@ -419,9 +386,7 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev, t = defaultKeyboardControl.bell_duration; else if (t < 0) { client->errorValue = t; - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadValue); - return Success; + return BadValue; } bctrl.duration = t; } @@ -485,38 +450,27 @@ ProcXChangeFeedbackControl(ClientPtr client) len = stuff->length - (sizeof(xChangeFeedbackControlReq) >> 2); dev = LookupDeviceIntRec(stuff->deviceid); - if (dev == NULL) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadDevice); - return Success; - } + if (dev == NULL) + return BadDevice; switch (stuff->feedbackid) { case KbdFeedbackClass: - if (len != (sizeof(xKbdFeedbackCtl) >> 2)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } + if (len != (sizeof(xKbdFeedbackCtl) >> 2)) + return BadLength; + for (k = dev->kbdfeed; k; k = k->next) - if (k->ctrl.id == ((xKbdFeedbackCtl *) & stuff[1])->id) { - ChangeKbdFeedback(client, dev, stuff->mask, k, - (xKbdFeedbackCtl *) & stuff[1]); - return Success; - } + if (k->ctrl.id == ((xKbdFeedbackCtl *) & stuff[1])->id) + return ChangeKbdFeedback(client, dev, stuff->mask, k, + (xKbdFeedbackCtl *) & stuff[1]); break; case PtrFeedbackClass: - if (len != (sizeof(xPtrFeedbackCtl) >> 2)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } + if (len != (sizeof(xPtrFeedbackCtl) >> 2)) + return BadLength; + for (p = dev->ptrfeed; p; p = p->next) - if (p->ctrl.id == ((xPtrFeedbackCtl *) & stuff[1])->id) { - ChangePtrFeedback(client, dev, stuff->mask, p, - (xPtrFeedbackCtl *) & stuff[1]); - return Success; - } + if (p->ctrl.id == ((xPtrFeedbackCtl *) & stuff[1])->id) + return ChangePtrFeedback(client, dev, stuff->mask, p, + (xPtrFeedbackCtl *) & stuff[1]); break; case StringFeedbackClass: { @@ -526,63 +480,46 @@ ProcXChangeFeedbackControl(ClientPtr client) if (client->swapped) { swaps(&f->num_keysyms, n); } - if (len != ((sizeof(xStringFeedbackCtl) >> 2) + f->num_keysyms)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } + if (len != ((sizeof(xStringFeedbackCtl) >> 2) + f->num_keysyms)) + return BadLength; + for (s = dev->stringfeed; s; s = s->next) - if (s->ctrl.id == ((xStringFeedbackCtl *) & stuff[1])->id) { - ChangeStringFeedback(client, dev, stuff->mask, s, - (xStringFeedbackCtl *) & stuff[1]); - return Success; - } + if (s->ctrl.id == ((xStringFeedbackCtl *) & stuff[1])->id) + return ChangeStringFeedback(client, dev, stuff->mask, s, + (xStringFeedbackCtl *) & stuff[1]); break; } case IntegerFeedbackClass: - if (len != (sizeof(xIntegerFeedbackCtl) >> 2)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } + if (len != (sizeof(xIntegerFeedbackCtl) >> 2)) + return BadLength; + for (i = dev->intfeed; i; i = i->next) - if (i->ctrl.id == ((xIntegerFeedbackCtl *) & stuff[1])->id) { - ChangeIntegerFeedback(client, dev, stuff->mask, i, - (xIntegerFeedbackCtl *) & stuff[1]); - return Success; - } + if (i->ctrl.id == ((xIntegerFeedbackCtl *) & stuff[1])->id) + return ChangeIntegerFeedback(client, dev, stuff->mask, i, + (xIntegerFeedbackCtl *)&stuff[1]); break; case LedFeedbackClass: - if (len != (sizeof(xLedFeedbackCtl) >> 2)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } + if (len != (sizeof(xLedFeedbackCtl) >> 2)) + return BadLength; + for (l = dev->leds; l; l = l->next) - if (l->ctrl.id == ((xLedFeedbackCtl *) & stuff[1])->id) { - ChangeLedFeedback(client, dev, stuff->mask, l, - (xLedFeedbackCtl *) & stuff[1]); - return Success; - } + if (l->ctrl.id == ((xLedFeedbackCtl *) & stuff[1])->id) + return ChangeLedFeedback(client, dev, stuff->mask, l, + (xLedFeedbackCtl *) & stuff[1]); break; case BellFeedbackClass: - if (len != (sizeof(xBellFeedbackCtl) >> 2)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } + if (len != (sizeof(xBellFeedbackCtl) >> 2)) + return BadLength; + for (b = dev->bell; b; b = b->next) - if (b->ctrl.id == ((xBellFeedbackCtl *) & stuff[1])->id) { - ChangeBellFeedback(client, dev, stuff->mask, b, - (xBellFeedbackCtl *) & stuff[1]); - return Success; - } + if (b->ctrl.id == ((xBellFeedbackCtl *) & stuff[1])->id) + return ChangeBellFeedback(client, dev, stuff->mask, b, + (xBellFeedbackCtl *) & stuff[1]); break; default: break; } - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, BadMatch); - return Success; + return BadMatch; } |