XI: canonicalize reply struct declarations and naming

* name all of them "rep", as throughout most of the Xserver codebase
* always declare them where initialized

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-04-01 17:19:15 +02:00
parent 7ea43bd5e9
commit 62863427a3
27 changed files with 67 additions and 98 deletions

View File

@ -108,7 +108,6 @@ ProcXChangeDeviceControl(ClientPtr client)
int i, status, ret = BadValue;
DeviceIntPtr dev;
xDeviceResolutionCtl *r;
xChangeDeviceControlReply rep;
AxisInfoPtr a;
CARD32 *resolution;
xDeviceEnableCtl *e;
@ -127,7 +126,7 @@ ProcXChangeDeviceControl(ClientPtr client)
goto out;
}
rep = (xChangeDeviceControlReply) {
xChangeDeviceControlReply rep = {
.repType = X_Reply,
.RepType = X_ChangeDeviceControl,
.sequenceNumber = client->sequence,

View File

@ -69,21 +69,12 @@ int
ProcXGetDeviceButtonMapping(ClientPtr client)
{
DeviceIntPtr dev;
xGetDeviceButtonMappingReply rep;
ButtonClassPtr b;
int rc;
REQUEST(xGetDeviceButtonMappingReq);
REQUEST_SIZE_MATCH(xGetDeviceButtonMappingReq);
rep = (xGetDeviceButtonMappingReply) {
.repType = X_Reply,
.RepType = X_GetDeviceButtonMapping,
.sequenceNumber = client->sequence,
.nElts = 0,
.length = 0
};
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
@ -92,8 +83,14 @@ ProcXGetDeviceButtonMapping(ClientPtr client)
if (b == NULL)
return BadMatch;
rep.nElts = b->numButtons;
rep.length = bytes_to_int32(rep.nElts);
xGetDeviceButtonMappingReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceButtonMapping,
.sequenceNumber = client->sequence,
.nElts = b->numButtons,
.length = bytes_to_int32(b->numButtons),
};
WriteReplyToClient(client, sizeof(xGetDeviceButtonMappingReply), &rep);
WriteToClient(client, rep.nElts, &b->map[1]);
return Success;

View File

@ -170,7 +170,6 @@ ProcXGetDeviceControl(ClientPtr client)
int rc, total_length = 0;
char *savbuf;
DeviceIntPtr dev;
xGetDeviceControlReply rep;
REQUEST(xGetDeviceControlReq);
REQUEST_SIZE_MATCH(xGetDeviceControlReq);
@ -179,13 +178,6 @@ ProcXGetDeviceControl(ClientPtr client)
if (rc != Success)
return rc;
rep = (xGetDeviceControlReply) {
.repType = X_Reply,
.RepType = X_GetDeviceControl,
.sequenceNumber = client->sequence,
.length = 0
};
switch (stuff->control) {
case DEVICE_RESOLUTION:
if (!dev->valuator)
@ -225,7 +217,13 @@ ProcXGetDeviceControl(ClientPtr client)
break;
}
rep.length = bytes_to_int32(total_length);
xGetDeviceControlReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceControl,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(total_length),
};
WriteReplyToClient(client, sizeof(xGetDeviceControlReply), &rep);
WriteToClient(client, total_length, savbuf);
free(savbuf);

View File

@ -269,7 +269,6 @@ ProcXGetFeedbackControl(ClientPtr client)
StringFeedbackPtr s;
BellFeedbackPtr b;
LedFeedbackPtr l;
xGetFeedbackControlReply rep;
REQUEST(xGetFeedbackControlReq);
REQUEST_SIZE_MATCH(xGetFeedbackControlReq);
@ -278,7 +277,7 @@ ProcXGetFeedbackControl(ClientPtr client)
if (rc != Success)
return rc;
rep = (xGetFeedbackControlReply) {
xGetFeedbackControlReply rep = {
.repType = X_Reply,
.RepType = X_GetFeedbackControl,
.sequenceNumber = client->sequence,

View File

@ -71,7 +71,6 @@ ProcXGetDeviceFocus(ClientPtr client)
{
DeviceIntPtr dev;
FocusClassPtr focus;
xGetDeviceFocusReply rep;
int rc;
REQUEST(xGetDeviceFocusReq);
@ -83,7 +82,7 @@ ProcXGetDeviceFocus(ClientPtr client)
if (!dev->focus)
return BadDevice;
rep = (xGetDeviceFocusReply) {
xGetDeviceFocusReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceFocus,
.sequenceNumber = client->sequence,

View File

@ -71,7 +71,6 @@ SOFTWARE.
int
ProcXGetDeviceKeyMapping(ClientPtr client)
{
xGetDeviceKeyMappingReply rep;
DeviceIntPtr dev;
XkbDescPtr xkb;
KeySymsPtr syms;
@ -102,7 +101,7 @@ ProcXGetDeviceKeyMapping(ClientPtr client)
if (!syms)
return BadAlloc;
rep = (xGetDeviceKeyMappingReply) {
xGetDeviceKeyMappingReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceKeyMapping,
.sequenceNumber = client->sequence,

View File

@ -69,7 +69,6 @@ int
ProcXGetDeviceModifierMapping(ClientPtr client)
{
DeviceIntPtr dev;
xGetDeviceModifierMappingReply rep;
KeyCode *modkeymap = NULL;
int ret, max_keys_per_mod;
@ -84,7 +83,7 @@ ProcXGetDeviceModifierMapping(ClientPtr client)
if (ret != Success)
return ret;
rep = (xGetDeviceModifierMappingReply) {
xGetDeviceModifierMappingReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceModifierMapping,
.sequenceNumber = client->sequence,

View File

@ -94,13 +94,12 @@ ProcXGetDeviceDontPropagateList(ClientPtr client)
int i, rc;
XEventClass *buf = NULL, *tbuf;
WindowPtr pWin;
xGetDeviceDontPropagateListReply rep;
OtherInputMasks *others;
REQUEST(xGetDeviceDontPropagateListReq);
REQUEST_SIZE_MATCH(xGetDeviceDontPropagateListReq);
rep = (xGetDeviceDontPropagateListReply) {
xGetDeviceDontPropagateListReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceDontPropagateList,
.sequenceNumber = client->sequence,

View File

@ -90,7 +90,6 @@ int
ProcXGetSelectedExtensionEvents(ClientPtr client)
{
int i, rc, total_length = 0;
xGetSelectedExtensionEventsReply rep;
WindowPtr pWin;
XEventClass *buf = NULL;
XEventClass *tclient;
@ -101,7 +100,7 @@ ProcXGetSelectedExtensionEvents(ClientPtr client)
REQUEST(xGetSelectedExtensionEventsReq);
REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);
rep = (xGetSelectedExtensionEventsReply) {
xGetSelectedExtensionEventsReply rep = {
.repType = X_Reply,
.RepType = X_GetSelectedExtensionEvents,
.sequenceNumber = client->sequence,

View File

@ -86,8 +86,6 @@ SProcXGetExtensionVersion(ClientPtr client)
int
ProcXGetExtensionVersion(ClientPtr client)
{
xGetExtensionVersionReply rep;
REQUEST(xGetExtensionVersionReq);
REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq);
@ -95,7 +93,7 @@ ProcXGetExtensionVersion(ClientPtr client)
stuff->nbytes))
return BadLength;
rep = (xGetExtensionVersionReply) {
xGetExtensionVersionReply rep = {
.repType = X_Reply,
.RepType = X_GetExtensionVersion,
.sequenceNumber = client->sequence,

View File

@ -100,7 +100,6 @@ int
ProcXGrabDevice(ClientPtr client)
{
int rc;
xGrabDeviceReply rep;
DeviceIntPtr dev;
GrabMask mask;
struct tmask tmp[EMASKSIZE];
@ -112,7 +111,7 @@ ProcXGrabDevice(ClientPtr client)
bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count)
return BadLength;
rep = (xGrabDeviceReply) {
xGrabDeviceReply rep = {
.repType = X_Reply,
.RepType = X_GrabDevice,
.sequenceNumber = client->sequence,

View File

@ -87,7 +87,6 @@ int
ProcXGetDeviceMotionEvents(ClientPtr client)
{
INT32 *coords = NULL, *bufptr;
xGetDeviceMotionEventsReply rep;
unsigned long i;
int rc, num_events, axes, size = 0;
unsigned long nEvents;
@ -97,8 +96,8 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
ValuatorClassPtr v;
REQUEST(xGetDeviceMotionEventsReq);
REQUEST_SIZE_MATCH(xGetDeviceMotionEventsReq);
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess);
if (rc != Success)
return rc;
@ -108,7 +107,8 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
if (dev->valuator->motionHintWindow)
MaybeStopDeviceHint(dev, client);
axes = v->numAxes;
rep = (xGetDeviceMotionEventsReply) {
xGetDeviceMotionEventsReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceMotionEvents,
.sequenceNumber = client->sequence,
@ -117,6 +117,7 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
.axes = axes,
.mode = Absolute /* XXX we don't do relative at the moment */
};
start = ClientTimeToServerTime(stuff->start);
stop = ClientTimeToServerTime(stuff->stop);
if (CompareTimeStamps(start, stop) == LATER ||

View File

@ -316,7 +316,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;
@ -328,7 +327,7 @@ ProcXListInputDevices(ClientPtr client)
REQUEST_SIZE_MATCH(xListInputDevicesReq);
rep = (xListInputDevicesReply) {
xListInputDevicesReply rep = {
.repType = X_Reply,
.RepType = X_ListInputDevices,
.sequenceNumber = client->sequence,

View File

@ -79,7 +79,6 @@ ProcXOpenDevice(ClientPtr client)
xInputClassInfo evbase[numInputClasses];
int j = 0;
int status = Success;
xOpenDeviceReply rep;
DeviceIntPtr dev;
REQUEST(xOpenDeviceReq);
@ -130,7 +129,8 @@ ProcXOpenDevice(ClientPtr client)
}
evbase[j].class = OtherClass;
evbase[j++].event_type_base = event_base[OtherClass];
rep = (xOpenDeviceReply) {
xOpenDeviceReply rep = {
.repType = X_Reply,
.RepType = X_OpenDevice,
.sequenceNumber = client->sequence,

View File

@ -66,7 +66,6 @@ ProcXQueryDeviceState(ClientPtr client)
xButtonState *tb;
ValuatorClassPtr v;
xValuatorState *tv;
xQueryDeviceStateReply rep;
DeviceIntPtr dev;
double *values;
@ -144,7 +143,7 @@ ProcXQueryDeviceState(ClientPtr client)
}
}
rep = (xQueryDeviceStateReply) {
xQueryDeviceStateReply rep = {
.repType = X_Reply,
.RepType = X_QueryDeviceState,
.sequenceNumber = client->sequence,

View File

@ -72,7 +72,6 @@ int
ProcXSetDeviceButtonMapping(ClientPtr client)
{
int ret;
xSetDeviceButtonMappingReply rep;
DeviceIntPtr dev;
REQUEST(xSetDeviceButtonMappingReq);
@ -86,7 +85,7 @@ ProcXSetDeviceButtonMapping(ClientPtr client)
if (ret != Success)
return ret;
rep = (xSetDeviceButtonMappingReply) {
xSetDeviceButtonMappingReply rep = {
.repType = X_Reply,
.RepType = X_SetDeviceButtonMapping,
.sequenceNumber = client->sequence,

View File

@ -73,13 +73,12 @@ int
ProcXSetDeviceValuators(ClientPtr client)
{
DeviceIntPtr dev;
xSetDeviceValuatorsReply rep;
int rc;
REQUEST(xSetDeviceValuatorsReq);
REQUEST_AT_LEAST_SIZE(xSetDeviceValuatorsReq);
rep = (xSetDeviceValuatorsReply) {
xSetDeviceValuatorsReply rep = {
.repType = X_Reply,
.RepType = X_SetDeviceValuators,
.sequenceNumber = client->sequence,

View File

@ -73,7 +73,6 @@ int
ProcXSetDeviceModifierMapping(ClientPtr client)
{
int ret;
xSetDeviceModifierMappingReply rep;
DeviceIntPtr dev;
REQUEST(xSetDeviceModifierMappingReq);
@ -83,13 +82,6 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
(stuff->numKeyPerModifier << 1))
return BadLength;
rep = (xSetDeviceModifierMappingReply) {
.repType = X_Reply,
.RepType = X_SetDeviceModifierMapping,
.sequenceNumber = client->sequence,
.length = 0
};
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
if (ret != Success)
return ret;
@ -99,6 +91,13 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
if (ret == Success)
ret = MappingSuccess;
xSetDeviceModifierMappingReply rep = {
.repType = X_Reply,
.RepType = X_SetDeviceModifierMapping,
.sequenceNumber = client->sequence,
.length = 0
};
if (ret == MappingSuccess || ret == MappingBusy || ret == MappingFailed) {
rep.success = ret;
WriteReplyToClient(client, sizeof(xSetDeviceModifierMappingReply),

View File

@ -73,13 +73,12 @@ int
ProcXSetDeviceMode(ClientPtr client)
{
DeviceIntPtr dev;
xSetDeviceModeReply rep;
int rc;
REQUEST(xSetDeviceModeReq);
REQUEST_SIZE_MATCH(xSetDeviceModeReq);
rep = (xSetDeviceModeReply) {
xSetDeviceModeReply rep = {
.repType = X_Reply,
.RepType = X_SetDeviceMode,
.sequenceNumber = client->sequence,

View File

@ -61,7 +61,6 @@ ProcXIGetClientPointer(ClientPtr client)
{
int rc;
ClientPtr winclient;
xXIGetClientPointerReply rep;
REQUEST(xXIGetClientPointerReq);
REQUEST_SIZE_MATCH(xXIGetClientPointerReq);
@ -75,7 +74,7 @@ ProcXIGetClientPointer(ClientPtr client)
else
winclient = client;
rep = (xXIGetClientPointerReply) {
xXIGetClientPointerReply rep = {
.repType = X_Reply,
.RepType = X_XIGetClientPointer,
.sequenceNumber = client->sequence,

View File

@ -67,7 +67,6 @@ int
ProcXIGrabDevice(ClientPtr client)
{
DeviceIntPtr dev;
xXIGrabDeviceReply rep;
int ret = Success;
uint8_t status;
GrabMask mask = { 0 };
@ -123,7 +122,7 @@ ProcXIGrabDevice(ClientPtr client)
if (ret != Success)
return ret;
rep = (xXIGrabDeviceReply) {
xXIGrabDeviceReply rep = {
.repType = X_Reply,
.RepType = X_XIGrabDevice,
.sequenceNumber = client->sequence,

View File

@ -849,7 +849,6 @@ int
ProcXListDeviceProperties(ClientPtr client)
{
Atom *atoms;
xListDevicePropertiesReply rep;
int natoms;
DeviceIntPtr dev;
int rc = Success;
@ -865,7 +864,7 @@ ProcXListDeviceProperties(ClientPtr client)
if (rc != Success)
return rc;
rep = (xListDevicePropertiesReply) {
xListDevicePropertiesReply rep = {
.repType = X_Reply,
.RepType = X_ListDeviceProperties,
.sequenceNumber = client->sequence,
@ -946,7 +945,6 @@ ProcXGetDeviceProperty(ClientPtr client)
int rc, format, nitems, bytes_after;
char *data;
Atom type;
xGetDevicePropertyReply reply;
REQUEST_SIZE_MATCH(xGetDevicePropertyReq);
if (stuff->delete)
@ -963,7 +961,7 @@ ProcXGetDeviceProperty(ClientPtr client)
if (rc != Success)
return rc;
reply = (xGetDevicePropertyReply) {
xGetDevicePropertyReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceProperty,
.sequenceNumber = client->sequence,
@ -975,13 +973,13 @@ ProcXGetDeviceProperty(ClientPtr client)
.deviceid = dev->id
};
if (stuff->delete && (reply.bytesAfter == 0))
if (stuff->delete && (rep.bytesAfter == 0))
send_property_event(dev, stuff->property, XIPropertyDeleted);
WriteReplyToClient(client, sizeof(xGenericReply), &reply);
WriteReplyToClient(client, sizeof(xGenericReply), &rep);
if (length) {
switch (reply.format) {
switch (rep.format) {
case 32:
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
break;
@ -996,7 +994,7 @@ ProcXGetDeviceProperty(ClientPtr client)
}
/* delete the Property */
if (stuff->delete && (reply.bytesAfter == 0)) {
if (stuff->delete && (rep.bytesAfter == 0)) {
XIPropertyPtr prop, *prev;
for (prev = &dev->properties.properties; (prop = *prev);
@ -1077,7 +1075,6 @@ int
ProcXIListProperties(ClientPtr client)
{
Atom *atoms;
xXIListPropertiesReply rep;
int natoms;
DeviceIntPtr dev;
int rc = Success;
@ -1093,7 +1090,7 @@ ProcXIListProperties(ClientPtr client)
if (rc != Success)
return rc;
rep = (xXIListPropertiesReply) {
xXIListPropertiesReply rep = {
.repType = X_Reply,
.RepType = X_XIListProperties,
.sequenceNumber = client->sequence,
@ -1171,7 +1168,6 @@ ProcXIGetProperty(ClientPtr client)
{
REQUEST(xXIGetPropertyReq);
DeviceIntPtr dev;
xXIGetPropertyReply reply;
int length;
int rc, format, nitems, bytes_after;
char *data;
@ -1192,7 +1188,7 @@ ProcXIGetProperty(ClientPtr client)
if (rc != Success)
return rc;
reply = (xXIGetPropertyReply) {
xXIGetPropertyReply rep = {
.repType = X_Reply,
.RepType = X_XIGetProperty,
.sequenceNumber = client->sequence,
@ -1203,13 +1199,13 @@ ProcXIGetProperty(ClientPtr client)
.format = format
};
if (length && stuff->delete && (reply.bytes_after == 0))
if (length && stuff->delete && (rep.bytes_after == 0))
send_property_event(dev, stuff->property, XIPropertyDeleted);
WriteReplyToClient(client, sizeof(xXIGetPropertyReply), &reply);
WriteReplyToClient(client, sizeof(xXIGetPropertyReply), &rep);
if (length) {
switch (reply.format) {
switch (rep.format) {
case 32:
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
break;
@ -1224,7 +1220,7 @@ ProcXIGetProperty(ClientPtr client)
}
/* delete the Property */
if (stuff->delete && (reply.bytes_after == 0)) {
if (stuff->delete && (rep.bytes_after == 0)) {
XIPropertyPtr prop, *prev;
for (prev = &dev->properties.properties; (prop = *prev);

View File

@ -67,7 +67,6 @@ SProcXIQueryDevice(ClientPtr client)
int
ProcXIQueryDevice(ClientPtr client)
{
xXIQueryDeviceReply rep;
DeviceIntPtr dev = NULL;
int rc = Success;
int i = 0, len = 0;
@ -110,7 +109,7 @@ ProcXIQueryDevice(ClientPtr client)
return BadAlloc;
}
rep = (xXIQueryDeviceReply) {
xXIQueryDeviceReply rep = {
.repType = X_Reply,
.RepType = X_XIQueryDevice,
.sequenceNumber = client->sequence,

View File

@ -77,7 +77,6 @@ int
ProcXIQueryPointer(ClientPtr client)
{
int rc;
xXIQueryPointerReply rep;
DeviceIntPtr pDev, kbd;
WindowPtr pWin, t;
SpritePtr pSprite;
@ -127,7 +126,7 @@ ProcXIQueryPointer(ClientPtr client)
pSprite = pDev->spriteInfo->sprite;
rep = (xXIQueryPointerReply) {
xXIQueryPointerReply rep = {
.repType = X_Reply,
.RepType = X_XIQueryPointer,
.sequenceNumber = client->sequence,

View File

@ -54,7 +54,6 @@ extern XExtensionVersion XIVersion; /* defined in getvers.c */
int
ProcXIQueryVersion(ClientPtr client)
{
xXIQueryVersionReply rep;
XIClientPtr pXIClient;
int major, minor;
@ -113,7 +112,7 @@ ProcXIQueryVersion(ClientPtr client)
pXIClient->minor_version = minor;
}
rep = (xXIQueryVersionReply) {
xXIQueryVersionReply rep = {
.repType = X_Reply,
.RepType = X_XIQueryVersion,
.sequenceNumber = client->sequence,

View File

@ -343,7 +343,6 @@ ProcXIGetSelectedEvents(ClientPtr client)
int rc, i;
WindowPtr win;
char *buffer = NULL;
xXIGetSelectedEventsReply reply;
OtherInputMasks *masks;
InputClientsPtr others = NULL;
xXIEventMask *evmask = NULL;
@ -357,7 +356,7 @@ ProcXIGetSelectedEvents(ClientPtr client)
if (rc != Success)
return rc;
reply = (xXIGetSelectedEventsReply) {
xXIGetSelectedEventsReply rep = {
.repType = X_Reply,
.RepType = X_XIGetSelectedEvents,
.sequenceNumber = client->sequence,
@ -376,7 +375,7 @@ ProcXIGetSelectedEvents(ClientPtr client)
}
if (!others) {
WriteReplyToClient(client, sizeof(xXIGetSelectedEventsReply), &reply);
WriteReplyToClient(client, sizeof(xXIGetSelectedEventsReply), &rep);
return Success;
}
@ -402,8 +401,8 @@ ProcXIGetSelectedEvents(ClientPtr client)
evmask->deviceid = i;
evmask->mask_len = mask_len;
reply.num_masks++;
reply.length += sizeof(xXIEventMask) / 4 + evmask->mask_len;
rep.num_masks++;
rep.length += sizeof(xXIEventMask) / 4 + evmask->mask_len;
if (client->swapped) {
swaps(&evmask->deviceid);
@ -419,10 +418,10 @@ ProcXIGetSelectedEvents(ClientPtr client)
}
/* save the value before SRepXIGetSelectedEvents swaps it */
length = reply.length;
WriteReplyToClient(client, sizeof(xXIGetSelectedEventsReply), &reply);
length = rep.length;
WriteReplyToClient(client, sizeof(xXIGetSelectedEventsReply), &rep);
if (reply.num_masks)
if (rep.num_masks)
WriteToClient(client, length * 4, buffer);
free(buffer);

View File

@ -86,7 +86,6 @@ ProcXISetFocus(ClientPtr client)
int
ProcXIGetFocus(ClientPtr client)
{
xXIGetFocusReply rep;
DeviceIntPtr dev;
int ret;
@ -99,7 +98,7 @@ ProcXIGetFocus(ClientPtr client)
if (!dev->focus)
return BadDevice;
rep = (xXIGetFocusReply) {
xXIGetFocusReply rep = {
.repType = X_Reply,
.RepType = X_XIGetFocus,
.sequenceNumber = client->sequence,