[PATCH 06/19] Use C99 designated initializers in Xinput Replies
Alan Coopersmith
alan.coopersmith at oracle.com
Sun Jun 24 10:25:13 PDT 2012
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
Xi/chgdctl.c | 12 ++---
Xi/getbmap.c | 25 +++++------
Xi/getdctl.c | 12 ++---
Xi/getfctl.c | 14 +++---
Xi/getfocus.c | 12 ++---
Xi/getkmap.c | 18 ++++----
Xi/getmmap.c | 19 ++++----
Xi/getprop.c | 14 +++---
Xi/getselev.c | 16 +++----
Xi/getvers.c | 30 ++++++-------
Xi/grabdev.c | 22 +++++----
Xi/gtmotion.c | 13 +++---
Xi/listdev.c | 22 ++++-----
Xi/opendev.c | 18 ++++----
Xi/queryst.c | 19 ++++----
Xi/setbmap.c | 28 ++++++------
Xi/setdval.c | 37 +++++++++-------
Xi/setmmap.c | 14 +++---
Xi/setmode.c | 35 ++++++++-------
Xi/xigetclientpointer.c | 19 ++++----
Xi/xigrabdev.c | 22 ++++-----
Xi/xipassivegrab.c | 14 +++---
Xi/xiproperty.c | 113 +++++++++++++++++++++++++----------------------
Xi/xiquerydevice.c | 12 ++---
Xi/xiquerypointer.c | 12 ++---
Xi/xiqueryversion.c | 22 ++++-----
Xi/xiselectev.c | 14 +++---
Xi/xisetdevfocus.c | 12 ++---
28 files changed, 329 insertions(+), 291 deletions(-)
diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c
index 0de5f2b..726d49e 100644
--- a/Xi/chgdctl.c
+++ b/Xi/chgdctl.c
@@ -109,7 +109,12 @@ ProcXChangeDeviceControl(ClientPtr client)
int i, status, ret = BadValue;
DeviceIntPtr dev;
xDeviceResolutionCtl *r;
- xChangeDeviceControlReply rep;
+ xChangeDeviceControlReply rep = {
+ .repType = X_Reply,
+ .RepType = X_ChangeDeviceControl,
+ .sequenceNumber = client->sequence,
+ .length = 0
+ };
AxisInfoPtr a;
CARD32 *resolution;
xDeviceEnableCtl *e;
@@ -123,11 +128,6 @@ ProcXChangeDeviceControl(ClientPtr client)
if (ret != Success)
goto out;
- rep.repType = X_Reply;
- rep.RepType = X_ChangeDeviceControl;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
switch (stuff->control) {
case DEVICE_RESOLUTION:
r = (xDeviceResolutionCtl *) &stuff[1];
diff --git a/Xi/getbmap.c b/Xi/getbmap.c
index 2712fcd..52d1278 100644
--- a/Xi/getbmap.c
+++ b/Xi/getbmap.c
@@ -85,19 +85,12 @@ int
ProcXGetDeviceButtonMapping(ClientPtr client)
{
DeviceIntPtr dev;
- xGetDeviceButtonMappingReply rep;
ButtonClassPtr b;
int rc;
REQUEST(xGetDeviceButtonMappingReq);
REQUEST_SIZE_MATCH(xGetDeviceButtonMappingReq);
- rep.repType = X_Reply;
- rep.RepType = X_GetDeviceButtonMapping;
- rep.nElts = 0;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
@@ -105,12 +98,18 @@ ProcXGetDeviceButtonMapping(ClientPtr client)
b = dev->button;
if (b == NULL)
return BadMatch;
-
- rep.nElts = b->numButtons;
- rep.length = bytes_to_int32(rep.nElts);
- WriteReplyToClient(client, sizeof(xGetDeviceButtonMappingReply), &rep);
- WriteToClient(client, rep.nElts, &b->map[1]);
- return Success;
+ else {
+ xGetDeviceButtonMappingReply rep = {
+ .repType = X_Reply,
+ .RepType = X_GetDeviceButtonMapping,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(b->numButtons),
+ .nElts = b->numButtons
+ };
+ WriteReplyToClient(client, sizeof(xGetDeviceButtonMappingReply), &rep);
+ WriteToClient(client, rep.nElts, &b->map[1]);
+ return Success;
+ }
}
/***********************************************************************
diff --git a/Xi/getdctl.c b/Xi/getdctl.c
index 27775e2..d8be7e9 100644
--- a/Xi/getdctl.c
+++ b/Xi/getdctl.c
@@ -173,7 +173,12 @@ ProcXGetDeviceControl(ClientPtr client)
int rc, total_length = 0;
char *buf, *savbuf;
DeviceIntPtr dev;
- xGetDeviceControlReply rep;
+ xGetDeviceControlReply rep = {
+ .repType = X_Reply,
+ .RepType = X_GetDeviceControl,
+ .sequenceNumber = client->sequence,
+ .length = 0
+ };
REQUEST(xGetDeviceControlReq);
REQUEST_SIZE_MATCH(xGetDeviceControlReq);
@@ -182,11 +187,6 @@ ProcXGetDeviceControl(ClientPtr client)
if (rc != Success)
return rc;
- rep.repType = X_Reply;
- rep.RepType = X_GetDeviceControl;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
switch (stuff->control) {
case DEVICE_RESOLUTION:
if (!dev->valuator)
diff --git a/Xi/getfctl.c b/Xi/getfctl.c
index 5f97cc3..6e98941 100644
--- a/Xi/getfctl.c
+++ b/Xi/getfctl.c
@@ -286,7 +286,13 @@ ProcXGetFeedbackControl(ClientPtr client)
StringFeedbackPtr s;
BellFeedbackPtr b;
LedFeedbackPtr l;
- xGetFeedbackControlReply rep;
+ xGetFeedbackControlReply rep = {
+ .repType = X_Reply,
+ .RepType = X_GetFeedbackControl,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .num_feedbacks = 0
+ };
REQUEST(xGetFeedbackControlReq);
REQUEST_SIZE_MATCH(xGetFeedbackControlReq);
@@ -295,12 +301,6 @@ ProcXGetFeedbackControl(ClientPtr client)
if (rc != Success)
return rc;
- rep.repType = X_Reply;
- rep.RepType = X_GetFeedbackControl;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.num_feedbacks = 0;
-
for (k = dev->kbdfeed; k; k = k->next) {
rep.num_feedbacks++;
total_length += sizeof(xKbdFeedbackState);
diff --git a/Xi/getfocus.c b/Xi/getfocus.c
index 54c176f..1034156 100644
--- a/Xi/getfocus.c
+++ b/Xi/getfocus.c
@@ -87,7 +87,12 @@ ProcXGetDeviceFocus(ClientPtr client)
{
DeviceIntPtr dev;
FocusClassPtr focus;
- xGetDeviceFocusReply rep;
+ xGetDeviceFocusReply rep = {
+ .repType = X_Reply,
+ .RepType = X_GetDeviceFocus,
+ .sequenceNumber = client->sequence,
+ .length = 0
+ };
int rc;
REQUEST(xGetDeviceFocusReq);
@@ -99,11 +104,6 @@ ProcXGetDeviceFocus(ClientPtr client)
if (!dev->focus)
return BadDevice;
- rep.repType = X_Reply;
- rep.RepType = X_GetDeviceFocus;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
focus = dev->focus;
if (focus->win == NoneWin)
diff --git a/Xi/getkmap.c b/Xi/getkmap.c
index 3536879..ce7ac1a 100644
--- a/Xi/getkmap.c
+++ b/Xi/getkmap.c
@@ -88,7 +88,6 @@ SProcXGetDeviceKeyMapping(ClientPtr client)
int
ProcXGetDeviceKeyMapping(ClientPtr client)
{
- xGetDeviceKeyMappingReply rep;
DeviceIntPtr dev;
XkbDescPtr xkb;
KeySymsPtr syms;
@@ -118,13 +117,16 @@ ProcXGetDeviceKeyMapping(ClientPtr client)
syms = XkbGetCoreMap(dev);
if (!syms)
return BadAlloc;
-
- rep.repType = X_Reply;
- rep.RepType = X_GetDeviceKeyMapping;
- rep.sequenceNumber = client->sequence;
- rep.keySymsPerKeyCode = syms->mapWidth;
- rep.length = (syms->mapWidth * stuff->count); /* KeySyms are 4 bytes */
- WriteReplyToClient(client, sizeof(xGetDeviceKeyMappingReply), &rep);
+ else {
+ xGetDeviceKeyMappingReply rep = {
+ .repType = X_Reply,
+ .RepType = X_GetDeviceKeyMapping,
+ .sequenceNumber = client->sequence,
+ .length = (syms->mapWidth * stuff->count), /* KeySyms are 4 bytes */
+ .keySymsPerKeyCode = syms->mapWidth
+ };
+ WriteReplyToClient(client, sizeof(xGetDeviceKeyMappingReply), &rep);
+ }
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
WriteSwappedDataToClient(client,
diff --git a/Xi/getmmap.c b/Xi/getmmap.c
index 97d4c0d..171d722 100644
--- a/Xi/getmmap.c
+++ b/Xi/getmmap.c
@@ -86,7 +86,6 @@ int
ProcXGetDeviceModifierMapping(ClientPtr client)
{
DeviceIntPtr dev;
- xGetDeviceModifierMappingReply rep;
KeyCode *modkeymap = NULL;
int ret, max_keys_per_mod;
@@ -100,15 +99,19 @@ ProcXGetDeviceModifierMapping(ClientPtr client)
ret = generate_modkeymap(client, dev, &modkeymap, &max_keys_per_mod);
if (ret != Success)
return ret;
-
- rep.repType = X_Reply;
- rep.RepType = X_GetDeviceModifierMapping;
- rep.numKeyPerModifier = max_keys_per_mod;
- rep.sequenceNumber = client->sequence;
+ else {
+ xGetDeviceModifierMappingReply rep = {
+ .repType = X_Reply,
+ .RepType = X_GetDeviceModifierMapping,
+ .sequenceNumber = client->sequence,
/* length counts 4 byte quantities - there are 8 modifiers 1 byte big */
- rep.length = max_keys_per_mod << 1;
+ .length = max_keys_per_mod << 1,
+ .numKeyPerModifier = max_keys_per_mod
+ };
- WriteReplyToClient(client, sizeof(xGetDeviceModifierMappingReply), &rep);
+ WriteReplyToClient(client, sizeof(xGetDeviceModifierMappingReply),
+ &rep);
+ }
WriteToClient(client, max_keys_per_mod * 8, modkeymap);
free(modkeymap);
diff --git a/Xi/getprop.c b/Xi/getprop.c
index b5af13a..4b52fc7 100644
--- a/Xi/getprop.c
+++ b/Xi/getprop.c
@@ -95,18 +95,18 @@ ProcXGetDeviceDontPropagateList(ClientPtr client)
int i, rc;
XEventClass *buf = NULL, *tbuf;
WindowPtr pWin;
- xGetDeviceDontPropagateListReply rep;
+ xGetDeviceDontPropagateListReply rep = {
+ .repType = X_Reply,
+ .RepType = X_GetDeviceDontPropagateList,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .count = 0
+ };
OtherInputMasks *others;
REQUEST(xGetDeviceDontPropagateListReq);
REQUEST_SIZE_MATCH(xGetDeviceDontPropagateListReq);
- rep.repType = X_Reply;
- rep.RepType = X_GetDeviceDontPropagateList;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.count = 0;
-
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
diff --git a/Xi/getselev.c b/Xi/getselev.c
index 4fcc902..aa162bc 100644
--- a/Xi/getselev.c
+++ b/Xi/getselev.c
@@ -91,7 +91,14 @@ int
ProcXGetSelectedExtensionEvents(ClientPtr client)
{
int i, rc, total_length = 0;
- xGetSelectedExtensionEventsReply rep;
+ xGetSelectedExtensionEventsReply rep = {
+ .repType = X_Reply,
+ .RepType = X_GetSelectedExtensionEvents,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .this_client_count = 0,
+ .all_clients_count = 0
+ };
WindowPtr pWin;
XEventClass *buf = NULL;
XEventClass *tclient;
@@ -102,13 +109,6 @@ ProcXGetSelectedExtensionEvents(ClientPtr client)
REQUEST(xGetSelectedExtensionEventsReq);
REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);
- rep.repType = X_Reply;
- rep.RepType = X_GetSelectedExtensionEvents;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.this_client_count = 0;
- rep.all_clients_count = 0;
-
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
diff --git a/Xi/getvers.c b/Xi/getvers.c
index b380344..9392817 100644
--- a/Xi/getvers.c
+++ b/Xi/getvers.c
@@ -89,27 +89,27 @@ SProcXGetExtensionVersion(ClientPtr client)
int
ProcXGetExtensionVersion(ClientPtr client)
{
- xGetExtensionVersionReply rep;
-
REQUEST(xGetExtensionVersionReq);
REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq);
if (stuff->length != bytes_to_int32(sizeof(xGetExtensionVersionReq) +
stuff->nbytes))
return BadLength;
-
- memset(&rep, 0, sizeof(xGetExtensionVersionReply));
- rep.repType = X_Reply;
- rep.RepType = X_GetExtensionVersion;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.present = TRUE;
- rep.major_version = XIVersion.major_version;
- rep.minor_version = XIVersion.minor_version;
-
- WriteReplyToClient(client, sizeof(xGetExtensionVersionReply), &rep);
-
- return Success;
+ else {
+ xGetExtensionVersionReply rep = {
+ .repType = X_Reply,
+ .RepType = X_GetExtensionVersion,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .major_version = XIVersion.major_version,
+ .minor_version = XIVersion.minor_version,
+ .present = TRUE
+ };
+
+ WriteReplyToClient(client, sizeof(xGetExtensionVersionReply), &rep);
+
+ return Success;
+ }
}
/***********************************************************************
diff --git a/Xi/grabdev.c b/Xi/grabdev.c
index bdc0c4b..286793d 100644
--- a/Xi/grabdev.c
+++ b/Xi/grabdev.c
@@ -101,7 +101,7 @@ int
ProcXGrabDevice(ClientPtr client)
{
int rc;
- xGrabDeviceReply rep;
+ CARD8 status;
DeviceIntPtr dev;
GrabMask mask;
struct tmask tmp[EMASKSIZE];
@@ -113,10 +113,6 @@ ProcXGrabDevice(ClientPtr client)
bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count)
return BadLength;
- rep.repType = X_Reply;
- rep.RepType = X_GrabDevice;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess);
if (rc != Success)
@@ -132,13 +128,21 @@ ProcXGrabDevice(ClientPtr client)
rc = GrabDevice(client, dev, stuff->other_devices_mode,
stuff->this_device_mode, stuff->grabWindow,
stuff->ownerEvents, stuff->time,
- &mask, XI, None, None, &rep.status);
+ &mask, XI, None, None, &status);
if (rc != Success)
return rc;
-
- WriteReplyToClient(client, sizeof(xGrabDeviceReply), &rep);
- return Success;
+ else {
+ xGrabDeviceReply rep = {
+ .repType = X_Reply,
+ .RepType = X_GrabDevice,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .status = status
+ };
+ WriteReplyToClient(client, sizeof(xGrabDeviceReply), &rep);
+ return Success;
+ }
}
/***********************************************************************
diff --git a/Xi/gtmotion.c b/Xi/gtmotion.c
index 2249b86..f9953d1 100644
--- a/Xi/gtmotion.c
+++ b/Xi/gtmotion.c
@@ -89,7 +89,13 @@ int
ProcXGetDeviceMotionEvents(ClientPtr client)
{
INT32 *coords = NULL, *bufptr;
- xGetDeviceMotionEventsReply rep;
+ xGetDeviceMotionEventsReply rep = {
+ .repType = X_Reply,
+ .RepType = X_GetDeviceMotionEvents,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .nEvents = 0
+ };
unsigned long i;
int rc, num_events, axes, size = 0;
unsigned long nEvents;
@@ -110,13 +116,8 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
if (dev->valuator->motionHintWindow)
MaybeStopDeviceHint(dev, client);
axes = v->numAxes;
- rep.repType = X_Reply;
- rep.RepType = X_GetDeviceMotionEvents;
- rep.sequenceNumber = client->sequence;
- rep.nEvents = 0;
rep.axes = axes;
rep.mode = Absolute; /* XXX we don't do relative at the moment */
- rep.length = 0;
start = ClientTimeToServerTime(stuff->start);
stop = ClientTimeToServerTime(stuff->stop);
if (CompareTimeStamps(start, stop) == LATER ||
diff --git a/Xi/listdev.c b/Xi/listdev.c
index 1fff738..ea1eff2 100644
--- a/Xi/listdev.c
+++ b/Xi/listdev.c
@@ -330,7 +330,6 @@ ShouldSkipDevice(ClientPtr client, DeviceIntPtr d)
int
ProcXListInputDevices(ClientPtr client)
{
- xListInputDevicesReply rep;
int numdevs = 0;
int namesize = 1; /* need 1 extra byte for strcpy */
int i = 0, size = 0;
@@ -342,12 +341,6 @@ ProcXListInputDevices(ClientPtr client)
REQUEST_SIZE_MATCH(xListInputDevicesReq);
- memset(&rep, 0, sizeof(xListInputDevicesReply));
- rep.repType = X_Reply;
- rep.RepType = X_ListInputDevices;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
/* allocate space for saving skip value */
skip = calloc(sizeof(Bool), inputInfo.numDevices);
if (!skip)
@@ -396,9 +389,18 @@ ProcXListInputDevices(ClientPtr client)
ListDeviceInfo(client, d, dev++, &devbuf, &classbuf, &namebuf);
}
- rep.ndevices = numdevs;
- rep.length = bytes_to_int32(total_length);
- WriteReplyToClient(client, sizeof(xListInputDevicesReply), &rep);
+
+ {
+ xListInputDevicesReply rep = {
+ .repType = X_Reply,
+ .RepType = X_ListInputDevices,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(total_length),
+ .ndevices = numdevs
+ };
+ WriteReplyToClient(client, sizeof(xListInputDevicesReply), &rep);
+ }
+
WriteToClient(client, total_length, savbuf);
free(savbuf);
free(skip);
diff --git a/Xi/opendev.c b/Xi/opendev.c
index 486ac14..53f54aa 100644
--- a/Xi/opendev.c
+++ b/Xi/opendev.c
@@ -93,7 +93,6 @@ ProcXOpenDevice(ClientPtr client)
xInputClassInfo evbase[numInputClasses];
int j = 0;
int status = Success;
- xOpenDeviceReply rep;
DeviceIntPtr dev;
REQUEST(xOpenDeviceReq);
@@ -117,10 +116,6 @@ ProcXOpenDevice(ClientPtr client)
if (status != Success)
return status;
- memset(&rep, 0, sizeof(xOpenDeviceReply));
- rep.repType = X_Reply;
- rep.RepType = X_OpenDevice;
- rep.sequenceNumber = client->sequence;
if (dev->key != NULL) {
evbase[j].class = KeyClass;
evbase[j++].event_type_base = event_base[KeyClass];
@@ -148,9 +143,16 @@ ProcXOpenDevice(ClientPtr client)
}
evbase[j].class = OtherClass;
evbase[j++].event_type_base = event_base[OtherClass];
- rep.length = bytes_to_int32(j * sizeof(xInputClassInfo));
- rep.num_classes = j;
- WriteReplyToClient(client, sizeof(xOpenDeviceReply), &rep);
+ {
+ xOpenDeviceReply rep = {
+ .repType = X_Reply,
+ .RepType = X_OpenDevice,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(j * sizeof(xInputClassInfo)),
+ .num_classes = j
+ };
+ WriteReplyToClient(client, sizeof(xOpenDeviceReply), &rep);
+ }
WriteToClient(client, j * sizeof(xInputClassInfo), evbase);
return Success;
}
diff --git a/Xi/queryst.c b/Xi/queryst.c
index de19974..0c18e46 100644
--- a/Xi/queryst.c
+++ b/Xi/queryst.c
@@ -80,18 +80,12 @@ ProcXQueryDeviceState(ClientPtr client)
xButtonState *tb;
ValuatorClassPtr v;
xValuatorState *tv;
- xQueryDeviceStateReply rep;
DeviceIntPtr dev;
double *values;
REQUEST(xQueryDeviceStateReq);
REQUEST_SIZE_MATCH(xQueryDeviceStateReq);
- rep.repType = X_Reply;
- rep.RepType = X_QueryDeviceState;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess);
if (rc != Success && rc != BadAccess)
return rc;
@@ -163,9 +157,16 @@ ProcXQueryDeviceState(ClientPtr client)
}
}
- rep.num_classes = num_classes;
- rep.length = bytes_to_int32(total_length);
- WriteReplyToClient(client, sizeof(xQueryDeviceStateReply), &rep);
+ {
+ xQueryDeviceStateReply rep = {
+ .repType = X_Reply,
+ .RepType = X_QueryDeviceState,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(total_length),
+ .num_classes = num_classes
+ };
+ WriteReplyToClient(client, sizeof(xQueryDeviceStateReply), &rep);
+ }
if (total_length > 0)
WriteToClient(client, total_length, savbuf);
free(savbuf);
diff --git a/Xi/setbmap.c b/Xi/setbmap.c
index 296b439..32039b4 100644
--- a/Xi/setbmap.c
+++ b/Xi/setbmap.c
@@ -86,7 +86,6 @@ int
ProcXSetDeviceButtonMapping(ClientPtr client)
{
int ret;
- xSetDeviceButtonMappingReply rep;
DeviceIntPtr dev;
REQUEST(xSetDeviceButtonMappingReq);
@@ -100,25 +99,26 @@ ProcXSetDeviceButtonMapping(ClientPtr client)
if (ret != Success)
return ret;
- rep.repType = X_Reply;
- rep.RepType = X_SetDeviceButtonMapping;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.status = MappingSuccess;
-
ret =
ApplyPointerMapping(dev, (CARD8 *) &stuff[1], stuff->map_length,
client);
if (ret == -1)
return BadValue;
- else if (ret == MappingBusy)
- rep.status = ret;
- else if (ret != Success)
+ else if ((ret != Success) && (ret != MappingBusy))
return ret;
-
- WriteReplyToClient(client, sizeof(xSetDeviceButtonMappingReply), &rep);
-
- return Success;
+ else {
+ xSetDeviceButtonMappingReply rep = {
+ .repType = X_Reply,
+ .RepType = X_SetDeviceButtonMapping,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .status = (ret == MappingBusy) ? MappingBusy : MappingSuccess,
+ };
+
+ WriteReplyToClient(client, sizeof(xSetDeviceButtonMappingReply), &rep);
+
+ return Success;
+ }
}
/***********************************************************************
diff --git a/Xi/setdval.c b/Xi/setdval.c
index 8c3816d..4b10526 100644
--- a/Xi/setdval.c
+++ b/Xi/setdval.c
@@ -86,18 +86,12 @@ int
ProcXSetDeviceValuators(ClientPtr client)
{
DeviceIntPtr dev;
- xSetDeviceValuatorsReply rep;
+ CARD8 status;
int rc;
REQUEST(xSetDeviceValuatorsReq);
REQUEST_AT_LEAST_SIZE(xSetDeviceValuatorsReq);
- rep.repType = X_Reply;
- rep.RepType = X_SetDeviceValuators;
- rep.length = 0;
- rep.status = Success;
- rep.sequenceNumber = client->sequence;
-
if (stuff->length != bytes_to_int32(sizeof(xSetDeviceValuatorsReq)) +
stuff->num_valuators)
return BadLength;
@@ -112,17 +106,26 @@ ProcXSetDeviceValuators(ClientPtr client)
return BadValue;
if ((dev->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client))
- rep.status = AlreadyGrabbed;
+ status = AlreadyGrabbed;
else
- rep.status = SetDeviceValuators(client, dev, (int *) &stuff[1],
- stuff->first_valuator,
- stuff->num_valuators);
-
- if (rep.status != Success && rep.status != AlreadyGrabbed)
- return rep.status;
-
- WriteReplyToClient(client, sizeof(xSetDeviceValuatorsReply), &rep);
- return Success;
+ status = SetDeviceValuators(client, dev, (int *) &stuff[1],
+ stuff->first_valuator,
+ stuff->num_valuators);
+
+ if (status != Success && status != AlreadyGrabbed)
+ return status;
+ else {
+ xSetDeviceValuatorsReply rep = {
+ .repType = X_Reply,
+ .RepType = X_SetDeviceValuators,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .status = status
+ };
+
+ WriteReplyToClient(client, sizeof(xSetDeviceValuatorsReply), &rep);
+ return Success;
+ }
}
/***********************************************************************
diff --git a/Xi/setmmap.c b/Xi/setmmap.c
index e70038e..be87eca 100644
--- a/Xi/setmmap.c
+++ b/Xi/setmmap.c
@@ -88,7 +88,6 @@ int
ProcXSetDeviceModifierMapping(ClientPtr client)
{
int ret;
- xSetDeviceModifierMappingReply rep;
DeviceIntPtr dev;
REQUEST(xSetDeviceModifierMappingReq);
@@ -98,11 +97,6 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
(stuff->numKeyPerModifier << 1))
return BadLength;
- rep.repType = X_Reply;
- rep.RepType = X_SetDeviceModifierMapping;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
if (ret != Success)
return ret;
@@ -113,7 +107,13 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
ret = MappingSuccess;
if (ret == MappingSuccess || ret == MappingBusy || ret == MappingFailed) {
- rep.success = ret;
+ xSetDeviceModifierMappingReply rep = {
+ .repType = X_Reply,
+ .RepType = X_SetDeviceModifierMapping,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .success = ret
+ };
WriteReplyToClient(client, sizeof(xSetDeviceModifierMappingReply),
&rep);
}
diff --git a/Xi/setmode.c b/Xi/setmode.c
index f212d83..2d3b0ce 100644
--- a/Xi/setmode.c
+++ b/Xi/setmode.c
@@ -86,43 +86,48 @@ int
ProcXSetDeviceMode(ClientPtr client)
{
DeviceIntPtr dev;
- xSetDeviceModeReply rep;
+ CARD8 status;
int rc;
REQUEST(xSetDeviceModeReq);
REQUEST_SIZE_MATCH(xSetDeviceModeReq);
- rep.repType = X_Reply;
- rep.RepType = X_SetDeviceMode;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
if (rc != Success)
return rc;
if (dev->valuator == NULL)
return BadMatch;
if ((dev->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client))
- rep.status = AlreadyGrabbed;
+ status = AlreadyGrabbed;
else
- rep.status = SetDeviceMode(client, dev, stuff->mode);
+ status = SetDeviceMode(client, dev, stuff->mode);
- if (rep.status == Success)
+ if (status == Success)
valuator_set_mode(dev, VALUATOR_MODE_ALL_AXES, stuff->mode);
- else if (rep.status != AlreadyGrabbed) {
- switch (rep.status) {
+ else if (status != AlreadyGrabbed) {
+ switch (status) {
case BadMatch:
case BadImplementation:
case BadAlloc:
break;
default:
- rep.status = BadMode;
+ status = BadMode;
}
- return rep.status;
+ return status;
}
- WriteReplyToClient(client, sizeof(xSetDeviceModeReply), &rep);
- return Success;
+ {
+ xSetDeviceModeReply rep = {
+ .repType = X_Reply,
+ .RepType = X_SetDeviceMode,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .status = status
+ };
+
+ WriteReplyToClient(client, sizeof(xSetDeviceModeReply), &rep);
+ return Success;
+ }
}
/***********************************************************************
diff --git a/Xi/xigetclientpointer.c b/Xi/xigetclientpointer.c
index 8a5f54f..e335cb3 100644
--- a/Xi/xigetclientpointer.c
+++ b/Xi/xigetclientpointer.c
@@ -61,7 +61,6 @@ ProcXIGetClientPointer(ClientPtr client)
{
int rc;
ClientPtr winclient;
- xXIGetClientPointerReply rep;
REQUEST(xXIGetClientPointerReq);
REQUEST_SIZE_MATCH(xXIGetClientPointerReq);
@@ -75,14 +74,18 @@ ProcXIGetClientPointer(ClientPtr client)
else
winclient = client;
- rep.repType = X_Reply;
- rep.RepType = X_XIGetClientPointer;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.set = (winclient->clientPtr != NULL);
- rep.deviceid = (winclient->clientPtr) ? winclient->clientPtr->id : 0;
+ {
+ xXIGetClientPointerReply rep = {
+ .repType = X_Reply,
+ .RepType = X_XIGetClientPointer,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .set = (winclient->clientPtr != NULL),
+ .deviceid = (winclient->clientPtr) ? winclient->clientPtr->id : 0
+ };
- WriteReplyToClient(client, sizeof(xXIGetClientPointerReply), &rep);
+ WriteReplyToClient(client, sizeof(xXIGetClientPointerReply), &rep);
+ }
return Success;
}
diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c
index 095fcfa..c53d2f1 100644
--- a/Xi/xigrabdev.c
+++ b/Xi/xigrabdev.c
@@ -62,7 +62,6 @@ int
ProcXIGrabDevice(ClientPtr client)
{
DeviceIntPtr dev;
- xXIGrabDeviceReply rep;
int ret = Success;
uint8_t status;
GrabMask mask = { 0 };
@@ -103,15 +102,18 @@ ProcXIGrabDevice(ClientPtr client)
if (ret != Success)
return ret;
-
- rep.repType = X_Reply;
- rep.RepType = X_XIGrabDevice;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.status = status;
-
- WriteReplyToClient(client, sizeof(rep), &rep);
- return ret;
+ else {
+ xXIGrabDeviceReply rep = {
+ .repType = X_Reply,
+ .RepType = X_XIGrabDevice,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .status = status
+ };
+
+ WriteReplyToClient(client, sizeof(rep), &rep);
+ return ret;
+ }
}
int
diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
index 5e4fa4e..ddab53d 100644
--- a/Xi/xipassivegrab.c
+++ b/Xi/xipassivegrab.c
@@ -78,7 +78,13 @@ int
ProcXIPassiveGrabDevice(ClientPtr client)
{
DeviceIntPtr dev, mod_dev;
- xXIPassiveGrabDeviceReply rep;
+ xXIPassiveGrabDeviceReply rep = {
+ .repType = X_Reply,
+ .RepType = X_XIPassiveGrabDevice,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .num_modifiers = 0
+ };
int i, ret = Success;
uint32_t *modifiers;
xXIGrabModifierInfo *modifiers_failed;
@@ -137,12 +143,6 @@ ProcXIPassiveGrabDevice(ClientPtr client)
xi2mask_set_one_mask(mask.xi2mask, stuff->deviceid,
(unsigned char *) &stuff[1], mask_len * 4);
- rep.repType = X_Reply;
- rep.RepType = X_XIPassiveGrabDevice;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.num_modifiers = 0;
-
memset(¶m, 0, sizeof(param));
param.grabtype = XI2;
param.ownerEvents = stuff->owner_events;
diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index ab86963..d1b2b52 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -848,7 +848,6 @@ int
ProcXListDeviceProperties(ClientPtr client)
{
Atom *atoms;
- xListDevicePropertiesReply rep;
int natoms;
DeviceIntPtr dev;
int rc = Success;
@@ -863,14 +862,17 @@ ProcXListDeviceProperties(ClientPtr client)
rc = list_atoms(dev, &natoms, &atoms);
if (rc != Success)
return rc;
-
- rep.repType = X_Reply;
- rep.RepType = X_ListDeviceProperties;
- rep.length = natoms;
- rep.sequenceNumber = client->sequence;
- rep.nAtoms = natoms;
-
- WriteReplyToClient(client, sizeof(xListDevicePropertiesReply), &rep);
+ else {
+ xListDevicePropertiesReply rep = {
+ .repType = X_Reply,
+ .RepType = X_ListDeviceProperties,
+ .sequenceNumber = client->sequence,
+ .length = natoms,
+ .nAtoms = natoms
+ };
+
+ WriteReplyToClient(client, sizeof(xListDevicePropertiesReply), &rep);
+ }
if (natoms) {
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, natoms * sizeof(Atom), atoms);
@@ -941,7 +943,6 @@ ProcXGetDeviceProperty(ClientPtr client)
int rc, format, nitems, bytes_after;
char *data;
Atom type;
- xGetDevicePropertyReply reply;
REQUEST_SIZE_MATCH(xGetDevicePropertyReq);
if (stuff->delete)
@@ -957,24 +958,27 @@ ProcXGetDeviceProperty(ClientPtr client)
if (rc != Success)
return rc;
-
- reply.repType = X_Reply;
- reply.RepType = X_GetDeviceProperty;
- reply.sequenceNumber = client->sequence;
- reply.deviceid = dev->id;
- reply.nItems = nitems;
- reply.format = format;
- reply.bytesAfter = bytes_after;
- reply.propertyType = type;
- reply.length = bytes_to_int32(length);
-
- if (stuff->delete && (reply.bytesAfter == 0))
- send_property_event(dev, stuff->property, XIPropertyDeleted);
-
- WriteReplyToClient(client, sizeof(xGenericReply), &reply);
+ else {
+ xGetDevicePropertyReply reply = {
+ .repType = X_Reply,
+ .RepType = X_GetDeviceProperty,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(length),
+ .propertyType = type,
+ .bytesAfter = bytes_after,
+ .nItems = nitems,
+ .format = format,
+ .deviceid = dev->id
+ };
+
+ if (stuff->delete && (reply.bytesAfter == 0))
+ send_property_event(dev, stuff->property, XIPropertyDeleted);
+
+ WriteReplyToClient(client, sizeof(xGenericReply), &reply);
+ }
if (length) {
- switch (reply.format) {
+ switch (format) {
case 32:
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
break;
@@ -989,7 +993,7 @@ ProcXGetDeviceProperty(ClientPtr client)
}
/* delete the Property */
- if (stuff->delete && (reply.bytesAfter == 0)) {
+ if (stuff->delete && (bytes_after == 0)) {
XIPropertyPtr prop, *prev;
for (prev = &dev->properties.properties; (prop = *prev);
@@ -1084,7 +1088,6 @@ int
ProcXIListProperties(ClientPtr client)
{
Atom *atoms;
- xXIListPropertiesReply rep;
int natoms;
DeviceIntPtr dev;
int rc = Success;
@@ -1099,14 +1102,18 @@ ProcXIListProperties(ClientPtr client)
rc = list_atoms(dev, &natoms, &atoms);
if (rc != Success)
return rc;
+ else {
+ xXIListPropertiesReply rep = {
+ .repType = X_Reply,
+ .RepType = X_XIListProperties,
+ .sequenceNumber = client->sequence,
+ .length = natoms,
+ .num_properties = natoms
+ };
+
+ WriteReplyToClient(client, sizeof(xXIListPropertiesReply), &rep);
+ }
- rep.repType = X_Reply;
- rep.RepType = X_XIListProperties;
- rep.length = natoms;
- rep.sequenceNumber = client->sequence;
- rep.num_properties = natoms;
-
- WriteReplyToClient(client, sizeof(xXIListPropertiesReply), &rep);
if (natoms) {
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, natoms * sizeof(Atom), atoms);
@@ -1173,7 +1180,6 @@ ProcXIGetProperty(ClientPtr client)
{
REQUEST(xXIGetPropertyReq);
DeviceIntPtr dev;
- xXIGetPropertyReply reply;
int length;
int rc, format, nitems, bytes_after;
char *data;
@@ -1193,23 +1199,26 @@ ProcXIGetProperty(ClientPtr client)
if (rc != Success)
return rc;
-
- reply.repType = X_Reply;
- reply.RepType = X_XIGetProperty;
- reply.sequenceNumber = client->sequence;
- reply.num_items = nitems;
- reply.format = format;
- reply.bytes_after = bytes_after;
- reply.type = type;
- reply.length = bytes_to_int32(length);
-
- if (length && stuff->delete && (reply.bytes_after == 0))
- send_property_event(dev, stuff->property, XIPropertyDeleted);
-
- WriteReplyToClient(client, sizeof(xXIGetPropertyReply), &reply);
+ else {
+ xXIGetPropertyReply reply = {
+ .repType = X_Reply,
+ .RepType = X_XIGetProperty,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(length),
+ .type = type,
+ .bytes_after = bytes_after,
+ .num_items = nitems,
+ .format = format
+ };
+
+ if (length && stuff->delete && (reply.bytes_after == 0))
+ send_property_event(dev, stuff->property, XIPropertyDeleted);
+
+ WriteReplyToClient(client, sizeof(xXIGetPropertyReply), &reply);
+ }
if (length) {
- switch (reply.format) {
+ switch (format) {
case 32:
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
break;
@@ -1224,7 +1233,7 @@ ProcXIGetProperty(ClientPtr client)
}
/* delete the Property */
- if (stuff->delete && (reply.bytes_after == 0)) {
+ if (stuff->delete && (bytes_after == 0)) {
XIPropertyPtr prop, *prev;
for (prev = &dev->properties.properties; (prop = *prev);
diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
index af7ea53..8e1e02f 100644
--- a/Xi/xiquerydevice.c
+++ b/Xi/xiquerydevice.c
@@ -64,7 +64,12 @@ SProcXIQueryDevice(ClientPtr client)
int
ProcXIQueryDevice(ClientPtr client)
{
- xXIQueryDeviceReply rep;
+ xXIQueryDeviceReply rep = {
+ .repType = X_Reply,
+ .RepType = X_XIQueryDevice,
+ .sequenceNumber = client->sequence,
+ .num_devices = 0
+ };
DeviceIntPtr dev = NULL;
int rc = Success;
int i = 0, len = 0;
@@ -107,12 +112,7 @@ ProcXIQueryDevice(ClientPtr client)
return BadAlloc;
}
- memset(&rep, 0, sizeof(xXIQueryDeviceReply));
- rep.repType = X_Reply;
- rep.RepType = X_XIQueryDevice;
- rep.sequenceNumber = client->sequence;
rep.length = len / 4;
- rep.num_devices = 0;
ptr = info;
if (dev) {
diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
index e09a1f6..fd78e94 100644
--- a/Xi/xiquerypointer.c
+++ b/Xi/xiquerypointer.c
@@ -72,7 +72,12 @@ int
ProcXIQueryPointer(ClientPtr client)
{
int rc;
- xXIQueryPointerReply rep;
+ xXIQueryPointerReply rep = {
+ .repType = X_Reply,
+ .RepType = X_XIQueryPointer,
+ .sequenceNumber = client->sequence,
+ .length = 6
+ };
DeviceIntPtr pDev, kbd;
WindowPtr pWin, t;
SpritePtr pSprite;
@@ -121,11 +126,6 @@ ProcXIQueryPointer(ClientPtr client)
pSprite = pDev->spriteInfo->sprite;
- memset(&rep, 0, sizeof(rep));
- rep.repType = X_Reply;
- rep.RepType = X_XIQueryPointer;
- rep.length = 6;
- rep.sequenceNumber = client->sequence;
rep.root = (GetCurrentRootWindow(pDev))->drawable.id;
rep.root_x = FP1616(pSprite->hot.x, 0);
rep.root_y = FP1616(pSprite->hot.y, 0);
diff --git a/Xi/xiqueryversion.c b/Xi/xiqueryversion.c
index 0d4962f..9fc4647 100644
--- a/Xi/xiqueryversion.c
+++ b/Xi/xiqueryversion.c
@@ -55,7 +55,6 @@ extern XExtensionVersion XIVersion; /* defined in getvers.c */
int
ProcXIQueryVersion(ClientPtr client)
{
- xXIQueryVersionReply rep;
XIClientPtr pXIClient;
int major, minor;
@@ -93,15 +92,18 @@ ProcXIQueryVersion(ClientPtr client)
pXIClient->minor_version = minor;
}
- memset(&rep, 0, sizeof(xXIQueryVersionReply));
- rep.repType = X_Reply;
- rep.RepType = X_XIQueryVersion;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.major_version = major;
- rep.minor_version = minor;
-
- WriteReplyToClient(client, sizeof(xXIQueryVersionReply), &rep);
+ {
+ xXIQueryVersionReply rep = {
+ .repType = X_Reply,
+ .RepType = X_XIQueryVersion,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .major_version = major,
+ .minor_version = minor
+ };
+
+ WriteReplyToClient(client, sizeof(xXIQueryVersionReply), &rep);
+ }
return Success;
}
diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c
index 6dd2c1c..a057be0 100644
--- a/Xi/xiselectev.c
+++ b/Xi/xiselectev.c
@@ -247,7 +247,13 @@ ProcXIGetSelectedEvents(ClientPtr client)
int rc, i;
WindowPtr win;
char *buffer = NULL;
- xXIGetSelectedEventsReply reply;
+ xXIGetSelectedEventsReply reply = {
+ .repType = X_Reply,
+ .RepType = X_XIGetSelectedEvents,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .num_masks = 0
+ };
OtherInputMasks *masks;
InputClientsPtr others = NULL;
xXIEventMask *evmask = NULL;
@@ -260,12 +266,6 @@ ProcXIGetSelectedEvents(ClientPtr client)
if (rc != Success)
return rc;
- reply.repType = X_Reply;
- reply.RepType = X_XIGetSelectedEvents;
- reply.length = 0;
- reply.sequenceNumber = client->sequence;
- reply.num_masks = 0;
-
masks = wOtherInputMasks(win);
if (masks) {
for (others = wOtherInputMasks(win)->inputClients; others;
diff --git a/Xi/xisetdevfocus.c b/Xi/xisetdevfocus.c
index 55e5c35..38a68a3 100644
--- a/Xi/xisetdevfocus.c
+++ b/Xi/xisetdevfocus.c
@@ -84,7 +84,12 @@ ProcXISetFocus(ClientPtr client)
int
ProcXIGetFocus(ClientPtr client)
{
- xXIGetFocusReply rep;
+ xXIGetFocusReply rep = {
+ .repType = X_Reply,
+ .RepType = X_XIGetFocus,
+ .sequenceNumber = client->sequence,
+ .length = 0
+ };
DeviceIntPtr dev;
int ret;
@@ -97,11 +102,6 @@ ProcXIGetFocus(ClientPtr client)
if (!dev->focus)
return BadDevice;
- rep.repType = X_Reply;
- rep.RepType = X_XIGetFocus;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
if (dev->focus->win == NoneWin)
rep.focus = None;
else if (dev->focus->win == PointerRootWin)
--
1.7.9.2
More information about the xorg-devel
mailing list