From d03d79f96b00fdbaa3dd6ffe0458b850e83644eb Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 18 Jul 2024 19:08:03 +0200 Subject: [PATCH] dri: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros Use the new macros to make request struct parsing / field swapping much easier. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xfree86/dri/xf86dri.c | 61 ++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c index 20e42d8a3..acf68509e 100644 --- a/hw/xfree86/dri/xf86dri.c +++ b/hw/xfree86/dri/xf86dri.c @@ -43,6 +43,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include "dix/dix_priv.h" +#include "dix/request_priv.h" #include "xf86.h" #include "misc.h" @@ -77,6 +78,8 @@ XF86DRIResetProc(ExtensionEntry *extEntry) static int ProcXF86DRIQueryVersion(register ClientPtr client) { + REQUEST_HEAD_STRUCT(xXF86DRIQueryVersionReq); + xXF86DRIQueryVersionReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, @@ -85,7 +88,6 @@ ProcXF86DRIQueryVersion(register ClientPtr client) .patchVersion = SERVER_XF86DRI_PATCH_VERSION }; - REQUEST_SIZE_MATCH(xXF86DRIQueryVersionReq); if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -100,10 +102,11 @@ ProcXF86DRIQueryVersion(register ClientPtr client) static int ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client) { + REQUEST_HEAD_STRUCT(xXF86DRIQueryDirectRenderingCapableReq); + REQUEST_FIELD_CARD32(screen); + Bool isCapable; - REQUEST(xXF86DRIQueryDirectRenderingCapableReq); - REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq); if (stuff->screen >= screenInfo.numScreens) { client->errorValue = stuff->screen; return BadValue; @@ -137,12 +140,12 @@ ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client) static int ProcXF86DRIOpenConnection(register ClientPtr client) { + REQUEST_HEAD_STRUCT(xXF86DRIOpenConnectionReq); + drm_handle_t hSAREA; char *busIdString; CARD32 busIdStringLength = 0; - REQUEST(xXF86DRIOpenConnectionReq); - REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq); if (stuff->screen >= screenInfo.numScreens) { client->errorValue = stuff->screen; return BadValue; @@ -179,14 +182,14 @@ ProcXF86DRIOpenConnection(register ClientPtr client) static int ProcXF86DRIAuthConnection(register ClientPtr client) { + REQUEST_HEAD_STRUCT(xXF86DRIAuthConnectionReq); + xXF86DRIAuthConnectionReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, .authenticated = 1 }; - REQUEST(xXF86DRIAuthConnectionReq); - REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq); if (stuff->screen >= screenInfo.numScreens) { client->errorValue = stuff->screen; return BadValue; @@ -203,8 +206,8 @@ ProcXF86DRIAuthConnection(register ClientPtr client) static int ProcXF86DRICloseConnection(register ClientPtr client) { - REQUEST(xXF86DRICloseConnectionReq); - REQUEST_SIZE_MATCH(xXF86DRICloseConnectionReq); + REQUEST_HEAD_STRUCT(xXF86DRICloseConnectionReq); + if (stuff->screen >= screenInfo.numScreens) { client->errorValue = stuff->screen; return BadValue; @@ -218,14 +221,14 @@ ProcXF86DRICloseConnection(register ClientPtr client) static int ProcXF86DRIGetClientDriverName(register ClientPtr client) { + REQUEST_HEAD_STRUCT(xXF86DRIGetClientDriverNameReq); + xXF86DRIGetClientDriverNameReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, }; char *clientDriverName; - REQUEST(xXF86DRIGetClientDriverNameReq); - REQUEST_SIZE_MATCH(xXF86DRIGetClientDriverNameReq); if (stuff->screen >= screenInfo.numScreens) { client->errorValue = stuff->screen; return BadValue; @@ -252,14 +255,14 @@ ProcXF86DRIGetClientDriverName(register ClientPtr client) static int ProcXF86DRICreateContext(register ClientPtr client) { + REQUEST_HEAD_STRUCT(xXF86DRICreateContextReq); + xXF86DRICreateContextReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, }; ScreenPtr pScreen; - REQUEST(xXF86DRICreateContextReq); - REQUEST_SIZE_MATCH(xXF86DRICreateContextReq); if (stuff->screen >= screenInfo.numScreens) { client->errorValue = stuff->screen; return BadValue; @@ -280,8 +283,8 @@ ProcXF86DRICreateContext(register ClientPtr client) static int ProcXF86DRIDestroyContext(register ClientPtr client) { - REQUEST(xXF86DRIDestroyContextReq); - REQUEST_SIZE_MATCH(xXF86DRIDestroyContextReq); + REQUEST_HEAD_STRUCT(xXF86DRIDestroyContextReq); + if (stuff->screen >= screenInfo.numScreens) { client->errorValue = stuff->screen; return BadValue; @@ -297,6 +300,8 @@ ProcXF86DRIDestroyContext(register ClientPtr client) static int ProcXF86DRICreateDrawable(ClientPtr client) { + REQUEST_HEAD_STRUCT(xXF86DRICreateDrawableReq); + xXF86DRICreateDrawableReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, @@ -304,8 +309,6 @@ ProcXF86DRICreateDrawable(ClientPtr client) DrawablePtr pDrawable; int rc; - REQUEST(xXF86DRICreateDrawableReq); - REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq); if (stuff->screen >= screenInfo.numScreens) { client->errorValue = stuff->screen; return BadValue; @@ -328,12 +331,11 @@ ProcXF86DRICreateDrawable(ClientPtr client) static int ProcXF86DRIDestroyDrawable(register ClientPtr client) { - REQUEST(xXF86DRIDestroyDrawableReq); + REQUEST_HEAD_STRUCT(xXF86DRIDestroyDrawableReq); + DrawablePtr pDrawable; int rc; - REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq); - if (stuff->screen >= screenInfo.numScreens) { client->errorValue = stuff->screen; return BadValue; @@ -355,6 +357,8 @@ ProcXF86DRIDestroyDrawable(register ClientPtr client) static int ProcXF86DRIGetDrawableInfo(register ClientPtr client) { + REQUEST_HEAD_STRUCT(xXF86DRIGetDrawableInfoReq); + xXF86DRIGetDrawableInfoReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, @@ -365,8 +369,6 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client) drm_clip_rect_t *pBackClipRects; int backX, backY, rc; - REQUEST(xXF86DRIGetDrawableInfoReq); - REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq); if (stuff->screen >= screenInfo.numScreens) { client->errorValue = stuff->screen; return BadValue; @@ -453,6 +455,8 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client) static int ProcXF86DRIGetDeviceInfo(register ClientPtr client) { + REQUEST_HEAD_STRUCT(xXF86DRIGetDeviceInfoReq); + xXF86DRIGetDeviceInfoReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, @@ -460,8 +464,6 @@ ProcXF86DRIGetDeviceInfo(register ClientPtr client) drm_handle_t hFrameBuffer; void *pDevPrivate; - REQUEST(xXF86DRIGetDeviceInfoReq); - REQUEST_SIZE_MATCH(xXF86DRIGetDeviceInfoReq); if (stuff->screen >= screenInfo.numScreens) { client->errorValue = stuff->screen; return BadValue; @@ -536,15 +538,6 @@ ProcXF86DRIDispatch(register ClientPtr client) } } -static int _X_COLD -SProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client) -{ - REQUEST(xXF86DRIQueryDirectRenderingCapableReq); - REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq); - swapl(&stuff->screen); - return ProcXF86DRIQueryDirectRenderingCapable(client); -} - static int _X_COLD SProcXF86DRIDispatch(register ClientPtr client) { @@ -558,7 +551,7 @@ SProcXF86DRIDispatch(register ClientPtr client) case X_XF86DRIQueryVersion: return ProcXF86DRIQueryVersion(client); case X_XF86DRIQueryDirectRenderingCapable: - return SProcXF86DRIQueryDirectRenderingCapable(client); + return ProcXF86DRIQueryDirectRenderingCapable(client); default: return DRIErrorBase + XF86DRIClientNotLocal; }