From 1dbd46b21bef7bb9385c3be8e109fcce3d62de95 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 10 Jul 2024 20:16:23 +0200 Subject: [PATCH] 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 74dce0da5..b0bd882aa 100644 --- a/Xi/chgdctl.c +++ b/Xi/chgdctl.c @@ -127,7 +127,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 4ffb76226..64dab777a 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 6daac08b5..73d71d5bc 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 fe988832b..175f4c9b1 100644 --- a/Xi/grabdev.c +++ b/Xi/grabdev.c @@ -115,7 +115,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 f768b10fd..e0e8878f7 100644 --- a/Xi/grabdevb.c +++ b/Xi/grabdevb.c @@ -100,7 +100,6 @@ ProcXGrabDeviceButton(ClientPtr client) DeviceIntPtr mdev; XEventClass *class; struct tmask tmp[EMASKSIZE]; - GrabParameters param; GrabMask mask; REQUEST(xGrabDeviceButtonReq); @@ -136,7 +135,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 5f9e8284b..2fb1a95dd 100644 --- a/Xi/grabdevk.c +++ b/Xi/grabdevk.c @@ -98,7 +98,6 @@ ProcXGrabDeviceKey(ClientPtr client) DeviceIntPtr mdev; XEventClass *class; struct tmask tmp[EMASKSIZE]; - GrabParameters param; GrabMask mask; REQUEST(xGrabDeviceKeyReq); @@ -134,7 +133,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 dc343cb35..d9ed0acd2 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 d145e57dc..d84e4bcd8 100644 --- a/Xi/setmode.c +++ b/Xi/setmode.c @@ -82,7 +82,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 2ae469d30..e36667960 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 e8caa61f4..95d18f20f 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 cac9b4606..3e3ccdc58 100644 --- a/Xi/xiselectev.c +++ b/Xi/xiselectev.c @@ -359,8 +359,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)