From eafda4d01f6c12cbcb87f15fdc5a3906803db04e Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 10 Jul 2024 20:16:23 +0200 Subject: [PATCH] (1613) Xi: use static reply struct init on declaration Make the code a bit easier to read by using initialization of the reply structs, at the point of declaration. Most of them aren't written to later, just passed into WriteReplyToClient(). Also dropping some useless zero assignments (struct initializers automatically zero-out unmentioned fields). Signed-off-by: Enrico Weigelt, metux IT consult --- Xi/chgdctl.c | 1 - Xi/getfctl.c | 1 - Xi/getfocus.c | 10 ++++------ Xi/getmmap.c | 2 +- Xi/getprop.c | 2 -- Xi/getselev.c | 3 --- Xi/getvers.c | 1 - Xi/grabdev.c | 1 - Xi/grabdevb.c | 3 +-- Xi/grabdevk.c | 3 +-- Xi/listdev.c | 17 ++++++++--------- Xi/setmode.c | 1 - Xi/xigetclientpointer.c | 1 - Xi/xiquerydevice.c | 1 - Xi/xiselectev.c | 2 -- Xi/xisetdevfocus.c | 1 - 16 files changed, 15 insertions(+), 35 deletions(-) diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c index 84d6171b0..80e49e320 100644 --- a/Xi/chgdctl.c +++ b/Xi/chgdctl.c @@ -126,7 +126,6 @@ ProcXChangeDeviceControl(ClientPtr client) } xChangeDeviceControlReply rep = { - .repType = X_Reply, .RepType = X_ChangeDeviceControl, .sequenceNumber = client->sequence, .status = Success, diff --git a/Xi/getfctl.c b/Xi/getfctl.c index 7379ad23b..f25b77650 100644 --- a/Xi/getfctl.c +++ b/Xi/getfctl.c @@ -264,7 +264,6 @@ ProcXGetFeedbackControl(ClientPtr client) .repType = X_Reply, .RepType = X_GetFeedbackControl, .sequenceNumber = client->sequence, - .num_feedbacks = 0 }; for (k = dev->kbdfeed; k; k = k->next) { diff --git a/Xi/getfocus.c b/Xi/getfocus.c index ebde12c09..64c7bb66e 100644 --- a/Xi/getfocus.c +++ b/Xi/getfocus.c @@ -82,15 +82,16 @@ ProcXGetDeviceFocus(ClientPtr client) if (!dev->focus) return BadDevice; + focus = dev->focus; + xGetDeviceFocusReply rep = { .repType = X_Reply, .RepType = X_GetDeviceFocus, .sequenceNumber = client->sequence, - .length = 0 + .time = focus->time.milliseconds, + .revertTo = focus->revert, }; - focus = dev->focus; - if (focus->win == NoneWin) rep.focus = None; else if (focus->win == PointerRootWin) @@ -100,9 +101,6 @@ ProcXGetDeviceFocus(ClientPtr client) else rep.focus = focus->win->drawable.id; - rep.time = focus->time.milliseconds; - rep.revertTo = focus->revert; - if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); diff --git a/Xi/getmmap.c b/Xi/getmmap.c index dea7f8254..e0ae696ef 100644 --- a/Xi/getmmap.c +++ b/Xi/getmmap.c @@ -88,7 +88,7 @@ ProcXGetDeviceModifierMapping(ClientPtr client) .RepType = X_GetDeviceModifierMapping, .sequenceNumber = client->sequence, .numKeyPerModifier = max_keys_per_mod, - /* length counts 4 byte quantities - there are 8 modifiers 1 byte big */ + /* length counts 4 byte quantities - there are 8 modifiers 1 byte big */ .length = max_keys_per_mod << 1 }; diff --git a/Xi/getprop.c b/Xi/getprop.c index 63e9a3ba1..108c52cb6 100644 --- a/Xi/getprop.c +++ b/Xi/getprop.c @@ -103,8 +103,6 @@ ProcXGetDeviceDontPropagateList(ClientPtr client) .repType = X_Reply, .RepType = X_GetDeviceDontPropagateList, .sequenceNumber = client->sequence, - .length = 0, - .count = 0 }; rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); diff --git a/Xi/getselev.c b/Xi/getselev.c index 023a5b21f..ecc80f1b8 100644 --- a/Xi/getselev.c +++ b/Xi/getselev.c @@ -104,9 +104,6 @@ ProcXGetSelectedExtensionEvents(ClientPtr client) .repType = X_Reply, .RepType = X_GetSelectedExtensionEvents, .sequenceNumber = client->sequence, - .length = 0, - .this_client_count = 0, - .all_clients_count = 0 }; rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); diff --git a/Xi/getvers.c b/Xi/getvers.c index f1c243880..c02294fe9 100644 --- a/Xi/getvers.c +++ b/Xi/getvers.c @@ -97,7 +97,6 @@ ProcXGetExtensionVersion(ClientPtr client) .repType = X_Reply, .RepType = X_GetExtensionVersion, .sequenceNumber = client->sequence, - .length = 0, .major_version = XIVersion.major_version, .minor_version = XIVersion.minor_version, .present = TRUE diff --git a/Xi/grabdev.c b/Xi/grabdev.c index 9feb68654..0a16f164d 100644 --- a/Xi/grabdev.c +++ b/Xi/grabdev.c @@ -116,7 +116,6 @@ ProcXGrabDevice(ClientPtr client) .repType = X_Reply, .RepType = X_GrabDevice, .sequenceNumber = client->sequence, - .length = 0, }; rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess); diff --git a/Xi/grabdevb.c b/Xi/grabdevb.c index 9a2ef87ab..1d211dea1 100644 --- a/Xi/grabdevb.c +++ b/Xi/grabdevb.c @@ -99,7 +99,6 @@ ProcXGrabDeviceButton(ClientPtr client) DeviceIntPtr mdev; XEventClass *class; struct tmask tmp[EMASKSIZE]; - GrabParameters param; GrabMask mask; REQUEST(xGrabDeviceButtonReq); @@ -135,7 +134,7 @@ ProcXGrabDeviceButton(ClientPtr client) X_GrabDeviceButton)) != Success) return ret; - param = (GrabParameters) { + GrabParameters param = { .grabtype = XI, .ownerEvents = stuff->ownerEvents, .this_device_mode = stuff->this_device_mode, diff --git a/Xi/grabdevk.c b/Xi/grabdevk.c index 7668735ea..24367f62d 100644 --- a/Xi/grabdevk.c +++ b/Xi/grabdevk.c @@ -97,7 +97,6 @@ ProcXGrabDeviceKey(ClientPtr client) DeviceIntPtr mdev; XEventClass *class; struct tmask tmp[EMASKSIZE]; - GrabParameters param; GrabMask mask; REQUEST(xGrabDeviceKeyReq); @@ -133,7 +132,7 @@ ProcXGrabDeviceKey(ClientPtr client) X_GrabDeviceKey)) != Success) return ret; - param = (GrabParameters) { + GrabParameters param = { .grabtype = XI, .ownerEvents = stuff->ownerEvents, .this_device_mode = stuff->this_device_mode, diff --git a/Xi/listdev.c b/Xi/listdev.c index 5be4a8f74..2f24b1c9f 100644 --- a/Xi/listdev.c +++ b/Xi/listdev.c @@ -327,13 +327,6 @@ ProcXListInputDevices(ClientPtr client) REQUEST_SIZE_MATCH(xListInputDevicesReq); - xListInputDevicesReply rep = { - .repType = X_Reply, - .RepType = X_ListInputDevices, - .sequenceNumber = client->sequence, - .length = 0 - }; - /* allocate space for saving skip value */ skip = calloc(inputInfo.numDevices, sizeof(Bool)); if (!skip) @@ -382,8 +375,14 @@ ProcXListInputDevices(ClientPtr client) ListDeviceInfo(client, d, dev++, &devbuf, &classbuf, &namebuf); } - rep.ndevices = numdevs; - rep.length = bytes_to_int32(total_length); + + xListInputDevicesReply rep = { + .repType = X_Reply, + .RepType = X_ListInputDevices, + .sequenceNumber = client->sequence, + .ndevices = numdevs, + .length = bytes_to_int32(total_length), + }; if (client->swapped) { swaps(&rep.sequenceNumber); diff --git a/Xi/setmode.c b/Xi/setmode.c index 62c46f61c..9818606a7 100644 --- a/Xi/setmode.c +++ b/Xi/setmode.c @@ -81,7 +81,6 @@ ProcXSetDeviceMode(ClientPtr client) .repType = X_Reply, .RepType = X_SetDeviceMode, .sequenceNumber = client->sequence, - .length = 0 }; rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess); diff --git a/Xi/xigetclientpointer.c b/Xi/xigetclientpointer.c index 70c91003c..64fccd2d8 100644 --- a/Xi/xigetclientpointer.c +++ b/Xi/xigetclientpointer.c @@ -78,7 +78,6 @@ ProcXIGetClientPointer(ClientPtr client) .repType = X_Reply, .RepType = X_XIGetClientPointer, .sequenceNumber = client->sequence, - .length = 0, .set = (winclient->clientPtr != NULL), .deviceid = (winclient->clientPtr) ? winclient->clientPtr->id : 0 }; diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c index e74696679..e234ca4ca 100644 --- a/Xi/xiquerydevice.c +++ b/Xi/xiquerydevice.c @@ -114,7 +114,6 @@ ProcXIQueryDevice(ClientPtr client) .RepType = X_XIQueryDevice, .sequenceNumber = client->sequence, .length = len / 4, - .num_devices = 0 }; ptr = info; diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c index d760ab02e..236e6bdad 100644 --- a/Xi/xiselectev.c +++ b/Xi/xiselectev.c @@ -358,8 +358,6 @@ ProcXIGetSelectedEvents(ClientPtr client) .repType = X_Reply, .RepType = X_XIGetSelectedEvents, .sequenceNumber = client->sequence, - .length = 0, - .num_masks = 0 }; masks = wOtherInputMasks(win); diff --git a/Xi/xisetdevfocus.c b/Xi/xisetdevfocus.c index f8316ae29..303578237 100644 --- a/Xi/xisetdevfocus.c +++ b/Xi/xisetdevfocus.c @@ -102,7 +102,6 @@ ProcXIGetFocus(ClientPtr client) .repType = X_Reply, .RepType = X_XIGetFocus, .sequenceNumber = client->sequence, - .length = 0 }; if (dev->focus->win == NoneWin)