dix: inline SProcResourceReq()

Simplifying byte-swapping code flow by inlining SProcResourceReq()
instead of having complicated call chains.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-09-25 14:46:52 +02:00 committed by Enrico Weigelt
parent 794a3f3630
commit 5ccaceb43c
8 changed files with 143 additions and 61 deletions

View File

@ -797,9 +797,13 @@ ProcDestroyWindow(ClientPtr client)
WindowPtr pWin;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
int rc;
REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupWindow(&pWin, stuff->id, client, DixDestroyAccess);
if (rc != Success)
return rc;
@ -819,9 +823,13 @@ ProcDestroySubwindows(ClientPtr client)
WindowPtr pWin;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
int rc;
REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupWindow(&pWin, stuff->id, client, DixRemoveAccess);
if (rc != Success)
return rc;
@ -835,9 +843,13 @@ ProcChangeSaveSet(ClientPtr client)
WindowPtr pWin;
REQUEST(xChangeSaveSetReq);
REQUEST_SIZE_MATCH(xChangeSaveSetReq);
if (client->swapped)
swapl(&stuff->window);
int rc;
REQUEST_SIZE_MATCH(xChangeSaveSetReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess);
if (rc != Success)
return rc;
@ -882,9 +894,12 @@ ProcMapWindow(ClientPtr client)
WindowPtr pWin;
REQUEST(xResourceReq);
int rc;
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
int rc;
rc = dixLookupWindow(&pWin, stuff->id, client, DixShowAccess);
if (rc != Success)
return rc;
@ -899,9 +914,13 @@ ProcMapSubwindows(ClientPtr client)
WindowPtr pWin;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
int rc;
REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess);
if (rc != Success)
return rc;
@ -916,9 +935,13 @@ ProcUnmapWindow(ClientPtr client)
WindowPtr pWin;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
int rc;
REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupWindow(&pWin, stuff->id, client, DixHideAccess);
if (rc != Success)
return rc;
@ -933,9 +956,13 @@ ProcUnmapSubwindows(ClientPtr client)
WindowPtr pWin;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
int rc;
REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess);
if (rc != Success)
return rc;
@ -968,9 +995,13 @@ ProcCirculateWindow(ClientPtr client)
WindowPtr pWin;
REQUEST(xCirculateWindowReq);
REQUEST_SIZE_MATCH(xCirculateWindowReq);
if (client->swapped)
swapl(&stuff->window);
int rc;
REQUEST_SIZE_MATCH(xCirculateWindowReq);
if ((stuff->direction != RaiseLowest) && (stuff->direction != LowerHighest)) {
client->errorValue = stuff->direction;
return BadValue;
@ -991,6 +1022,9 @@ ProcGetGeometry(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
rc = dixLookupDrawable(&pDraw, stuff->id, client, M_ANY, DixGetAttrAccess);
if (rc != Success)
return rc;
@ -1029,8 +1063,11 @@ ProcQueryTree(ClientPtr client)
WindowPtr pWin, pHead;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess);
if (rc != Success)
return rc;
@ -1095,8 +1132,11 @@ ProcGetAtomName(ClientPtr client)
const char *str;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
if (!(str = NameForAtom(stuff->id))) {
client->errorValue = stuff->id;
return BadAtom;
@ -1282,8 +1322,11 @@ ProcCloseFont(ClientPtr client)
int rc;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
rc = dixLookupResourceByType((void **) &pFont, stuff->id, X11_RESTYPE_FONT,
client, DixDestroyAccess);
if (rc == Success) {
@ -1306,6 +1349,9 @@ ProcQueryFont(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
rc = dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess);
if (rc != Success)
return rc;
@ -1357,6 +1403,9 @@ ProcQueryTextExtents(ClientPtr client)
REQUEST(xQueryTextExtentsReq);
REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq);
if (client->swapped)
swapl(&stuff->fid);
rc = dixLookupFontable(&pFont, stuff->fid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
@ -1507,6 +1556,9 @@ ProcFreePixmap(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
rc = dixLookupResourceByType((void **) &pMap, stuff->id, X11_RESTYPE_PIXMAP,
client, DixDestroyAccess);
if (rc == Success) {
@ -1655,6 +1707,9 @@ ProcFreeGC(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
rc = dixLookupGC(&pGC, stuff->id, client, DixDestroyAccess);
if (rc != Success)
return rc;
@ -2443,8 +2498,11 @@ ProcFreeColormap(ClientPtr client)
int rc;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
rc = dixLookupResourceByType((void **) &pmap, stuff->id, X11_RESTYPE_COLORMAP,
client, DixDestroyAccess);
if (rc == Success) {
@ -2489,6 +2547,9 @@ ProcInstallColormap(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
rc = dixLookupResourceByType((void **) &pcmp, stuff->id, X11_RESTYPE_COLORMAP,
client, DixInstallAccess);
if (rc != Success)
@ -2518,6 +2579,9 @@ ProcUninstallColormap(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
rc = dixLookupResourceByType((void **) &pcmp, stuff->id, X11_RESTYPE_COLORMAP,
client, DixUninstallAccess);
if (rc != Success)
@ -2548,6 +2612,9 @@ ProcListInstalledColormaps(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
if (rc != Success)
return rc;
@ -3109,8 +3176,11 @@ ProcFreeCursor(ClientPtr client)
int rc;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
rc = dixLookupResourceByType((void **) &pCursor, stuff->id, X11_RESTYPE_CURSOR,
client, DixDestroyAccess);
if (rc == Success) {
@ -3357,10 +3427,14 @@ int
ProcKillClient(ClientPtr client)
{
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
ClientPtr killclient;
int rc;
REQUEST_SIZE_MATCH(xResourceReq);
if (stuff->id == AllTemporary) {
CloseDownRetainedResources();
return Success;

View File

@ -1942,8 +1942,11 @@ ProcAllowEvents(ClientPtr client)
DeviceIntPtr keybd = NULL;
REQUEST(xAllowEventsReq);
REQUEST_SIZE_MATCH(xAllowEventsReq);
if (client->swapped)
swapl(&stuff->time);
UpdateCurrentTime();
time = ClientTimeToServerTime(stuff->time);
@ -5115,8 +5118,11 @@ ProcUngrabPointer(ClientPtr client)
TimeStamp time;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
UpdateCurrentTime();
grab = device->deviceGrab.grab;
@ -5300,8 +5306,11 @@ ProcUngrabKeyboard(ClientPtr client)
TimeStamp time;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
UpdateCurrentTime();
grab = device->deviceGrab.grab;
@ -5332,6 +5341,9 @@ ProcQueryPointer(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
if (rc != Success)
return rc;

View File

@ -651,8 +651,11 @@ ProcListProperties(ClientPtr client)
WindowPtr pWin;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
int rc = dixLookupWindow(&pWin, stuff->id, client, DixListPropAccess);
if (rc != Success)
return rc;

View File

@ -246,6 +246,9 @@ ProcGetSelectionOwner(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
/* allow extensions to intercept */
SelectionFilterParamRec param = {
.client = client,

View File

@ -115,18 +115,6 @@ SwapShorts(short *list, unsigned long count)
}
}
/* The following is used for all requests that have
only a single 32-bit field to be swapped, coming
right after the "length" field */
int _X_COLD
SProcResourceReq(ClientPtr client)
{
REQUEST(xResourceReq);
REQUEST_AT_LEAST_SIZE(xResourceReq); /* not EXACT */
swapl(&stuff->id);
return (*ProcVector[stuff->reqType]) (client);
}
int _X_COLD
SProcCreateWindow(ClientPtr client)
{

View File

@ -334,42 +334,42 @@ int (*SwappedProcVector[256]) (ClientPtr /* client */) = {
ProcBadRequest,
SProcCreateWindow,
SProcChangeWindowAttributes,
SProcResourceReq, /* GetWindowAttributes */
SProcResourceReq, /* DestroyWindow */
SProcResourceReq, /* 5 DestroySubwindows */
SProcResourceReq, /* SProcChangeSaveSet, */
ProcGetWindowAttributes,
ProcDestroyWindow,
ProcDestroySubwindows, /* 5 */
ProcChangeSaveSet,
SProcReparentWindow,
SProcResourceReq, /* MapWindow */
SProcResourceReq, /* MapSubwindows */
SProcResourceReq, /* 10 UnmapWindow */
SProcResourceReq, /* UnmapSubwindows */
ProcMapWindow,
ProcMapSubwindows,
ProcUnmapWindow, /* 10 */
ProcUnmapSubwindows,
SProcConfigureWindow,
SProcResourceReq, /* SProcCirculateWindow, */
SProcResourceReq, /* GetGeometry */
SProcResourceReq, /* 15 QueryTree */
ProcCirculateWindow,
ProcGetGeometry,
ProcQueryTree, /* 15 */
SProcInternAtom,
SProcResourceReq, /* SProcGetAtomName, */
ProcGetAtomName,
SProcChangeProperty,
SProcDeleteProperty,
SProcGetProperty, /* 20 */
SProcResourceReq, /* SProcListProperties, */
ProcListProperties,
SProcSetSelectionOwner,
SProcResourceReq, /* SProcGetSelectionOwner, */
ProcGetSelectionOwner,
SProcConvertSelection,
SProcSendEvent, /* 25 */
SProcGrabPointer,
SProcResourceReq, /* SProcUngrabPointer, */
ProcUngrabPointer,
SProcGrabButton,
SProcUngrabButton,
SProcChangeActivePointerGrab, /* 30 */
SProcGrabKeyboard,
SProcResourceReq, /* SProcUngrabKeyboard, */
ProcUngrabKeyboard,
SProcGrabKey,
SProcUngrabKey,
SProcResourceReq, /* 35 SProcAllowEvents, */
ProcAllowEvents,
ProcGrabServer,
ProcUngrabServer,
SProcResourceReq, /* SProcQueryPointer, */
ProcQueryPointer,
SProcGetMotionEvents,
SProcTranslateCoords, /*40 */
SProcWarpPointer,
@ -377,21 +377,21 @@ int (*SwappedProcVector[256]) (ClientPtr /* client */) = {
ProcGetInputFocus,
ProcQueryKeymap,
SProcOpenFont, /* 45 */
SProcResourceReq, /* SProcCloseFont, */
SProcResourceReq, /* SProcQueryFont, */
SProcResourceReq, /* SProcQueryTextExtents, */
ProcCloseFont,
ProcQueryFont,
ProcQueryTextExtents,
SProcListFonts,
SProcListFontsWithInfo, /* 50 */
SProcSetFontPath,
ProcGetFontPath,
SProcCreatePixmap,
SProcResourceReq, /* SProcFreePixmap, */
ProcFreePixmap,
SProcCreateGC, /* 55 */
SProcChangeGC,
SProcCopyGC,
SProcSetDashes,
SProcSetClipRectangles,
SProcResourceReq, /* 60 SProcFreeGC, */
ProcFreeGC, /* 60 */
SProcClearToBackground,
SProcCopyArea,
SProcCopyPlane,
@ -410,11 +410,11 @@ int (*SwappedProcVector[256]) (ClientPtr /* client */) = {
SProcImageText,
SProcImageText,
SProcCreateColormap,
SProcResourceReq, /* SProcFreeColormap, */
ProcFreeColormap,
SProcCopyColormapAndFree, /* 80 */
SProcResourceReq, /* SProcInstallColormap, */
SProcResourceReq, /* SProcUninstallColormap, */
SProcResourceReq, /* SProcListInstalledColormaps, */
ProcInstallColormap,
ProcUninstallColormap,
ProcListInstalledColormaps,
SProcAllocColor,
SProcAllocNamedColor, /* 85 */
SProcAllocColorCells,
@ -426,7 +426,7 @@ int (*SwappedProcVector[256]) (ClientPtr /* client */) = {
SProcLookupColor,
SProcCreateCursor,
SProcCreateGlyphCursor,
SProcResourceReq, /* 95 SProcFreeCursor, */
ProcFreeCursor, /* 95 */
SProcRecolorCursor,
SProcQueryBestSize,
SProcQueryExtension,
@ -444,7 +444,7 @@ int (*SwappedProcVector[256]) (ClientPtr /* client */) = {
ProcListHosts, /* 110 */
ProcChangeAccessControl,
ProcChangeCloseDownMode,
SProcResourceReq, /* SProcKillClient, */
ProcKillClient,
SProcRotateProperties,
ProcForceScreenSaver, /* 115 */
ProcSetPointerMapping,

View File

@ -1567,6 +1567,9 @@ ProcGetWindowAttributes(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if (client->swapped)
swapl(&stuff->id);
WindowPtr pWin;
int rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
if (rc != Success)

View File

@ -73,7 +73,6 @@ int SProcQueryBestSize(ClientPtr client);
int SProcQueryColors(ClientPtr client);
int SProcQueryExtension(ClientPtr client);
int SProcReparentWindow(ClientPtr client);
int SProcResourceReq(ClientPtr client);
int SProcRotateProperties(ClientPtr client);
int SProcSetClipRectangles(ClientPtr client);
int SProcSetDashes(ClientPtr client);